找回密码
 中文实名注册
查看: 180|回复: 0

星·

[复制链接]

2

主题

7

帖子

289

积分

中级会员

Rank: 3Rank: 3

积分
289
发表于 2023-6-11 17:19:16 | 显示全部楼层 |阅读模式
snake_list = [[400,400],[420,400],[440,400],[460,400],[480,100]]
for position in snake_list:
    print(position)

if event.type==pygame.KEYDOWN:
    if event .key == pygame.K_UP:
        direction = 'up'
    if event .key == pygame.K_DOWN:
        direction = 'down'
    if event .key == pygame.K_LEFT:
        direction = 'left'
    if event .key == pygame.K_RIGHT:
        direction = 'right'

if direction == 'up':
    head_x = snake_list[0][0]
    head_y = snake_list[0][1] - 20
    head = [head_x, head_y]
    snake_list. insert(0,head)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 中文实名注册

本版积分规则

小黑屋|东台市机器人学会 ( 苏ICP备2021035350号-1;苏ICP备2021035350号-2;苏ICP备2021035350号-3 )

GMT+8, 2024-4-30 11:25 , Processed in 0.036720 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表