-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakeSprite.py
executable file
·61 lines (56 loc) · 2.07 KB
/
snakeSprite.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env python
import pygame
import basicSprite
from helpers import *
class Snake(basicSprite.Sprite):
def __init__(self, centerPoint, image):
"""initialize base class"""
basicSprite.Sprite.__init__(self, centerPoint, image,'SN')
"""Initialize the number of pellets eaten"""
self.letters = 0
"""Set the number of Pixels to move each time"""
self.x_dist = 24
self.y_dist = 24
self.yMove = 0;
self.xMove = 0;
"""Initialize how much we are moving"""
def MoveKey(self,key):
if (self.xMove == 0 and self.yMove == 0):
if (key == K_RIGHT):
self.xMove += self.x_dist
elif (key == K_LEFT):
self.xMove += -self.x_dist
elif (key == K_UP):
self.yMove += -self.y_dist
elif (key == K_DOWN):
self.yMove += self.y_dist
# def MoveKeyDown(self, key):
# """This function sets the xMove or yMove variables that will
# then move the snake when update() function is called. The
# xMove and yMove values will be returned to normal when this
# keys MoveKeyUp function is called."""
#
# if (key == K_RIGHT):
# self.xMove += self.x_dist
# elif (key == K_LEFT):
# self.xMove += -self.x_dist
# elif (key == K_UP):
# self.yMove += -self.y_dist
# elif (key == K_DOWN):
# self.yMove += self.y_dist
#
# def MoveKeyUp(self, key):
# """This function resets the xMove or yMove variables that will
# then move the snake when update() function is called. The
# xMove and yMove values will be returned to normal when this
# keys MoveKeyUp function is called."""
#
# if (key == K_RIGHT):
# self.xMove += -self.x_dist
# elif (key == K_LEFT):
# self.xMove += self.x_dist
# elif (key == K_UP):
# self.yMove += self.y_dist
# elif (key == K_DOWN):
# self.yMove += -self.y_dist
#