Уведомления

Группа в Telegram: @pythonsu

#1 Март 5, 2018 21:37:47

matvey21
Зарегистрирован: 2018-03-05
Сообщения: 5
Репутация: +  0  -
Профиль   Отправить e-mail  

Помогите пожалуйста не запускается программа....

Не запускается программа помогите пожалуйста

Основная программа

 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(ai_settings)
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT: sys.exit()
        screen.fill(ai_settings.bg_color)
        ship.blitme()
        pygame.display.flip()
run_game()


программа Ship
 import pygame
class Ship():
    def __init__(self,screen):
        self.screen=screen
        self.image=pygame.image.load_basic('images/ship.bmp')
        self.rect=self.image.get_rect()
        self.screen_rect=screen.get_rect()
        self.rect.centerx=self.screen_rect.centrex
        self.rect.bottom=self.screen_rect.bottom
    def blitme(self):
        self.screen.blit(self.image,self.rect)


программа Setings
 class Settings():
    def __init__(self):
        self.screen_width=1200
        self.screen_height=600
        self.bg_color=(255,0,0)


А ошибка при запуске вот такая
 Traceback (most recent call last):
  File "D:/програмирование/pyton/alien_invasion/aloen_invasion.py", line 18, in <module>
    run_game()
  File "D:/програмирование/pyton/alien_invasion/aloen_invasion.py", line 11, in run_game
    ship = Ship(ai_settings)
  File "D:\програмирование\pyton\alien_invasion\ship.py", line 7, in __init__
    self.screen_rect=screen.get_rect()
AttributeError: 'Settings' object has no attribute 'get_rect' 



Отредактировано matvey21 (Март 6, 2018 20:43:06)

Офлайн

#2 Март 6, 2018 08:41:11

JOHN_16
От: Россия, Петропавловск-Камчатск
Зарегистрирован: 2010-03-22
Сообщения: 3292
Репутация: +  221  -
Профиль   Отправить e-mail  

Помогите пожалуйста не запускается программа....

код нужно постить в специальных тегах code, иначе теряется оформление (вы же сами это видите) и программа становится не читаемой - а значит вам вероятнее всего никто не поможет



_________________________________________________________________________________
полезный блог о python john16blog.blogspot.com

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version