Open damusss opened 2 years ago
class Menu():
def __init__(self):
self.surf = pygame.image.load("Assets/SplashScreen.png")
self.surf.set_colorkey((0, 0, 0), RLEACCEL)
self.start_button = Button1()
self.quit_button = Button2()
def draw_menu(self, screen):
screen.blit(self.surf,(0,0))
menu = Menu()
# Main loop
while running:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
elif event.type == QUIT:
running = False
if is_started == True: # these stuff should be done only if the game has started
elif event.type == ADDENEMY:
new_enemy = Enemy()
enemies.add(new_enemy)
all_sprites.add(new_enemy)
elif event.type == ADDCLOUD:
new_cloud = Cloud()
clouds.add(new_cloud)
all_sprites.add(new_cloud)
for entity in all_sprites:
screen.blit(entity.surf, entity.rect)
if pygame.sprite.spritecollideany(player, enemies):
player.kill()
jetsound.stop()
pygame.quit()
running = False
screen.fill((135, 206, 250))
if is_started == True:
for entity in all_sprites:
screen.blit(entity.surf, entity.rect)
screen.blit(player.surf, player.rect)
pressed_keys = pygame.key.get_pressed()
enemies.update()
clouds.update()
player.update(pressed_keys)
elif is_started == False:
menu.draw_menu(screen)
if menu.start_button.draw(screen):
is_started = True
if menu.quit_button.draw(screen):
running = False
pygame.display.flip()
clock.tick(FrameRateTick)
class Menu(): def init(self): self.surf = pygame.image.load("Assets/SplashScreen.png") self.surf.set_colorkey((0, 0, 0), RLEACCEL)
menu = Menu()
Main loop
while running: for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_ESCAPE: running = False elif event.type == QUIT: running = False if is_started == True: # these stuff should be done only if the game has started elif event.type == ADDENEMY: new_enemy = Enemy() enemies.add(new_enemy) all_sprites.add(new_enemy)