Im a beginner pygameneer and im making this sweet space invaders type game called mooshalot escape, the point being that you will get to become a mooshalot and fight the evils that threaten the condition of the mooshalots, its a self project to help me become a better programmer, (of course its a free game so when done ill post it lols) The point being I'm having trouble opening my game, the code runs properly, but the screen is the main issue, I don't think I did a good job connecting the screen, could someone take a look would really appreciate the help and input in any shape or format, regards
import sys
import pygame
from settings import Settings
from Mooshipclassr import Mooship
from Mooshammo import Mooshammo
class MooshalotEscape:
def __init__(self):
pygame.init()
self.settings = Settings()
self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
self.settings.screen_width = self.screen.get_rect().width
self.settings.screen_height = self.screen.get_rect().height
pygame.display.set_caption('Mooshalot Escape')
self.bg_color = (106, 228, 241)
self.mooship = Mooship(self)
self.bullets = pygame.sprite.Group()
def run_game(self):
while True:
self._check_events()
self.mooship.update()
self.bullets.update()
self._update_screen()
def _check_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
self._check_keydown_events(event)
elif event.type == pygame.KEYUP:
self._check_keyup_events(event)
def _check_keydown_events(self, event):
if event.key == pygame.K_RIGHT:
self.mooship.moving_right = True
elif event.key == pygame.K_LEFT:
self.mooship.moving_left = True
elif event.key == pygame.K_q:
sys.exit()
elif event.key == pygame.K_SPACE:
self._fire_mooshammo()
def _check_keyup_events(self, event):
if event.key == pygame.K_RIGHT:
self.mooship.moving_right = False
elif event.key == pygame.K_LEFT:
self.mooship.moving_left = False
def _fire_mooshammo(self):
new_mooshammo = Mooshammo(self)
self.bullets.add(new_mooshammo)
def _update_screen(self):
self.screen.fill(self.bg_color)
self.mooship.blitme()
pygame.display.flip()
if __name__ == 'main':
ai = MooshalotEscape()
ai.run_game()
'''settings class'''
class Settings:
def __init__(self):
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (106, 228, 241)
self.mooship_speed = 1.5
self.mooshammo_speed = 1.0
self.mooshammo_width = 3
self.mooshammo_height = 15
self.mooshammo_color = (60, 60, 60)