【发布时间】:2017-12-02 22:09:02
【问题描述】:
标题很容易解释。我正在尝试找出如何在 python 中为这个俄罗斯方块游戏制作一个带有数组的矩形。
代码如下:
screen = pygame.display.set_mode((400,800))
#Rectangle Variables
x = 200
y = 0
width = 50
height = 50
thickness = 5
speed = 1
#Colors
red = (255,0,0)
white = (255,255, 255)
green = (0,255,0)
blue = (0,0,255)
while(True):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit (); sys.exit ();
#These lines ^ make the user able to exit out of the game window
y = y+1
pygame.draw.rect((screen) , red, (x,y,width,height), thickness)
pygame.display.update()
【问题讨论】:
-
请隔离您遇到的问题,而不是转储代码块并说如何执行此操作?
-
没问题,我刚改了。
-
您必须说明孤立的问题是什么。我们不会为您编写新代码,您会隔离问题/错误,我们会修复它。
-
问题是我不知道该怎么做。到目前为止,我的代码有效,但我不知道如何包含一个数组以创建多个矩形。
-
使用
for循环从数组/列表中获取元素,并与draw.rect()一起使用
标签: python arrays pygame rectangles