我正在研究这款游戏,我希望它具有滚动背景和一些花花公子。每当我去按下空格键而不是扔打孔精灵时,它就会加载左空闲的精灵。香港专业教育学院一直试图改变我的正确和错误的陈述,什么也没有发生,我还是在一两堂课中添加了我,但也没有成功。
在一天的大部分时间里,我一直在努力,感谢任何帮助。
import pygame
pygame.init()
class player(object):
def __init__(self,x,y,width,height):
self.x = x
self.y = y
self.width = width
self.height = height
self.vel = 5
self.isJump = False
self.left = False
self.right = False
self.walkCount = 0
self.jumpCount = 10
self.standing = True
def draw(self, win):
if self.walkCount + 1 >= 27:
self.walkCount = 0
if not(self.standing):
if self.left:
win.blit(walkLeft[self.walkCount//9], (self.x,self.y))
self.walkCount += 1
elif self.right:
win.blit(walkRight[self.walkCount//9], (self.x,self.y))
self.walkCount +=1
else:
if self.right:
win.blit(walkRight[0], (self.x, self.y))
else:
win.blit(walkLeft[0], (self.x, self.y))
class Attacks(object):
attack = pygame.image.load("atk3.png")
def __init__(self, x, y, width, height, attack):
self.x = x
self.y = y
self.width = width
self.height = height
self.attack = True
def draw(self, win):
self.attack()
if self.attack:
win.blit(attack, (self.x, self.y))
else:
self.attack = True
if not(self.attack):
self.attack = False
def redrawGameWindow():
win.blit(bg, (0, 0))
bob.draw(win)
jerk.draw(win)
for Attack in attack:
attack.draw(win)
pygame.display.update()
#While true
bob = player(100, 200, 128, 128)
jerk = enemy(500, 200, 164, 100, 600)
attack = []
run = True
while run:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
bob.attack = True
bob.standing = False
bob.left = False
bob.right = False
redrawGameWindow()
pygame.quit()