Beispiel #1
0
def main():

    con, panel, mouse, key = Initializer.init_game()

    newgame = Menu.main_menu(con, key, mouse)

    if not newgame:
        sys.exit(0)

    race, prof = Menu.starting_menu(con, key, mouse)

    world = World(race, prof)

    # world.debug = True

    mapmaker = MapMaker()

    mapmaker.new_dungeon(world)

    world.fov_map = Initializer.init_fov_map(world.tilemap)

    DeathFunctions.world = world

    while not libtcod.console_is_window_closed():

        RenderFunctions.render_all(con, panel, world)
        libtcod.console_flush()

        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        action = Controls.handle_keys(key, world)

        world.update(action)
Beispiel #2
0
 def update(screen):
     """update"""
     World.update(screen)
     Items.update(screen)
     screen.blit(Game.player.sprite, Game.player.get_position())
     font = pygame.font.SysFont("comicsansms", 12)
     screen.blit(
         font.render(
             "{} Items sur {} .".format(Game.player.inventory, Items.count),
             True, (0, 0, 0)), (200, 1))
     if Items.pick_item_at(Game.player.get_position_case()):
         Game.player.pick_up_item()
     if World.get_sprite_at(Game.player.get_position_case()[0],
                            Game.player.get_position_case()[1]) == "G":
         if Items.count == Game.player.inventory:
             sm.SceneManager.load_scene(2)
             Over.set_text("Vous avez gagnez")
         else:
             sm.SceneManager.load_scene(2)
             Over.set_text("GameOver vous n'avez pas récupéré les Items")
Beispiel #3
0
            if isinstance(entity, Entity):
                DISP_SURF.blit(pygame.transform.scale(images[type(entity)], (TILESIZE, TILESIZE)), (entity.x * TILESIZE, entity.y * TILESIZE))

# world loop
hold = False
while True:
    # get all the user events
    for event in pygame.event.get():
        # if the user wants to quit (ESC)
        if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
            pygame.quit()
            sys.exit()
        if event.type == KEYDOWN and event.key == K_SPACE:
            hold = not hold
            if hold:
                print('GAME ON HOLD')
            else:
                print('CONTINUE')
    # draw grid
    DISP_SURF.fill(BLACK)
    for row in range(world.height):
        for column in range(world.width):
            # add a white square (drawing surface, colour, coordinates, border thickness)
            pygame.draw.rect(DISP_SURF, WHITE, (column*TILESIZE, row*TILESIZE, TILESIZE, TILESIZE), 1)
    # update the display
    fpsClock.tick(FPS)
    if not hold:
        world.update()
    render()
    pygame.display.update()