import pygame
import time
import random
from pygame.locals import *
class BasePlane(object):
def __init__(self,screen_temp,hp,star,x,y,image_name):
self.x = x
self.y = y
self.hp = hp
self.screen = screen_temp
self.star = star
self.bullet_list = []
self.image = pygame.image.load(image_name)
def display(self):
if self.hp>0:
self.screen.blit(self.image,(self.x,self.y))
elif self.hp<=0:
pass
for bullet in self.bullet_list:
bullet.display()
if bullet.judge():
self.bullet_list.remove(bullet)
class EnemyPlane1(BasePlane):
def __init__(self,screen_temp):
BasePlane.__init__(self,screen_temp,100,0,200,0,'./enemy1.png')
self.count = 1
self.random = 1
def automove(self):
if self.x<0 or self.x>423:
self.count += 1
if self.count%2!=0:
self.x-=5
else:
self.x+=
面向对象开发pygame
最新推荐文章于 2024-04-24 13:35:29 发布