找回密码
 中文实名注册
12
返回列表 发新帖
楼主: 潘凌城

nihao

[复制链接]

1

主题

12

帖子

157

积分

注册会员

Rank: 2

积分
157
 楼主| 发表于 2024-4-13 17:24:16 | 显示全部楼层
sdgffsdgsdfgsdfg
回复

使用道具 举报

1

主题

12

帖子

157

积分

注册会员

Rank: 2

积分
157
 楼主| 发表于 2024-4-13 17:37:37 | 显示全部楼层
import pygame
pygame.init()

screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("我的游戏")

ball_size = 50;ball_x = 400;ball_y = 300;ball_speed =1

while Ture:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        print(keys)
        ball_x = ball_speed
回复

使用道具 举报

15

主题

131

帖子

3383

积分

论坛元老

Rank: 8Rank: 8

积分
3383
发表于 2024-4-13 17:37:38 | 显示全部楼层
if keys[pygame.K_LEFT]:
        print(keys)
        ball_x-=ball_speed
    if keys[pygame.K_RIGHT]:
        
        ball_x-=ball_speed
    if keys[pygame.K_UP]:
        
        ball_x-=ball_speed
    if keys[pygame.K_K_DOWN]:
        
        ball_x-=ball_speed

    screen.fill((255,255,255))
    pygame.draw.circle(screen,(255,0,0),(ball_x,ball_y),ball_size)
    pygame.display.update()

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-1 07:07 , Processed in 0.038921 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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