基本功能包括:
- 玩家飞机显示
- 玩家发射子弹
- 敌机显示
- 敌机发射子弹
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 08:09:08 2020
@author: Administrator
"""
import pygame,sys,time,random
from pygame.locals import *
class PlayerPlane(object):
def __init__(self,screen):
#飞机子弹
self.bullet = []
#设置速度
self.speed = 5
#设置飞机名字
self.name = "player"
#飞机zhaop
planeImage = "Resources/hero.png"
self.image = pygame.image.load(planeImage).convert()
#设置默认坐标
self.x = 200
self.y = 520
#窗口属性
self.chuangkou = screen
def draw(self):
self.chuangkou.blit(self.image,(self.x,self.y))
for temp in self.bullet:
temp.draw()
def planeHandle(self,keyValue):
if keyValue == "right":
self.x+=