snake4.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:SnakeGame 作者: KyrosDigital 项目源码 文件源码
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
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号