-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathsnake1.py
More file actions
29 lines (24 loc) · 792 Bytes
/
snake1.py
File metadata and controls
29 lines (24 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
Snake Game Part 1
'''
''' #1 import some stuff '''
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP
from random import randint
''' #2 Define some variables '''
WIDTH = 35 # total game cell width and height
HEIGHT = 20
MAX_X = WIDTH - 2 # sets max inside the game, so the snake wont hit the border
MAX_Y = HEIGHT - 2
SNAKE_LENGTH = 5 # Starting snake length
SNAKE_X = SNAKE_LENGTH + 1
SNAKE_Y = 3
TIMEOUT = 100 #this controls the speed of the game
''' #3 make Snake Oject '''
class Snake(object):
def __init__(self):
self.x = 'Hisss!'
def method_a(self, foo):
print self.x + ' ' + foo
snake = Snake() # We do not pass any argument to the __init__ method
snake.method_a('Says the snake') # We only pass a single argument