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 play_game():
    global key, mouse

    player_action = None

    mouse = libtcod.Mouse()
    key = libtcod.Key()
    # main loop
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)
        # render the screen
        render_all()

        libtcod.console_flush()

        # level up if needed
        check_level_up()

        # erase all objects at their old locations, before they move
        for object in objects:
            object.clear()

        # handle keys and exit game if needed
        player_action = handle_keys()
        if player_action == 'exit':
            save_game()
            break

        # let monsters take their turn
        if game_state == 'playing' and player_action != 'didnt-take-turn':
            for object in objects:
                if object.ai:
                    object.ai.take_turn()
Beispiel #3
0
def play_game():
	player_action = None
	while not libtcod.console_is_window_closed():
		#draw all the things	
		render_all()
		

		#some other shit, flushing the console?
		libtcod.console_flush()

		#clear off the @ ghosts created by movement
		for stuff in objects:
			stuff.clear()

		#handle keys
		player_action = handle_keys()
		if player_action == 'exit':
			save_game()
			break
	
		#monsters turn
		if game_state == 'playing' and player_action != 'didnt-take-turn':
			for stuff in objects:
				if stuff.ai:
					stuff.ai.take_turn()
Beispiel #4
0
 def eventLoopSetup(self, handleKey, handleMouse, draw):
     while not libtcod.console_is_window_closed() and self._loopActive:
         time.sleep(0.01)
         newKey, newMouse = self.getInput()
         if newMouse.on():
             handleMouse(newMouse)
             draw()
         elif newKey.on():
             handleKey(newKey)
             draw()
Beispiel #5
0
  def main_loop(self):
    while not libtcod.console_is_window_closed():
      self.__render_all()
      libtcod.console_flush()
      self.__clear_all()

      action = self.__handle_keys()
      if action == 'exit':
        break
      elif self.__state == 'playing' and action != 'pass':
        for entity in Entity.entities:
          if entity.ai:
            entity.ai.take_turn()
Beispiel #6
0
def main_menu():
	while not libtcod.console_is_window_closed():
		
		#show game title
		libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'Dick Slayer')


		#show options
		choice = menu('', ['Play a new game', 'Continue last 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
Beispiel #7
0
def play_game():
    player_action = None
    while not libtcod.console_is_window_closed():
        #draw all the things
        render_all()

        #some other shit, flushing the console?
        libtcod.console_flush()

        #clear off the @ ghosts created by movement
        for stuff in objects:
            stuff.clear()

        #handle keys
        player_action = handle_keys()
        if player_action == 'exit':
            save_game()
            break

        #monsters turn
        if game_state == 'playing' and player_action != 'didnt-take-turn':
            for stuff in objects:
                if stuff.ai:
                    stuff.ai.take_turn()
Beispiel #8
0
def main_menu():
    while not libtcod.console_is_window_closed():

        #show game title
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE,
                                     'Dick Slayer')

        #show options
        choice = menu('', ['Play a new game', 'Continue last 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
Beispiel #9
0
init_start()
init_mechanics()
init_ambience()

#libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False)
libtcod.sys_set_fps(LIMIT_FPS)
con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

#a warm welcoming message!
message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)
sound_general_start.play()

while not libtcod.console_is_window_closed():

    #render the screen
    render_graphics()

    #recompute ambient sound voumes
    render_ambience()

    #random ambient sounds
    render_random_ambient_sounds()

    libtcod.console_flush()
 
    #erase all objects at their old locations, before they move
    for object in objects:
        object.clear()
Beispiel #10
0
    libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Amulet of Yelpdor',
                          False)
libtcod.sys_set_fps(LIMIT_FPS)
console = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

district = District()
dungeon_map = generate_city_map(MAP_WIDTH, MAP_HEIGHT, district)
dungeon_map.init_fov_map()
screen = Screen(width=SCREEN_WIDTH, height=SCREEN_HEIGHT)
camera = Camera(CAMERA_WIDTH, CAMERA_HEIGHT, dungeon_map)
renderer = Renderer(console, screen, camera)
messenger = Messenger(width=MESSENGER_WIDTH,
                      height=MESSENGER_HEIGHT,
                      screen=screen)

player = Player(dungeon_map.spawn[0], dungeon_map.spawn[1], '@', libtcod.white)
dungeon_map.objects.append(player)
stats = Stats(48, 3, player)
amulet = Amulet(player, 48, 12, district)
player.amulet = amulet

player.set_level(dungeon_map, district)

while not libtcod.console_is_window_closed():
    renderer.render(player, dungeon_map, amulet, stats)
    messenger.render()
    libtcod.console_flush()
    if handle_keys():
        break