键盘输入立刻反应"/>
python 键盘输入立刻反应
跟着那个12岁的少年学pygame的时候,遇到点问题,原文地址:青少年如何使用Python开发游戏
做完第三步之后,怎么按键盘都反应,也没有报错,win32,pygame1.9.1,python2.7
#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))
keys = [False, False, False, False]
playerpos = [100, 100]
#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
for x in range(width/grass.get_width()+1):
for y in range(height/gra
更多推荐
python 键盘输入立刻反应
发布评论