我试图在矩形上blit图像 这是我创建矩形的功能。
def drawCell(coords,ccolor):
#Here coords is the coordnnates (x and y axis) for rectangle
#cclor is colour for the rectangle , white in my program.
global score
for coord in coords:
x=coord['x']*cellSize
y=coord['y']*cellSize
makeCell=pygame.Rect(x,y,cellSize,cellSize)
pygame.draw.rect(gameDisplay,ccolor,makeCell)
if makeCell.colliderect(foodrect): #If the rectangle collides with food
#score gets added and the food is blitted
#to a random
foodrect.x = random.randint(0, display_width-25)
foodrect.y = random.randint(0, display_height-25)
score+=1
scoredisplay(score) #Displays Score
这是游戏循环中的函数调用:
drawCell(coords,white)
现在我想要它做的是矩形上的blit this,这样看起来苹果正在移动(移动功能不同,这里没有提供)。
答案 0 :(得分:0)
当然,您可以在gameDisplay.blit(imgname, (x,y))
pygame.draw.rect(gameDisplay,ccolor,makeCell)