|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import sys
import pygame
from settings import Settings
from ship import Ship
def run_game():
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width,ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
#创建一艘飞船
ship = Ship(screen)
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
screen.fill(be_color)
screen.fill(ai_settings.bg_color)
ship.blite()
pygame.display.flip()
run_game()
class Settings:
def _int_(self):
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (230,230,230)
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============ RESTART: C:\Users\asus\Desktop\外星人入侵\alien_invasion.py ============
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:\Users\asus\Desktop\外星人入侵\alien_invasion.py", line 31, in <module>
run_game()
File "C:\Users\asus\Desktop\外星人入侵\alien_invasion.py", line 12, in run_game
(ai_settings.screen_width,ai_settings.screen_height))
AttributeError: 'Settings' object has no attribute 'screen_width'
>>>
我按照书上的的代码打的为什么一直有问题
|
|