예제 #1
0
파일: Esper.py 프로젝트: Mahdarah/rougelike
def main_menu():
    img = image_load('background.png')

    while not tdl.event.is_window_closed():
        #show background image at twice regular console resolution
        img.blit_2x(root,0,0)

        #show games title and credits
        title = 'THIS GAME HAS NO NAME YET'
        center = (SCREEN_WIDTH - len(title)) //2
        root.draw_str(center, SCREEN_HEIGHT//2-6,title,bg=None,fg=colors.light_red)

        title = 'By Mahdarah'
        center = (SCREEN_WIDTH - len(title)) //2
        root.draw_str(center, SCREEN_HEIGHT//2-4,title,bg=None,fg=colors.light_red)

        #show options and wait for players choice
        choice = menu('',['New game','Continue game','Quit'],24)

        if choice == 0: #new game
            new_game()
            play_game()
        elif choice == 1: #load game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()

        elif choice == 2: #quit
            break
예제 #2
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0, libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16, libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    img = libtcodpy.image_from_console(console)
    libtcodpy.image_refresh_console(img, console)
    libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('libtcod/data/img/circle.png'))
def character_portrait(target):
    portrait_image = libtcod.image_load('green.png')
    libtcod.image_blit_rect(
        portrait_image, 0,
        game_constants.screen_width - game_constants.character_portrait_width,
        game_constants.panel_y, game_constants.character_portrait_width,
        game_constants.panel_height, libtcod.BKGND_SET)
예제 #4
0
def main_menu():
    img = libtcod.image_load("menu_background.png")

    while not libtcod.console_is_window_closed():
        # Show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)

        # Show the game's title and credits
        libtcod.console_set_default_foreground(0, libtcod.light_blue)
        libtcod.console_print_ex(0, int(SCREEN_WIDTH / 2),
                                 int(SCREEN_HEIGHT / 2 - 6),
                                 libtcod.BKGND_NONE, libtcod.CENTER,
                                 "Roguelike thinger")
        libtcod.console_print_ex(0, int(SCREEN_WIDTH / 2),
                                 int(SCREEN_HEIGHT / 2 - 4),
                                 libtcod.BKGND_NONE, libtcod.CENTER,
                                 "Written by Cody Kelly and Roguebasin")

        # Show options and wait for the player's choice
        choice = menu("", ["Start a new game", "Continue last game", "Quit"],
                      24)

        if choice == 0:  # New game
            new_game()
            play_game()
        elif choice == 1:  # Load last game
            load_game()
            play_game()
        elif choice == 2:  # Quit
            break
예제 #5
0
def main_menu():
    img = image_load("menu_background1.png")
    pygame.mixer.init()
    while not tdl.event.is_window_closed():
        img.blit_2x(root, 0, 0)

        title = 'Pyrl'
        center = (SCREEN_WIDTH-len(title)) // 2
        root.draw_str(center, SCREEN_HEIGHT//2-2, title, bg=None, fg=colors.white)

        title = 'By Nick Hilger'
        center = (SCREEN_WIDTH - len(title)) // 2
        root.draw_str(center, SCREEN_HEIGHT-2, title, bg=None, fg=colors.light_gray)

        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24, SCREEN_HEIGHT//2)

        if choice == 0:
            new_game()
            play_game()
        if choice == 1:  # load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:
            break
예제 #6
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0,
                         libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16,
                              libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    img = libtcodpy.image_from_console(console)
    libtcodpy.image_refresh_console(img, console)
    libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('libtcod/data/img/circle.png'))
예제 #7
0
def main_menu():
    img = image_load(os.path.join(assets_dir, 'menu_background.png'))
    # show the background image, at twice the regular console resolution

    offset_x = (SCREEN_WIDTH - 80) // 2
    offset_y = (SCREEN_HEIGHT - 50) // 2

    while not tdl.event.is_window_closed():
        img.blit_2x(root_view, offset_x, offset_y)

        # show the game's title, and some credits!
        title = 'ROGUELIKE'
        center = (SCREEN_WIDTH - len(title)) // 2
        root_view.draw_str(center, 2, title, bg=None, fg=Colors.light_yellow)

        title = 'By Scoppio'
        center = (SCREEN_WIDTH - len(title)) // 2
        root_view.draw_str(center,
                           SCREEN_HEIGHT - 2,
                           title,
                           bg=None,
                           fg=Colors.light_yellow)

        # show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:  # new game
            new_game()
            play_game()
        elif choice == 1:
            load()
            play_game()
        elif choice == 2:  # quit
            break
예제 #8
0
파일: role.py 프로젝트: nebiont/rogue
class Warrior(Role):
    name = 'Rageoholic'
    description = '''Joe cannot live without rageahol. He crushes his foes with sheer rage
and feeds off of their pain. In dire situation he can unleash his inner monster:

A creature so powerful that nothing can contain its rage. Joe has a large pool of HP and can use the power of rageohol to destroy his foes.'''

    portrait = libtcod.image_load(
        os.path.join(definitions.ROOT_DIR, 'data', 'joe.png'))
    con = 14
    base_defense = 12
    base_power = 14
    dmg = [1, 8]
    hitdie = [1, 10]
    tackle = Ability(
        'Tackle',
        description=None,
        ability_function=tackle,
        targeting=True,
        targeting_message=Message(
            'Left-click a target tile for the fireball, or right-click to cancel.',
            libtcod.light_cyan))
    abilities = [tackle]

    def role_init(self):
        self.owner.fighter.con = self.con
        self.owner.fighter.base_defense = self.base_defense
        self.owner.fighter.base_power = self.base_power
        self.owner.fighter.dmg = self.dmg
        self.owner.fighter.hitdie = self.hitdie
        self.owner.name = 'Joe'
        self.owner.fighter.init_hp()
        self.owner.abilities = self.abilities
        for ability in self.abilities:
            ability.owner = self.owner
예제 #9
0
파일: main.py 프로젝트: Jipes/TYRMA
def main_menu():
    img = libtcod.image_load('assets/menu.png')

    while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)
        #show the game's title, and some credits!
        libtcod.console_set_default_foreground(0, libtcod.light_yellow)
        libtcod.console_print_ex(0, int(SCREEN_WIDTH/2), int(SCREEN_HEIGHT/2-4), libtcod.BKGND_NONE, libtcod.CENTER,
            'TYRMÄ')
        libtcod.console_print_ex(0, int(SCREEN_WIDTH/2), int(SCREEN_HEIGHT-2), libtcod.BKGND_NONE, libtcod.CENTER,
            'By Hakaponttoauto')
        #show options and wait for the player's choice
        choice = menu('', ['Uusi peli', 'Jatka tallennuksesta', 'Lopeta'], 24)

        if choice == 0:  #new game
            new_game()
            play_game()
        elif choice == 1:  #load last game
            try:
                load_game()
            except:
                msgbox('\n Ei tallennettua peliä.\n', 24)
                continue
            play_game()
        elif choice == 2:  #quit
            break
def main_menu():
    img = libtcod.image_load('menu_background.png')
 
    while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)
 
        #show the game's title, and some credits!
        libtcod.console_set_default_foreground(0, libtcod.light_yellow)
        libtcod.console_print_ex(0, SCREEN_WIDTH//2, SCREEN_HEIGHT//2-4, libtcod.BKGND_NONE, libtcod.CENTER,
            'TOMBS OF THE ANCIENT KINGS')
        libtcod.console_print_ex(0, SCREEN_WIDTH//2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER,
            'By Jotaf')
 
        #show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24)
 
        if choice == 0:  #new game
            new_game()
            play_game()
        if choice == 1:  #load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:  #quit
            break
예제 #11
0
def main_menu():
    img = libtcod.image_load('menu_background.png')

    while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)

        #show the game's title, and some credits!
        libtcod.console_set_default_foreground(0, libtcod.light_yellow)
        libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4,
                                 libtcod.BKGND_NONE, libtcod.CENTER,
                                 'TOMBS OF THE ANCIENT KINGS')
        libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2,
                                 libtcod.BKGND_NONE, libtcod.CENTER,
                                 'By Jotaf')

        #show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:  #new game
            new_game()
            play_game()
        if choice == 1:  #load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:  #quit
            break
예제 #12
0
def main_menu():
    img = image_load('menu_background1.png')

    while not tdl.event.is_window_closed():
        # show the background image, at twice the regular console resolution
        img.blit_2x(root, 0, 0)

        # show the game's title, and some credits!
        title = 'TOMBS OF THE ANCIENT KINGS'
        center = (SCREEN_WIDTH - len(title)) // 2
        root.draw_str(center, SCREEN_HEIGHT // 2 - 4, title, bg=None, fg=colors.light_yellow)

        title = 'roguelike'
        center = (SCREEN_WIDTH - len(title)) // 2
        root.draw_str(center, SCREEN_HEIGHT - 2, title, bg=None, fg=colors.light_yellow)

        # show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24)

        if choice == 0:  # new game
            new_game()
            play_game()
        if choice == 1:  # load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:  # quit
            break
예제 #13
0
 def update(self) -> None:
     img_path = f"{data.img_dir}/{self.character.sex}/{self.character.img}"
     img = tcod.image_load(img_path)
     img.scale(2 * self.geometry.content_width,
               2 * self.geometry.content_height)
     img.blit_2x(self.console, 0, 0)
     self.should_update = False
예제 #14
0
def main_menu():
	img = image_load('menu_background.png')
	
	while not tdl.event.is_window_closed():
		img.blit_2x(root, 0, 0)	# Blit the image, at twice the regular console resolution
		
		# Game Title and Credits
		title = 'THE ABYSS'
		centre = (SCREEN_WIDTH - len(title)) // 2
		root.draw_str(centre, SCREEN_HEIGHT // 2 -4, title, bg=None, fg=colours.light_yellow)
		
		title = 'by Edward Powell'
		centre = (SCREEN_WIDTH - len(title)) // 2
		root.draw_str(centre, SCREEN_HEIGHT-2, title, bg=None, fg=colours.light_yellow)
		
		# Show options
		choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24)
		
		if choice == 0:
			new_game()
			play_game()
		if choice == 1:  #load last game
			try: load_game()
			except:
				msgbox('\n No saved game to load.\n', 24)
				continue
			play_game()
		elif choice == 2: break
예제 #15
0
def main_menu():
    img = libtcod.image_load('kawaii.png')

    while not libtcod.console_is_window_closed():
        #show bkgnd img at twice the size
        libtcod.image_blit_2x(img, 0, 0, 0)

        #show game title and credits
        libtcod.console_set_default_foreground(0, libtcod.purple)
        libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, '~WOGUEY WIKEY~')
        libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'by n8uv')

        #show options and wait for the player's choice
        choice = menu('', ['Pway a new game!', 'Return to Daddy', 'Quit OwO'], 24)

        if choice == 0: #new game
            new_game()
            play_game()
        if choice == 1: #load last game
            try:
                load_game()
            except:
                msgbox('\n u dont have saved game \n', 24)
                continue
            play_game()
        elif choice == 2: #quit
            break
예제 #16
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GRAYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(constants['screen_width'], constants['screen_height'], constants['window_title'], False)

    con = libtcod.console_new(constants['screen_width'], constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'], constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image, constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(constants)
                game_state = GameStates.PLAYERS_TURN
                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game()
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con, panel, constants)
            show_main_menu = True
예제 #17
0
 def __init__(self, source):
     super().__init__(source)
     self.type = MenuType.GRAPHIC
     self.title = "CURSED FOREST"
     self.header = ""
     self.background_image = libtcod.image_load("menu_background.png")
     self.display_options = [Texts.get_text('MAIN_MENU_NEW_GAME'),
                             Texts.get_text('MAIN_MENU_LOAD_GAME'),
                             Texts.get_text('MAIN_MENU_LANGUAGES'),
                             Texts.get_text('MAIN_MENU_QUIT')]
     self._options = ["new game", "load game", "languages", "quit"]
     self.forced_width = 24
예제 #18
0
def DiedMenu(con, screen_width, screen_height):
    img = libtcod.image_load('ball.png')
    libtcod.image_blit_2x(img, 0, 0, 0, 0, 0, -1, -1)

    libtcod.console_set_default_foreground(0, libtcod.blue)

    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height / 2) - 4, libtcod.BKGND_NONE, libtcod.CENTER,
                             'GAME OVER!')
    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height - 2), libtcod.BKGND_NONE, libtcod.CENTER,
                             'By Francesco Rostagno')

    menu(con, '', ['New Game','Quit'], 24, screen_width, screen_height)
예제 #19
0
def WinMenu(con, screen_width, screen_height):
    img = libtcod.image_load('ball.png')
    libtcod.image_blit_2x(img, 0, 0, 0, 0, 0, -1, -1)

    libtcod.console_set_default_foreground(0, libtcod.blue)

    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height / 2) - 4, libtcod.BKGND_NONE, libtcod.CENTER,
                             'YOU WIN CONGRATULATIONS')
    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height - 2), libtcod.BKGND_NONE, libtcod.CENTER,
                             'By Francesco Rostagno')

    menu(con, '', '', 24, screen_width, screen_height)
예제 #20
0
def main_menu():
    world = GameWorld()
    bg_image = image_load(settings.MAIN_MENU_BG_IMG)

    while not tdl.event.is_window_closed():
        console.clear()
        root_console.clear()

        image_blit_2x(bg_image, 0, 0, 0)

        print_str(settings.GAME_SCREEN_WIDTH / 2 -
                  (len(settings.GAME_TITLE) / 2),
                  settings.GAME_SCREEN_HEIGHT / 2 - 4,
                  settings.GAME_TITLE.upper(),
                  bg=None,
                  fg=colors.gold,
                  bg_alpha=0.75)
        print_str(settings.GAME_SCREEN_WIDTH / 2 -
                  (len(settings.GAME_AUTHOR) / 2),
                  settings.GAME_SCREEN_HEIGHT - 3,
                  settings.GAME_AUTHOR,
                  bg=None,
                  fg=colors.gold,
                  bg_alpha=0.75)

        choice = world.render.menu('', [
            'Play a new game',
            'Continue last game',
            'Quit',
        ], 24)

        world.render.flush_console()

        if choice == 0:
            new_world = new_game()
            play_game(new_world)
        elif choice == 1:
            try:
                old_world = load_game()
                old_world.status = GAME_STATUS.PLAY
                play_game(old_world)
            except Exception as err:
                log.warn(err)
                msg = 'No saved game to load!'
                message_box(settings.GAME_SCREEN_WIDTH / 2 - (len(msg) / 2),
                            settings.GAME_SCREEN_HEIGHT / 2,
                            msg,
                            width=len(msg),
                            fg=colors.red,
                            bg_alpha=1.0)
        elif choice == 2:
            break
예제 #21
0
    def run(self):
        """ Main game loop """
        show_main_menu = True
        show_load_error_message = False

        main_menu_background_image = tcod.image_load('menu_background.png')

        key = tcod.Key()
        mouse = tcod.Mouse()

        while not tcod.console_is_window_closed():
            tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS | tcod.EVENT_MOUSE,
                                     key, mouse)

            if show_main_menu:
                main_menu(self.main_console, main_menu_background_image,
                          self.constants['screen_width'],
                          self.constants['screen_height'])

                if show_load_error_message:
                    message_box(self.main_console, 'No save game to load', 50,
                                self.constants['screen_width'],
                                self.constants['screen_height'])

                tcod.console_flush()

                action = handle_main_menu(key)

                a_new_game = action.get('new_game')
                a_load_saved_game = action.get('load_game')
                a_exit_game = action.get('exit')

                if show_load_error_message and (a_new_game or a_load_saved_game
                                                or a_exit_game):
                    show_load_error_message = False
                elif a_new_game:
                    self.reset_game()
                    show_main_menu = False
                elif a_load_saved_game:
                    try:
                        self.load_saved_game()
                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                elif a_exit_game:
                    break

            else:
                tcod.console_clear(self.main_console)
                self.play_game()

                show_main_menu = True
예제 #22
0
def main_menu(con, screen_width, screen_height):

    img = libtcod.image_load('ball.png')
    libtcod.image_blit_2x(img,0, 0, 0 , 0,0,-1,-1)


    libtcod.console_set_default_foreground(0, libtcod.blue)

    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height / 2) - 4, libtcod.BKGND_NONE, libtcod.CENTER,
                             'THE REVENGE OF A PLAYER!')
    libtcod.console_print_ex(0, int(screen_width / 2), int(screen_height - 2), libtcod.BKGND_NONE, libtcod.CENTER,
                             'By Francesco Rostagno')

    menu(con, '', ['Play a new game', 'Continue last game', 'Quit'], 24, screen_width, screen_height)
예제 #23
0
    def __init__(self):
        super().__init__()
        self.type = MenuType.GRAPHIC
        self.title = Texts.get_text('VICTORY_1_TITLE')
        self.header = ("""
        
""" + Texts.get_text('VICTORY_1_PART_1') + ' \n' +
                       Texts.get_text('VICTORY_1_PART_2') + '\n' + """

""")
        self.background_image = libtcod.image_load("menu_background.png")
        self._options = []
        self.forced_width = 48
        self.back_to_main = True
예제 #24
0
    def __init__(self):

        tdl.set_font('arial10x10.png', greyscale=True, altLayout=True)
        self.root = tdl.init(SCREEN_WIDTH,
                             SCREEN_HEIGHT,
                             title="Roguelike",
                             fullscreen=False)
        tdl.setFPS(LIMIT_FPS)
        self.con = tdl.Console(MAP_WIDTH, MAP_HEIGHT)
        self.panel = tdl.Console(SCREEN_WIDTH, PANEL_HEIGHT)
        self.panel2 = tdl.Console(PANEL_2_WIDTH, PANEL_2_HEIGHT)
        self.visible_tiles = []
        self.fov_recompute = True
        self.bg_img = image_load('menu_background.png')
        self.game_msgs = []
예제 #25
0
    def main(self):
        self.renderer.render_root()

        show_main_menu = True
        show_load_error_message = False

        main_menu_background_image = tcod.image_load(screen_vars.menu_background_img)

        while True:
            if show_main_menu:
                main_menu(main_menu_background_image, menu_vars.main_width, self.renderer)

                for raw_event in tcod.event.wait():
                    if show_load_error_message:
                        message_box('No save game to load', 50, self.renderer)

                    tcod.console_flush()

                    event = event_handler.handle_main_menu(raw_event)
                    new_game = event.get('new_game')
                    load_saved_game = event.get('load_saved_game')
                    exit_game = event.get('exit_game')

                    if show_load_error_message and (new_game or load_saved_game or exit_game):
                        show_load_error_message = False
                    elif new_game:
                        self.entities, self.world_map, self.message_log, self.game_state = get_game_variables()
                        show_main_menu = False
                        break
                    elif load_saved_game:
                        try:
                            self.entities, self.world_map, self.message_log, self.game_state = load_game()
                            show_main_menu = False
                            break
                        except FileNotFoundError:
                            show_load_error_message = True
                    elif exit_game:
                        raise SystemExit
            else:
                self.renderer.clear()
                if self.world_map.current_dungeon:
                    self.player_location = PlayerLocations.DUNGEON
                self.play_game()

                self.player_location = PlayerLocations.WORLD_MAP
                show_main_menu = True
예제 #26
0
def main_menu(console: tcod.console.Console, bg_image: str, screen_width: int,
              screen_height: int) -> None:
    console.clear()

    bg_image = tcod.image_load(bg_image)
    bg_image.blit_2x(console, 0, 0)

    title_con = tcod.console_from_xp("arcturus.xp")

    title_con.blit(console, 24, 24, bg_alpha=0.0)

    menu(console,
         "", ["New Game", "Load Game", "Quit"],
         13,
         screen_width,
         screen_height,
         sy=31)
예제 #27
0
파일: utils.py 프로젝트: lergor/SD
class UISettings:
    game_font = 'src/ui/graphics/arial12x12.png'
    background_image = image_load('src/ui/graphics/background.png')
    info_file = 'src/ui/graphics/info'
    window_title = 'Roguelike'
    author = 'By lergor'
    screen_width = 90
    screen_height = 50
    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height
    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1
    map_width = 80
    map_height = 43
    room_max_size = 10
    room_min_size = 6
    max_rooms = 30
    max_monsters_per_room = 3
    max_items_per_room = 2
    inventory_width = 50
    character_screen = (30, 10)

    dark_wall = (0, 0, 100)
    dark_ground = (50, 50, 150)
    light_wall = (130, 110, 50)
    light_ground = (200, 180, 50)
    desaturated_green = (63, 127, 63)
    my_green = (0, 127, 63)
    darker_green = (0, 127, 0)
    dark_red = (191, 0, 0)
    white = (255, 255, 255)
    black = (0, 0, 0)
    red = (255, 0, 0)
    orange = (255, 127, 0)
    light_red = (255, 114, 114)
    darker_red = (127, 0, 0)
    violet = (127, 0, 255)
    yellow = (255, 255, 0)
    blue = (0, 0, 255)
    green = (0, 255, 0)
    light_yellow = (255, 255, 114)
    light_violet = (184, 114, 255)
    sky = (20, 50, 150)
    darker_orange = (127, 63, 0)
예제 #28
0
 def __init__(self,
              title: str,
              logo: Path,
              credits: str,
              title_color: Color = None,
              credits_color: Color = None,
              credits_format_colors: Dict[int, Color] = None):
     if credits_format_colors is None:
         self.credits_format_colors = {}
     else:
         self.credits_format_colors = credits_format_colors
     self.title = title
     self.logo = image_load(logo.as_posix())
     self.credits = credits
     self._centered_title: str = None
     self._centered_credits: str = None
     self.title_color = title_color
     self.credits_color = credits_color
예제 #29
0
def main_menu():
    """
        Show the menu, with a background image
    """
    img = image_load('menu_background1.png')

    while not tdl.event.is_window_closed():
        # show the background image, at twice the regular console resolution
        img.blit_2x(root, 0, 0)

        # show the game's title, and some credits
        title = 'Catacombs of the Ancients'
        center = (SCREEN_WIDTH - len(title)) // 2
        root.draw_str(center,
                      SCREEN_HEIGHT // 2 - 4,
                      title,
                      bg=None,
                      fg=roguecolors.light_yellow)

        title = 'By Jotaf'
        center = (SCREEN_WIDTH - len(title)) // 2
        root.draw_str(center,
                      SCREEN_HEIGHT - 2,
                      title,
                      bg=None,
                      fg=roguecolors.light_yellow)

        # show options and wait for player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:  # new game
            new_game()
            play_game()
        if choice == 1:  # load last game
            try:
                load_game()
            except:
                msgbox('\n No previous game to load.\n')
                continue
            play_game()
        elif choice == 2:  # quit
            break
예제 #30
0
파일: role.py 프로젝트: nebiont/rogue
class Ranger(Role):
    name = 'Beast Master'
    description = '''Kyle is a trained beaster master who holds domain over many beast. He summons these beasts to support him on the battlefield.

Kyle is a ranged fighter using bows as his primary weapon, but his true power lies with the beasts he summons to aid him in battle.'''

    portrait = libtcod.image_load(
        os.path.join(definitions.ROOT_DIR, 'data', 'kyle.png'))
    con = 10
    base_defense = 8
    base_power = 12
    dmg = [1, 6]
    hitdie = [1, 6]

    def role_init(self):
        self.owner.fighter.con = self.con
        self.owner.fighter.base_defense = self.base_defense
        self.owner.fighter.base_power = self.base_power
        self.owner.fighter.dmg = self.dmg
        self.owner.fighter.hitdie = self.hitdie
        self.owner.name = 'Kyle'
        self.owner.fighter.init_hp()
예제 #31
0
파일: role.py 프로젝트: nebiont/rogue
class Rogue(Role):
    name = 'Sense Bender'
    description = '''Brett is a creature of the shadows. He uses shadows and nonsense to confuse his foes and then takes advantage of their vulnerable state.

Brett is a frontline fighter that lacks HP, but makes up for it with his unit control capabilities.'''

    portrait = libtcod.image_load(
        os.path.join(definitions.ROOT_DIR, 'data', 'brett.png'))
    con = 10
    base_defense = 10
    base_power = 14
    dmg = [1, 8]
    hitdie = [1, 8]

    def role_init(self):
        self.owner.fighter.con = self.con
        self.owner.fighter.base_defense = self.base_defense
        self.owner.fighter.base_power = self.base_power
        self.owner.fighter.dmg = self.dmg
        self.owner.fighter.hitdie = self.hitdie
        self.owner.name = 'Brett'
        self.owner.fighter.init_hp()
예제 #32
0
파일: role.py 프로젝트: nebiont/rogue
class Paladin(Role):
    name = 'Bald Bro'
    description = '''Devon is a devout follower of Baldicus. As a 'Bald Bro' Devon can harness the power of Baldicus' divine will to smite his foes and heal his wounds.

Devon is a front line fighter that relies on his divine powers to defeat his oponents.'''

    portrait = libtcod.image_load(
        os.path.join(definitions.ROOT_DIR, 'data', 'devon.png'))
    con = 10
    base_defense = 14
    base_power = 12
    dmg = [1, 6]
    hitdie = [1, 8]

    def role_init(self):
        self.owner.fighter.con = self.con
        self.owner.fighter.base_defense = self.base_defense
        self.owner.fighter.base_power = self.base_power
        self.owner.fighter.dmg = self.dmg
        self.owner.fighter.hitdie = self.hitdie
        self.owner.name = 'Devon'
        self.owner.fighter.init_hp()