"""
倾巢出动_飞机大战敌机类, 这是一个动画。
读者再加是一个玩家,让它射击就可以把这个动画变成一个射击游戏了.
"""
import glob
import pygame
from pygame.locals import *
from random import randint,choice
class Enemy():
def __init__(self,costume,screen):
"""参数说明:
costume:造型
explosion_costume:爆炸造型
screen:渲染面
"""
def update(self):
self.rect.move_ip(self.xspeed,self.yspeed)
if self.rect.top > self.sh:
self.rect.bottom = randint(-2000,-10)
def draw(self):
self.screen.blit(self.image,self.rect)
if __name__ == "__main__":
enemy_images = glob.glob("*.gif")
print(enemy_images)
width,height = 800,600
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("倾巢而出_李兴球")
background = pygame.image.load("bg.png")
enemies = [Enemy(choice(enemy_images),screen) for i in range(10)]
clock = pygame.time.Clock()
running = True
while running:
clock.tick(60)
for event in pygame.event.get():
if event.type ==QUIT:
running = False
pygame.display.update()
pygame.quit()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

