def __init__(self, x, y, window):
self.body_list = []
self.hit_score = 0
self.timeout = TIMEOUT
#0 Append The Snake's range to the Body object for Snakes Body
for i in range(SNAKE_LENGTH, 0, -1):
self.body_list.append(Body(x - i, y))
#1 Define and append the snakes head
self.body_list.append(Body(x, y, '0'))
#2 define the window
self.window = window
#3 Move snake to right when game starts
self.direction = KEY_RIGHT
#4 set snakes lst head coordinate
self.last_head_coor = (x, y)
#5 define direction map
self.direction_map = {
KEY_UP: self.move_up,
KEY_DOWN: self.move_down,
KEY_LEFT: self.move_left,
KEY_RIGHT: self.move_right
}
评论列表
文章目录