diff --git a/snake.py b/snake.py index 14fd8c97..ea86427c 100644 --- a/snake.py +++ b/snake.py @@ -21,6 +21,7 @@ def __init__(self, start, dirnx=1, dirny=0, color=(255,0,0)): self.dirny = dirny # "L", "R", "U", "D" self.color = color + def move(self, dirnx, dirny): self.dirnx = dirnx self.dirny = dirny @@ -46,6 +47,7 @@ def draw(self, surface, eyes=False): class snake(): body = [] turns = {} + def __init__(self, color, pos): #pos is given as coordinates on the grid ex (1,5) @@ -54,6 +56,7 @@ def __init__(self, color, pos): self.body.append(self.head) self.dirnx = 0 self.dirny = 1 + def move(self): for event in pygame.event.get(): @@ -98,6 +101,7 @@ def reset(self,pos): self.dirnx = 0 self.dirny = 1 + def addCube(self): tail = self.body[-1] dx, dy = tail.dirnx, tail.dirny @@ -113,6 +117,7 @@ def addCube(self): self.body[-1].dirnx = dx self.body[-1].dirny = dy + def draw(self, surface): for i,c in enumerate(self.body): @@ -133,7 +138,6 @@ def redrawWindow(): pass - def drawGrid(w, rows, surface): sizeBtwn = w // rows @@ -191,8 +195,7 @@ def main(): break redrawWindow() - -main() - - + +if __name__ == '__main__': + main()