Commit 60931e6c authored by 13680905's avatar 13680905

Upload New File

parent a30ce040
'''from PyQt5.QtGui import *
import os
img = QImage()
path = "./images"
for root, dirs, files in os.walk(path):
for name in files:
print(name)
if name.endswith(".png"):
print(name)
print("./img/" + name)
img.load("./img/" + name)
img.save("./img/" + name)'''
import pygame
from planes_sprites import *
pygame.init()
#创建游戏窗口大小
screen=pygame.display.set_mode((480,700))
#创建背景图像
bg = pygame.image.load("./images/background.png")
screen.blit(bg,(0,0))
pygame.display.update()
#创建英雄飞机
hero = pygame.image.load("./images/me1.png")
screen.blit(hero,(150,500))
#在所有绘制工作完成后,统一调用update方法
pygame.display.update()
#创建时钟对象
clock = pygame.time.Clock()
hero_rect=pygame.Rect(150,500,102,126)
i=0
l=0
#建立精灵组和精灵
enemy=GameSprite("./images/enemy1.png")
enemy2=GameSprite("./images/enemy2.png",2)
enemy_group=pygame.sprite.Group(enemy,enemy2)
#创建游戏内循环
while True:
if hero_rect.y < -102:
hero_rect = pygame.Rect(150, 700, 102, 126)
clock.tick(60)
hero_rect.y -= 1
screen.blit(bg, (0, 0))
screen.blit(hero, hero_rect)
for event in pygame.event.get():
print(event)
if event.type==pygame.QUIT:
print("游戏退出")
if event.type==pygame.KEYDOWN:
if event.key==276:
print("测试为左")
print("键位测试")
enemy_group.update()
enemy_group.draw(screen)
pygame.display.update()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment