我创建的那个一张图片上下移动和敌机.但是屏幕一直黑.和别人的代码一样到底哪不行
def __create_sprites(self):
bg1 = BackGround()
bg2 = BackGround(True)
bg2.rect.y= -bg2.rect.height
self.back_group = pygame.sprite.Group(bg1,bg2)
self.enemy_group= pygame.sprite.Group
def __event_handler(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
PlaneGame.__game_over()
elif event.type==CREATE_ENEMY:
print("敌机出场")
evemy = Enemy()
self.enemy_group.add(1)
def __check_collied(self):
pass
def __update_sprites(self):
self.back_groud.update()
self.back_groud.draw(self.screen)
self.enemy_group.update()
self.enemy_group.draw(self.screen)
**游戏精灵模块**
import random
import pygame
SCREEN_RECT = pygame.Rect(0,0,400,600)
CREATE_ENEMY=pygame.USEREVENT
class GameSprites(pygame.sprite.Sprite):
"""飞机大战游戏精灵"""
def __init__(self,image_name,speed=1):
super().__init__()
self.image = pygame.image.load(image_name)
self.rect = self.image.get_rect()
self.speed = speed
def update(self, *args):
self.rect.y += self.speed
class BackGround(GameSprites):
"""游戏背景"""
def __init__(self,is_out = False):
pygame.display.set_caption("周彬大战菊花怪")
if is_out:
self.rect.y = -self.rect.y
def update(self, *args):
super().update()
if self.rect.y >= SCREEN_RECT.height:
self.rect.y = -self.rect.height