|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pygame
from sprites1 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()
f = pygame.image.load("./images/me1.png")
screen.blit(f, (200, 500))
pygame.display.update()
clock = pygame.time.Clock()
hero_rect = pygame.Rect(150,300,102,126)
enemy = GameSprite("./images/enemy2.png")
enemy1 = GameSprite("./images/enemy2.png",2)
enemy_group = pygame.sprite.Group(enemy)
while True:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
print("游戏结束。。。")
pygame.quit()
exit()
hero_rect.y -= 5
if hero_rect.y <= -100:
hero_rect.y = 700
screen.blit(bg,(0,0))
screen.blit(f,hero_rect)
enemy_group.update
enemy_group.draw(screen)
pygame.display.update()
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "C:/Users/tlan2/Desktop/真·飞机大战/01.py", line 19, in <module>
enemy = GameSprite("./images/enemy2.png")
File "C:\Users\tlan2\Desktop\真·飞机大战\venv\sprites1.py", line 7, in __init__
self.rect = relf.image.get_rect()
NameError: name 'relf' is not defined
先把报错的信息提到的对应位置的relf改成self,再看有无报错。
|
|