def main_menu(): global game_state img = libtcod.image_load('playground-title-small.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 options and wait for the player's choice if game_state == 'won': img = libtcod.image_load('playground-win-small.png') choice = draw.menu( 'Congrats! Your score was ' + str(objects.score) + '.', ['Play a new game', 'Instructions', 'About', 'Quit'], 35) else: choice = draw.menu( '', ['Play a new game', 'Instructions', 'About', 'Quit'], 24) if choice == 0: #new game new_game() play_game() elif choice == 1: #instructions blah = draw.instructions('', instructions, 50) elif choice == 2: #about blah = draw.instructions('', credits, 50) elif choice == 3: #quit break
def main_menu(): if (libtcod.random_get_int(0, 0, 1) == 0): img = libtcod.image_load('menu_background.png') else: img = libtcod.image_load('menu_background2.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_set_alignment(0, libtcod.CENTER) libtcod.console_print(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4, 'Party Rogue WIP') libtcod.console_print(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, 'By Dragynrain') libtcod.console_set_alignment(0, libtcod.LEFT) #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
def main_menu(): global game_state img = libtcod.image_load('playground-title-small.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 options and wait for the player's choice if game_state == 'won': img = libtcod.image_load('playground-win-small.png') choice = draw.menu('Congrats! Your score was ' + str(objects.score) + '.', ['Play a new game', 'Instructions','About','Quit'], 35) else: choice = draw.menu('', ['Play a new game', 'Instructions','About','Quit'], 24) if choice == 0: #new game new_game() play_game() elif choice == 1: #instructions blah = draw.instructions('',instructions,50) elif choice == 2: #about blah = draw.instructions('',credits,50) elif choice == 3: #quit break
def main_menu(): img = libtcod.image_load('menu_background1.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, 'The Universal Reference Frame') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Pat East and Scotty Jones') #show options and wait for the player's choice #Have the Player Choose his race choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) if choice == 0: #new game new_game() play_game() elif 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
def main_menu(): img = libtcod.image_load('star.png') while not libtcod.console_is_window_closed(): # background image libtcod.image_blit_2x(img, 0, 0, 0) # title and credits libtcod.console_set_default_foreground(0, libtcod.red) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, 'TEST GAME') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-3, libtcod.BKGND_NONE, libtcod.CENTER, 'by MoyTW') # menu + choice choice = menu('', ['New game', 'Continue game', 'Quit'], 24) if choice == 0: new_game() play_game() elif choice == 1: try: load_game() except: msgbox('\n Error loading game.\n', 24) continue play_game() elif choice == 2: break
def main_menu(): img = tcod.image_load('menu_background.png') while not tcod.console_is_window_closed(): # Show the background image, at twice the regular console resolution tcod.image_blit_2x(img, 0, 0, 0) # Show the game's title and some credits tcod.console_set_default_foreground(0, tcod.light_yellow) tcod.console_print_ex(0, SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 4, tcod.BKGND_NONE, tcod.CENTER, 'FASCIST EXTERMINATORS') tcod.console_print_ex(0, SCREEN_WIDTH // 2, SCREEN_HEIGHT - 2, tcod.BKGND_NONE, tcod.CENTER, 'By fejoa') # 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 last game try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: # Quit break
def story_slide(): img = libtcod.image_load('menu_background2.png') if dungeon_level == 0: level_subtitle = 'LEVEL 0' elif dungeon_level == 1: level_subtitle = 'LEVEL 1' elif dungeon_level == 2: level_subtitle = 'BEFORE THE STARDUST FADES' elif dungeon_level == 3: level_subtitle = 'WISH UPON THE DIAMOND DUST' 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-6, libtcod.BKGND_NONE, libtcod.CENTER, 'CHAPTER '+str(dungeon_level)) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, level_subtitle) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2-2, libtcod.BKGND_NONE, libtcod.CENTER, '- w5748 -') #show options and wait for the player's choice choice = menu('', ['PROCEED'], 11) if choice == 0: #PROCEED PATH, THINK ABOUT A save_game() ROUTE break elif choice == 1: break
def main_menu(): img = libtcod.image_load(b'img/backgrounds/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 libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_set_alignment(0, libtcod.CENTER) libtcod.console_print(0, int(round(SCREEN_WIDTH / 2)), int(round(SCREEN_HEIGHT / 2 - 4)), 'THE LEGEND OF THARSA') libtcod.console_print(0, int(round(SCREEN_WIDTH / 2)), int(round(SCREEN_HEIGHT - 2)), 'By Athemis') # Show the 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 last game try: load_game() except: msgbox('\n No saved game to load. \n', 24) continue play_game() elif choice == 2: # Quit break
def main_menu(): """ Game main menu """ img = libtcod.image_load('menu_background.png') title = 'Rumble in the Underdeep' author = 'By @cr8ivecodesmith' while not libtcod.console_is_window_closed(): # blit the bg image at twice the regular console resolution libtcod.image_blit_2x(img, 0, 0, 0) libtcod.console_set_default_foreground(0, libtcod.gold) libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, title) libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, author) # show the options and wait for the player's input choice = menu('', ['New game', 'Continue', 'Quit'], 24) if choice == 0: # New game new_game() play_game() elif choice == 1: try: load_game() play_game() except Exception as e: print(e) msgbox('\nNo saved game to load.\n', 24) continue elif choice == 2: # Quit break
def __init__(self,newParty,newEnemies): self.party = newParty # The adventuring party, retrieved from the previous scene. self.enemies = newEnemies # The enemies. Will later be retrieved from the previous scene, but for now will just be generated on the spot. self.nextScene = None # The scene to advance to. This is meant for when one side loses. # Determine turn order. self.turnOrder = [] # Store the turn order. for ally in self.party: # Add all allies. self.turnOrder.append(ally) for enemy in self.enemies: # Add all enemies. self.turnOrder.append(enemy) random.shuffle(self.turnOrder) # Shuffle the array. # Later, there will be the extra step of sorting by DEX, but for now, leaving it as-is. Even then, the initial shuffle will be necessary, to randomly break any ties resulting from two actors having the same DEX. self.log = [] # The current combat log. self.partyBoxes = [] # The boxes to display on the left. for i in range(4): # Draw party boxes, deciding whether to have a name displaying in each or not. if len(self.party) > i: self.partyBoxes.append(bx.Box(0,i*6,22,6,self.party[i].getName())) else: self.partyBoxes.append(bx.Box(0,i*6,22,6,None)) self.enemyBoxes = [] # The boxes to display on the right. for i in range(6): # Draw enemy boxes, deciding whether to have a name displaying in each or not. if len(self.enemies) > i: self.enemyBoxes.append(bx.Box(59,i*4,21,4,self.enemies[i].getName())) else: self.enemyBoxes.append(bx.Box(59,i*4,21,4,None)) self.infoBox = bx.Box(22,10,37,14,"Combat Log") # This box has no function in itself, but will show the combat log via code in refresh(). self.turnBox = bx.Box(22,0,18,3) # This box has no function in itself, but will show whose turn it is via code in refresh(). self.turnOrderBox = bx.Box(40,0,19,10,"Turn Order") # The idea behind this box should be clear. This one will also be dynamically resized based on party size. self.image = rl.image_load('battlebg2.png'.encode()) # Load the test battle background image. This will later be able to be toggled via an option in the options menu. self.moveBoxes = [] # The boxes for the character's action selection. self.animPhase = 0 # Which phase the animation is in. 1 is playing the animation itself, 2 is the target's box blinking, 0 is no animation. self.animStarted = time.time() # When the current animation phase started. This theoretically doesn't need to be initialized yet, but just in case... self.animTarget = 0 # Who the current animation is playing on. 0-3 are party members, 4-9 are enemies, 10 is all party members, 11 is all enemies.
def main_menu(self): #load the background. img = libtcod.image_load('menu_background.png') #while the window is open, display the menu. 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.SCREEN_WIDTH / 2, Screen.SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, 'TOMBS OF THE ANCIENT KINGS') libtcod.console_print_ex(0, Screen.SCREEN_WIDTH / 2, Screen.SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Steven') #show options and wait for the player's choice choice = self.screen.menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: #new game self.new_game() self.play_game() elif choice == 1: #load game try: self.load_game() except: #there's an issue (of some sort) loading the game, so just default to no save game error. self.screen.msgbox('\n No saved game to load!\n', 24) continue #play the loaded game. self.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) #title and 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, 'JESUS CHRIST: PATH TO RESSURECTION') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'a game by Peter Rao') #show main menu choice = menu("", ["Play a new game", "Continue last game", "Quit"], 24) if choice == 0: #new game new_game() play_game() if choice == 1: #load game try: load_game() except: msgbox('\n No saved game to load.\n', 24) #libtcod.console_wait_for_keypress(True) continue play_game() if choice == 2: #quit break
def main_menu(): img = libtcod.image_load('homescreen.png') while not libtcod.console_is_window_closed(): #show background image, at double the console resolution libtcod.image_blit_2x(img, 0, 0, 0) #show game title and credits libtcod.console_set_default_foreground(0, libtcod.red) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_SCREEN, libtcod.CENTER, 'Blood For Blood') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_SCREEN, libtcod.CENTER, 'By Dylan Campbell') #show menu options for player choice choice = menu('', ['New Game','Load Game','Quit'], 24) if choice == 0: #new game new_game() play_game() elif choice == 1: #load game try: load_game() except: msgbox('\n No save game to load \n', 24) continue play_game() elif choice == 2: #quit break
def main_menu(): img = libtcod.image_load('menu_background1.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 game details, credits, etc libtcod.console_set_foreground_color(0, libtcod.light_yellow) libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, 'The Frontier') libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, 'By Winkle and Littlefoot') #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 save game try: load_game() except: msgbox('\n No save game to load\n', 24) continue play_game() elif choice == 2: #Quit break
def main_menu(): img = libtcod.image_load('menu.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) libtcod.console_set_default_foreground(0, libtcod.yellow) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, 'The Halls of the Ancients') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Forty-Bot') choice = menu('', ['New game', 'Continue', 'Quit'], 24) if choice == 0: new_game() play_game() elif choice == 1: try: load_game() except: msg_box('\nError loading save\n', 24) continue play_game() elif choice == 2: 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
def main_menu(): img = libtcod.image_load('menu_background.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) 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, 'TITLE FORTHCOMING (BETA)') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-3, libtcod.BKGND_NONE, libtcod.CENTER, 'Results may vary') choice = menu('', ['Play a new game', 'Continue last game', 'Controls', 'Quit'], 24) if choice == 0: new_game() play_game() if choice == 1: try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() if choice == 2: msgbox('\n Arrow keys or number pad: move/attack \n 1-9: cast spells \n i: inventory \n g: pick up item \n d: drop items \n c: stats \n Enter: climb ladder \n Escape: quit to main menu', 50) continue elif choice == 3: break
def mainMenu(): image = libtcod.image_load("menu_background1.png") while not libtcod.console_is_window_closed(): #Shows the background image libtcod.image_blit_2x(image, 0, 0, 0) #shows the game title and author libtcod.console_set_foreground_color(0, libtcod.light_orange) libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-5, libtcod.BKGND_NONE, "Jules Quest") libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-3, libtcod.BKGND_NONE, "By Julian Jocque") menuOptions = ["New Game", "Continue", "Quit"] #shows options and waits for a choice choice = menu("", menuOptions, MAIN_MENU_WIDTH) if choice == 0: #new game newGame() playGame() elif choice == 1: #continue try: loadGame() playGame() except: msgBox("\n No save file found.\n", MAIN_MENU_WIDTH) continue #elif choice == 2: #show instructions # menu("\nArrow Keys to move and attack monsters.\nG to pickup an item you are standing on.\nI to open Inventory.\n" +\ # "D to open Drop menu.\nP to pause and unpause.\nC to open Character information screen.\n> to go down stairs.\n" +\ # "Mouse over a tile to see what is on it, either monsters or items.\n", [], SCREEN_WIDTH/2) elif choice == 2: #quit break
def main_menu(): img = libtcod.image_load(b'menu_background3.png') while not libtcod.console_is_window_closed(): # Show the background image at twice the regular resolution. libtcod.image_blit_2x(img, 0, 0, 0) # Show the game's title and 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 NEW BEGINNINGS') libtcod.console_print_ex(0, SCREEN_WIDTH//2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Parker Harris Emerson') # 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 global light light = Light() new_game() play_game() elif 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
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_red) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-8, libtcod.BKGND_NONE, libtcod.CENTER, 'R- U- N-') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-6, libtcod.BKGND_NONE, libtcod.CENTER, 'Something cool') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2-2, libtcod.BKGND_NONE, libtcod.CENTER, '- w5748 -') #show options and wait for the player's choice choice = menu('', ['New Game', 'Load File', '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
def main_menu(new_game, play_game, load_game): """ Prompt the player to start a new game, continue playing the last game, or exit. """ 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) libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_print_ex( 0, config.SCREEN_WIDTH/2, config.SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, 'TOMBS OF THE ANCIENT KINGS') libtcod.console_print_ex( 0, config.SCREEN_WIDTH/2, config.SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Jotaf') (char, choice) = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: play_game(new_game()) if choice == 1: try: player = load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game(player) elif choice == 2: break
def main_menu(): img = libtcod.image_load('terminal12x12_gs_ro.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) 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, 'Tomb of the Ancient Kings') libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'Author') choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: new_game() play_game() if choice == 1: try: load_game() except: msgbox('\n No saved game to load. \n', 24) continue play_game() elif choice == 2: break
def draw_main_menu(con, has_file=False): tcod.console_set_default_foreground(con, COL_A) img = tcod.image_load('small.png') tcod.image_set_key_color(img, tcod.red) tcod.image_blit(img, 0, 45, 30, tcod.BKGND_LIGHTEN, .5, .25, 0) xx=-20 yy=15 can_cont = "" can_del = '' if has_file: can_cont = '-- (c)ontinue' can_del = '-- (D)elete' options=( """ GAME TITLE """+chr(tcod.CHAR_BLOCK2)+chr(tcod.CHAR_BLOCK1)+chr(tcod.CHAR_BLOCK1)+""" | | \t-- (n)ew game | \t--\t%s | | | \t%s | \t-- (esc)cape """ % (can_cont, can_del) ) tcod.console_print_ex(con, game.GAME_WIDTH/4+xx, game.GAME_HEIGHT/3+yy, tcod.BKGND_LIGHTEN, tcod.LEFT,options) tcod.console_print(con, 2, game.GAME_HEIGHT-2, 'oyyooyoyoyoyyooyoyoy') tcod.console_flush() tcod.console_clear(con)
def main_menu(): img = libtcod.image_load('BG_IMG.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.Color(79, 227, 0)) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, libtcod.CENTER, 'mi8-reEVA') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2+4, libtcod.BKGND_NONE, libtcod.CENTER, 'by defined moe.') choice = menu('', ['start game', 'continue', '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: #quit break
def main_menu(): """Displays splash screen and initial options such as new game, continue, save/load.""" global end_credits img = libtcod.image_load('2001_station_and_shuttle.png') end_credits = False while not libtcod.console_is_window_closed(): #show the background image at 2x the normal resolution using special font characters to do sub-cell shading: libtcod.image_blit_2x(img, 0, 0, 0) #show the game's title and opening 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, 'MANY MARTIANS!') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'By K\'NEK-TEK') #show options and wait for the player's choice choice = menu('', ['New Game', 'Continue', 'Quit'], 24) if choice == 0: #new game list_of_maps, map_number = new_game() play_game(list_of_maps, map_number) elif choice == 1: #load game try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game(list_of_maps, map_number) elif choice == 2: #quit break
def main_menu(): img = libtcod.image_load('img/menu_background1.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_print_ex(0, Game.SCREEN_WIDTH / 2, Game.SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, 'TITLE HERE') libtcod.console_print_ex(0, Game.SCREEN_WIDTH / 2, Game.SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Drew') choice = Game.menu( '', ['Play a new game', 'Continue current game', 'Quit'], 24) if choice == 0: Game.new_game() Game.run() elif choice == 1: try: Game.run() except: Game.msgbox('\n No saved game to load.\n', 24) continue elif choice == 2: break
def main_menu(): libtcod.console_set_custom_font( 'terminal8x12_gs_ro.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW) libtcod.console_init_root(cfg.SCREEN_WIDTH, cfg.SCREEN_HEIGHT, 'Monster Genetics', False) libtcod.sys_set_fps(cfg.LIMIT_FPS) img = libtcod.image_load('menu_background.png') while not libtcod.console_is_window_closed(): gui.display_main_menu(img) #show options and wait for the player's choice choice = gui.menu('', [ 'Play a new game', 'Continue last game', 'Display controls', 'Quit' ], 24) if choice == 0: #new game new_game() play_game() elif choice == 1: #load last game try: load_game() except: gui.msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: #controls, will eventually be options menu gui.display_controls() elif choice == 3: #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 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 last game try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: #quit break
def main_menu(self): """THE main menu, no other.""" LIMIT_FPS = 20 libtcod.sys_set_fps(LIMIT_FPS) img = libtcod.image_load('main/lazor.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, color_menu_text) libtcod.console_print_ex(0, SCREEN_WIDTH/2, 1, libtcod.BKGND_NONE, libtcod.CENTER, 'Laz0r Dodging Game') libtcod.console_print_ex(0, SCREEN_WIDTH/2, 2, libtcod.BKGND_NONE, libtcod.CENTER, 'by magikmw') #show options and wait for the player's choice choice = menu('Choose an option:\n', ['Real-Time', 'Turn-Based', 'Highscores', 'Help', 'Quit.'], 18, -10) if choice == 0: #new game self.new_game('RT') if choice == 1: self.new_game('TB') if choice == 2: #TODO the highscore function call here pass if choice == 3: #TODO help screen funcion call here pass if choice == 4: #quit break
def main_menu(): img = libtcod.image_load('menu_background1.png') while not libtcod.console_is_window_closed(): 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, 'Castle of Orkish Warlock') libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Mrzyglosz') libtcod.image_blit_2x(img, 0, 0, 0) choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: new_game() play_game() if choice == 1: try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: break
def main_menu(): img = libtcod.image_load('menu_background1.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.black) libtcod.console_print(0, config.SCREEN_WIDTH/2, config.SCREEN_HEIGHT/2-4, 'P U R G E') libtcod.console_set_default_foreground(0, libtcod.white) libtcod.console_print(0, config.SCREEN_WIDTH/2, config.SCREEN_HEIGHT-2, 'By Nathaniel Berens') #show options and wait for the player's choice choice = gfx.menu(' ', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: #new game new_game() play_game() elif choice == 1: #load last game try: load_game() except: gfx.msgbox('\n No saved game to load. \n', 24) continue play_game() elif choice == 2: #quit break
def main_menu(): img = libtcod.image_load('menu_background1.png') while not libtcod.console_is_window_closed(): # 以分辨率的两倍显示背景图像 libtcod.image_blit_2x(img, 0, 0, 0) # 显示游戏的标题,以及一些积分! 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 COOSK-KUNKUN') # 显示选项并等待玩家的选择 choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: #new game # new_game() # play_game() race_menu() 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
def main_menu(): # will work with no image but the background on the menu will be plain black. img = libtcod.image_load('images\menu_background.png') while not libtcod.console_is_window_closed(): clear_all_consoles() libtcod.image_blit_2x(img, 0, 0, 0) choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], width=24, x=4, y=2) if key.vk == libtcod.KEY_ENTER and (key.lalt or key.ralt): # Alt + Enter: toggle full screen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) if choice == 0: new_game() play_game() elif choice == 1: try: load_game() except: menu('\n No saved game to load. \n', [], width=24, x=((STAT_PANEL_WIDTH + SCREEN_WIDTH - 24) / 2), y=2) continue play_game() elif choice == 2: break
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) # Not portable. #img = libtcodpy.image_from_console(console) #libtcodpy.image_refresh_console(img, console) #libtcodpy.image_delete(img) libtcodpy.image_delete(libtcodpy.image_load('../data/img/circle.png'))
def mainMenu(): img = libtcod.image_load("menu_background1.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. libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 6, libtcod.BKGND_NONE, libtcod.CENTER, "FORCASTIA TALES: THE MARKED") libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, "2014 Studio Draconis") #Show options and wait for the player's choice. choice = menu('', ["Start a New Adventure", "Continue a Previous Adventure", "Quit"], 40) if choice == 0: #NEW GAME startNewGame() playGame() if choice == 1: #LOAD GAME try: loadGame() except: announce("\n No saved game to load. \n", 24) continue playGame() elif choice == 2: #QUIT break
def main_menu(): img = libtcod.image_load('menu_background1.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_foreground_color(0, libtcod.black) libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'P U R G A T O R I O') libtcod.console_set_foreground_color(0, libtcod.white) libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'By CitizenArcane') #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 last game try: load_game() except: msgbox('\n No saved game to load. \n', 24) continue play_game() elif choice == 2: #quit break
def main_menu(): img = libtcod.image_load('moon.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) libtcod.console_set_foreground_color(0, libtcod.light_yellow) libtcod.console_print_center(0, SCREEN_WIDTH / 2, (SCREEN_WIDTH / 2) - 4, libtcod.BKGND_NONE, 'Moon Game') libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, 'James Disley') choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: new_game() play_game() if choice == 1: try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: break
def main_menu(): img = libtcod.image_load('title.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.black) libtcod.console_print_ex(0, SCREEN_WIDTH / 2, int(SCREEN_HEIGHT * .75), libtcod.BKGND_NONE, libtcod.CENTER, 'WizRL') libtcod.console_print_ex(0, SCREEN_WIDTH / 2, int(SCREEN_HEIGHT * .75) + 2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Dragyn') # 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 libtcod.console_clear(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: # quit break
def showDebugScreen(self): # store the current view behind_window = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) libtcod.console_blit(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, behind_window, 0, 0, 1.0, 1.0) # show the background image, at twice the regular console resolution img = libtcod.image_load("./media/menu_debug.png") libtcod.image_blit_2x(img, 0, 0, 0) while not libtcod.console_is_window_closed(): # show options and wait for the player's choice choice = self.showMenu( "Select debug option:", ["Run some test code!", "Show me some game stuff!", "Back"], # Choice 0 # Choice 1 # Choice 2 36, ) # interpret choice if choice is None: continue if choice == 0: print "Running some test code!" self.runTestCode() self.showMessage("Test code complete!", "There might be some output in the console...", 36) continue elif choice == 1: print "Showing some game stuff!" self.newGame() self.showGameScreen() elif choice == 2: # quit print "Back" break # Clean up (restore whatever was behind this window) libtcod.console_blit(behind_window, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 1.0, 1.0) libtcod.console_flush()
def main_menu(): img = libtcod.image_load('img/menu_background1.png') while not libtcod.console_is_window_closed(): Renderer.render_main_screen(img) choice = Renderer.menu('', ['Play a new game', 'Continue current game', 'Quit'], 24, 0) if choice == 0: Renderer.render_main_screen(img) races = race_decoder.decode_all_races() race = Renderer.menu('Pick a race', races, 15, 0) if race is None: continue Renderer.render_main_screen(img) jobs = job_decoder.decode_all_jobs() job = Renderer.menu('Pick a job', jobs, 15, 0) if job is None: continue Game.new_game(races[race].lower(), jobs[job].lower()) Game.run() elif choice == 1: try: Game.run() except: Game.msgbox('\n No saved game to load.\n', 24) continue elif choice == 2: 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
def main_menu(): img = libtcod.image_load('rltutBackdrop.png') while not libtcod.console_is_window_closed(): #libtcod.image_blit(img, 0, 0, 0) #show the background image at twice the regular console resolution libtcod.image_blit_2x(img, 0, 0, 0) #show 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, MAIN_TITLE) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, libtcod.CENTER, 'by Austin McGee') #print controls libtcod.console_print_ex(0, 1, 1, libtcod.BKGND_NONE, libtcod.LEFT, CONTROLS_TEXT) #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
def main_menu(): img = libtcod.image_load('menu_background.png') while not libtcod.console_is_window_closed(): #show the menu image in a terrible way libtcod.image_blit_2x(img, 0, 0, 0) #fancy main menu title and crediting libtcod.console_set_default_foreground(0, libtcod.white) libtcod.console_set_default_background(0, libtcod.black) libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_ALPHA(0.7), libtcod.CENTER, 'JOTAF\'S COMPLETE ROGUELIKE TUTORIAL,') libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-3, libtcod.BKGND_ALPHA(0.7), libtcod.CENTER, 'USING PYTHON+LIBTCOD') #libtcod.console_print_ex(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_ALPHA(0.7), libtcod.CENTER, 'Implemented By') #show main menu optionss and request selection choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) #fullscreen toggle needs to work in main menu too #if key.vk == libtcod.KEY_ENTER and key.lalt: # libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) 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
def main_menu(): #Set up the main menu, which is presented to the player when they first load the game img = libtcod.image_load('images/menu_background1.png') while not libtcod.console_is_window_closed(): #Show the image at twice its usual resolution of the console libtcod.image_blit_2x(img, 0, SCREEN_WIDTH / 6, SCREEN_HEIGHT / 6) #Show the games 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, 'DUNGEONCRAWLER') libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'By Jeremy Cerise') #Show menu options and wait for the players choice choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: #Start a new game #Clear the base conosle, so the menu image and options don't show up under the rest of the UI libtcod.console_set_default_background(0, libtcod.brass) libtcod.console_clear(0) new_game() play_game() elif choice == 1: try: libtcod.console_set_default_background(0, libtcod.brass) libtcod.console_clear(0) load_game() except: msgbox('\n No saved game to load!\n', 24) elif choice == 2: #Exit the program 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_foreground_color(0, libtcod.light_yellow) libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'Rogue-LIKE!') libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'By RobBbot') #show options and wait for the player's choice choice = menu('', ['Play a new game', 'Continue last game', 'Controls', '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: msgbox('\n "g" will pickup items\n\n "i" will bring up your inventory \n\n "d" will drop an item on the ground\n\n Arrow keys move the @ around\n\n Casting Spells requires you to click on the\n mob you want to target after selecting \n the scroll from your inventory') elif choice == 3: #quit break
def print_char_big(self, icon_position, destination, console=0): source_pixel_x = (icon_position % ROW_LENGTH) * settings.TILE_WIDTH source_pixel_y = (icon_position / ROW_LENGTH) * settings.TILE_WIDTH dx, dy = destination if not self.font_image: self.font_image = libtcod.image_load(FONT_FILE_PATH) libtcod.image_set_key_color(self.font_image, libtcod.Color(0, 0, 0)) libtcod.image_blit_2x(self.font_image, console, dx, dy, source_pixel_x, source_pixel_y, settings.TILE_WIDTH, settings.TILE_WIDTH)
def image(file_string): #Create the image console. imagecon = libtcod.console_new(MAP_WINDOW_WIDTH, MAP_WINDOW_HEIGHT) img = libtcod.image_load('resources/' + file_string) #Set green as the transparent colour. #libtcod.console_set_key_color(imagecon, libtcod.Color(0, 255, 0)) #Render the image and blit it to the root console. libtcod.image_blit_rect(img, imagecon, 0, 0, -1, -1, libtcod.BKGND_SET) libtcod.console_blit(imagecon, 0, 0, 50, 50, 0, 0, 0)
def main_menu(con, key, mouse): consts = Constants.consts path = consts['MENU_BACKGROUND'] img = libtcod.image_load(path) while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) choice = Menu.basic_menu(con, '', ['New game', 'Quit'], 24, key) if choice == 0: return True elif choice == 1: return False
def render_main_menu(self): img = tcod.image_load('static/menu_background.png') choice = EXIT_GAME while not tcod.console_is_window_closed(): # show the background image, at twice the regular console resolution tcod.image_blit_2x(img, 0, 0, 0) # game name and credits tcod.console_set_default_foreground(0, tcod.light_yellow) tcod.console_print_ex(0, int(SCREEN_WIDTH / 2), int(SCREEN_HEIGHT / 2 - 4), tcod.BKGND_NONE, tcod.CENTER, GAME_NAME) tcod.console_print_ex(0, int(SCREEN_WIDTH / 2), SCREEN_HEIGHT - 2, tcod.BKGND_NONE, tcod.CENTER, AUTHOR) # show options and wait for the player's choice choice = self.menu( '', ['Play a new game', 'Continue last game', 'Quit'], 24) return choice
def showWelcomeScreen(self): #store the current view behind_window = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) libtcod.console_blit(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, behind_window, 0, 0, 1.0, 1.0) #show the background image, at twice the regular console resolution img = libtcod.image_load('./media/menu_background.png') libtcod.image_blit_2x(img, 0, 0, 0) while not libtcod.console_is_window_closed(): #show options and wait for the player's choice choice = self.showMenu( 'Main menu:\n----------', [ 'Start a new game', # Choice 0 'Continue previous game', # Choice 1 'Go to debug mode', # Choice 2 'Quit' ], # Choice 3 36) #interpret choice if choice is None: continue if choice == 0: print "Start a new game" self.newGame() self.showGameScreen() continue elif choice == 1: print "Continue previous game" self.showMessage('Oops...', 'I don\'t know how to load a game yet :-)', 36) elif choice == 2: # quit print "Go to debug mode" self.showDebugScreen() elif choice == 3: print "Quiting" break #Clean up (restore whatever was behind this window) libtcod.console_blit(behind_window, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 1.0, 1.0) libtcod.console_flush()
def main_menu(): global con con = libtcod.console_new(g.SCREEN_WIDTH, g.SCREEN_HEIGHT) libtcod.console_set_custom_font( 'arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(g.SCREEN_WIDTH, g.SCREEN_HEIGHT, 'python/libtcod tutorial', False) libtcod.sys_set_fps(g.LIMIT_FPS) img = libtcod.image_load('menu_background1.png') # show the background image, at twice the regular console resolution 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, g.SCREEN_WIDTH / 2, g.SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, 'SNAKES IN THE DUNGEON') libtcod.console_print_ex(0, g.SCREEN_WIDTH / 2, g.SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'by whothefuckcares') # 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
def main_menu(): # start game menu - logic handled in officehack.py #background image for menu img = libtcod.image_load('data/img/bg.png') libtcod.image_blit_2x(img, 0, 0, 0) # title libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_set_default_background(0, libtcod.flame) libtcod.console_print_ex(0, gameconfig.SCREEN_WIDTH / 2, gameconfig.SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_SET, libtcod.CENTER, gameconfig.GAME_TITLE) libtcod.console_print_ex(0, gameconfig.SCREEN_WIDTH / 2, gameconfig.SCREEN_HEIGHT / 2 - 3, libtcod.BKGND_SET, libtcod.CENTER, gameconfig.GAME_AUTHOR) return menu('', ['New Game', 'Continue', 'Quit'], 24)
def main_menu(): img = libtcod.image_load('menu_background.png') while not libtcod.console_is_window_closed(): libtcod.image_blit_2x(img, 0, 0, 0) 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, 'ROGUELIKE') libtcod.console_print_ex(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, '') choice = menu('', ['Play a game', 'Quit'], 24) if choice == 0: new_game() play_game() elif choice == 1: break
def showDebugScreen(self): #store the current view behind_window = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) libtcod.console_blit(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, behind_window, 0, 0, 1.0, 1.0) #show the background image, at twice the regular console resolution img = libtcod.image_load('./media/menu_debug.png') libtcod.image_blit_2x(img, 0, 0, 0) while not libtcod.console_is_window_closed(): #show options and wait for the player's choice choice = self.showMenu( 'Select debug option:', [ 'Run some test code!', # Choice 0 'Show me some game stuff!', # Choice 1 'Back' ], # Choice 2 36) #interpret choice if choice is None: continue if choice == 0: print "Running some test code!" self.runTestCode() self.showMessage( 'Test code complete!', 'There might be some output in the console...', 36) continue elif choice == 1: print "Showing some game stuff!" self.newGame() self.showGameScreen() elif choice == 2: # quit print "Back" break #Clean up (restore whatever was behind this window) libtcod.console_blit(behind_window, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 1.0, 1.0) libtcod.console_flush()
def end_game(player): ''' Shows End Game screen ''' constants = get_constants() con = libtcod.console_new(constants['screen_width'], constants['screen_height']) panel = libtcod.console_new(constants['screen_width'], constants['panel_height']) show_end_menu = True # uses custom background image end_menu_background_image = libtcod.image_load('./art/end_screen.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_end_menu: end_menu(con, end_menu_background_image, player, constants['screen_width'], constants['screen_height']) libtcod.console_flush() action = handle_end_menu(key) exit_game = action.get('exit') fullscreen = action.get('fullscreen') # toggle fullscreen if fullscreen: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) if exit_game: show_end_menu = False else: exit()
def main_menu(): img = libtcod.image_load(data.MAIN_MENU_BKG) 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 game title and credits libtcod.console_set_default_foreground(0, libtcod.light_yellow) libtcod.console_print_ex(0, data.SCREEN_WIDTH/2, data.SCREEN_HEIGHT/2 - 4, libtcod.BKGND_NONE, libtcod.CENTER, 'MeFightRogues!') libtcod.console_print_ex(0, data.SCREEN_WIDTH/2, data.SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.CENTER, 'by johnstein!') #show options and wait for the player's choice choice = menu('', [Menuobj('Play a new game'), Menuobj('Battle Royale!'), Menuobj('Continue last game'), Menuobj('Quit')], 24, Game, letterdelim=')') if choice == 0: #new game data.FREE_FOR_ALL_MODE = False data.AUTOMODE = False new_game() play_game() if choice == 1: #new game data.AUTOMODE = True new_game() play_game() if choice == 2: #load last game try: load_game() except: msgbox('\n No saved game to load. \n', Game, 24) continue play_game() elif choice == 3: #quit try: save_game() except: msgbox('Bye!', Game, 24) break
def animate_background(animation_name, duration, reverse=False): """ | Blits images with names on a range from *animation_name*_0 to *animation_name*_x onto the screen | with given *duration*. x is the amount of files in the assets/images/<animation_name>/ directory. | The *reverse*-Flag reverses the animation """ import os, os.path from time import sleep end = len([ name for name in os.listdir('./assets/images/' + animation_name + '/') ]) for i in range(0, end): if reverse: i = end - i - 1 libtcod.image_blit_2x( libtcod.image_load("assets/images/" + animation_name + '/' + animation_name + '_' + str(i) + '.png'), gvar.window, 0, 0) libtcod.console_blit(gvar.window, 0, 0, gvar.SCREEN_WIDTH, gvar.SCREEN_HEIGHT, 0, 0, 0, 1.0, 1) libtcod.console_flush() sleep(float(duration) / float(end))