我是pygame的新手,我正在製作一個側面滾動的遊戲,它使用一個鳥作爲角色,它飛行,但我試圖讓它在屏幕上上下移動,但我無法圖如何。側面滾動Pygame
import pygame
from pygame.locals import *
import os
import sys
import time
pygame.init()
class Fly:
def __init__(self):
self.last_update = time.clock()
self.screen = pygame.display.set_mode((700, 400), 0, 32)
#Load bird
self.bird_state = 1
self.bird_frames = []
for r in xrange(1, 5):
self.bird_frames.append(pygame.image.load('bird%s.png' % r))
self.bg = pygame.image.load('bg.png').convert()
self.Loop()
def eventLoop(self):
'Take and process input from perephirals'
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
def Update(self):
self.bird_state += 1
if self.bird_state > 4:
self.bird_state = 1
def Draw(self):
self.screen.blit(self.bg, [0, 0])
self.screen.blit(self.bird_frames[self.bird_state - 1], (150, 150))
def Loop(self):
while 1:
self.eventLoop()
if time.clock() - self.last_update > 0.15:
self.Update()
self.last_update = time.clock()
self.Draw()
pygame.display.update()
Fly()
你可以對你的問題更清楚,你是怎麼試圖ECT ECT – 2013-04-23 22:38:34