python编译时的错误:

http://img.mukewang.com/5979bb7c00015dbd05480091.jpg

这是网上的游戏:兔子和獾

下面这一段出上面的结果,不知道怎么回事有时候可执行,上次把# 6 - draw the screen elements
screen.blit(player, (100,100))和下面隔开执行成功了一次,求解。


# 1 - Import library
import pygame
from pygame.locals import *
 
# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
 
# 3 - Load images
player = pygame.image.load("resources/images/dude.png")
grass = pygame.image.load("resources/images/grass.png")
castle = pygame.image.load("resources/images/castle.png")
 
# 4 - keep looping through
while 1:
    # 5 - clear the screen before drawing it again
screen.fill(0)
    
# 6 - draw the screen elements
screen.blit(player, (100,100))
for x in range(width\grass.get_width()+1):
        for y in range(height\grass.get_height()+1):
            screen.blit(grass,(x*100,y*100))
screen.blit(castle,(0,30))
screen.blit(castle,(0,135))
screen.blit(castle,(0,240))
screen.blit(castle,(0,345 ))
    # 7 - update the screen
    pygame.display.flip()
    # 8 - loop through the events
    for event in pygame.event.get():
        # check if the event is the X button 
        if event.type==pygame.QUIT:
            # if it is quit the game
            pygame.quit() 
            exit(0)


qq_头疼了_0
浏览 1960回答 2
2回答

产品经理不是经理

中文冒号?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python
测试