'''
Created on 21. sep. 2013
Page 136 in ze almighty python book, 4.3
@author: Christian
'''
import sys,pygame,time
pygame.init()
numLevels = 15 # Number of levels
unitSize = 25 # Height of one level
white = (255,255,255) # RGB Value of White
black = (0,0,0) # RGB Value of Black
size = unitSize * (numLevels + 1)
xPos = size /2.0 # Constant position of X value
screenSize = size,size # Screen size to accomodate pygame
screen = pygame.display.set_mode(screenSize)
for level in range(numLevels):
yPos = (level + 1) * unitSize
width = (level +1) * unitSize
block = pygame.draw.rect(screen,white,(0,0,width,unitSize),0)
block.move(xPos,yPos)
pygame.time.wait(100)
pygame.display.flip()
block.move(xPos,yPos)應該可以工作,但不會出於某種奇怪的原因。我不知道爲什麼。 我相當肯定,其他一切工作都很好,我在網站上搜索了幾個小時之後才尋求幫助。Rect.move()不移動矩形
我非常抱歉沒有足夠清楚我想做什麼,我有多愚蠢。代碼旨在構建一個金字塔,當時只有一層。 並感謝您的幫助,您的建議像一個魅力工作! –