Example #1
0
    
    elif conf.state == MENU_STATE:
        if (sound_manager.playing_background_music and sound_manager.music_playing != MENU_MUSIC_PATH):
            sound_manager.stop_background_music()
        elif (not sound_manager.playing_background_music):
            sound_manager.play_background_music(MENU_MUSIC_PATH)

        menu.draw_menu(surface, font, conf)
        if (not conf.music_enabled):
            sound_manager.enabled = False
            sound_manager.stop_background_music()
        elif(not sound_manager.enabled):
            sound_manager.enabled = True
    elif conf.state == CONTINUE_GAME_STATE:
        conf.state = GAME_STATE
        if (configuration.has_saved_game()):
            player.score = configuration.load_score()
    elif conf.state == NEW_GAME_STATE:
        level = Level(CELL_SIZE, LEVEL_INITIAL_ROWS, LEVEL_INITIAL_COLS)
        player = Player(level, 0, PLAYER_SPAWN_POSITION_COL * CELL_SIZE, (SURFACE_LEVEL - 1 )* CELL_SIZE)
        lava = Lava()
        camera = Camera()
        conf.state = GAME_STATE
    elif conf.state == MAN_STATE:
        if (sound_manager.playing_background_music and sound_manager.music_playing != SHOP_MUSIC_PATH):
            sound_manager.stop_background_music()
        elif (not sound_manager.playing_background_music):
            sound_manager.play_background_music(SHOP_MUSIC_PATH)

        #Input
        for event in pygame.event.get():
Example #2
0
import pygame, sys
import configuration

from constants import *
from pygame.locals import *

pos = 0
menu_redirection = {
    0: NEW_GAME_STATE,
    1: CONTINUE_GAME_STATE,
    2: MAN_STATE,
    4: CREDITS_STATE
}
game_saved = configuration.has_saved_game()


def draw_menu(surface, font, conf):
    global pos, music_enabled
    #Input
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                pygame.quit()
                sys.exit()
            elif event.key == K_UP:
                pos = (pos - 1) % 6
                if pos == 1 and not game_saved:
                    pos = (pos - 1) % 6
Example #3
0
import pygame, sys
import configuration

from constants import *
from pygame.locals import *

pos = 0
menu_redirection = {0: NEW_GAME_STATE, 1: CONTINUE_GAME_STATE, 2: MAN_STATE, 4: CREDITS_STATE}
game_saved = configuration.has_saved_game()

def draw_menu(surface, font, conf):
    global pos, music_enabled
	#Input
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                pygame.quit()
                sys.exit()
            elif event.key == K_UP:
                pos = (pos - 1) % 6
                if pos == 1 and not game_saved:
                    pos = (pos - 1) % 6
            elif event.key == K_DOWN:
                pos = (pos + 1) % 6
                if pos == 1 and not game_saved:
                    pos = (pos + 1) % 6
            elif event.key == K_RETURN:
                if pos == 3: