小编aTA*_*ian的帖子

Pygame:如何根据输入顺时针/逆时针旋转矩形

到目前为止,我已经制作了一个矩形,它跟随用户的鼠标并用a键逆时针旋转,用键顺时针旋转d

目前矩形跟随鼠标,但一旦用户开始旋转矩形,矩形就会变得非常滞后和变形。我需要帮助保持矩形不变和恒定的 FPS。感谢您的帮助!

这是代码:

import pygame as py  

# define constants  
WIDTH = 500  
HEIGHT = 500  
FPS = 200

# define colors  
BLACK = (0 , 0 , 0)  
GREEN = (0 , 255 , 0)

# initialize pygame and create screen  
py.init()  
screen = py.display.set_mode((WIDTH , HEIGHT))  
# for setting FPS  
clock = py.time.Clock()  

rot = 0  
rot_speed = 2  

# define a surface (RECTANGLE)  
image_orig = py.Surface((1 , 100))  
# for making transparent …
Run Code Online (Sandbox Code Playgroud)

python pygame

4
推荐指数
1
解决办法
777
查看次数

标签 统计

pygame ×1

python ×1