如何在Pygame中保持旋转正方形?

问题描述

我想知道如何在pygame中继续旋转一个简单的正方形。

我编写了这个简单的代码,中间有一个黑色的背景和一个白色的正方形。我怎样才能继续旋转那个白色正方形?

在此程序:

import pygame
pygame.init()

window = pygame.display.set_mode((500,500))
pygame.display.set_caption("code man")


# the square

class square:
    def __init__(self,x,y,height,width,color):
        self.x = x
        self.y = y
        self.height = height
        self.width = width
        self.color = color
        self.rect = pygame.Rect(x,width)
    def draw(self):
        self.rect.topleft = (self.x,self.y)
        pygame.draw.rect(window,self.color,self.rect)

white = (255,255,255)
square1 = square(200,200,50,white)


# redraw the window

def redraw():
    BLACK = (0,0)

    # fill the window black
    window.fill(BLACK)

    # draw the square
    square1.draw()

    # update the screen
    pygame.display.update()

# the main loop
runninggame = True
while runninggame:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            runninggame = False


    # call the redraw
    redraw()

    
   

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)