diff --git a/src/game.cpp b/src/game.cpp index 4efaf7f..a3017ca 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -364,7 +364,8 @@ void Game::create_levels(void) auto v = levels_create(g); game_levels_set(g, v); - game_level_set(g, v, 0, 0); + auto l = game_level_set(g, v, 0, 0); + level_scroll_warp_to_player(g, v, l); } void game_create_levels(Gamep g) { g->create_levels(); } diff --git a/src/gfx_12x12.cpp b/src/gfx_12x12.cpp index eba0e50..08cd7e3 100644 --- a/src/gfx_12x12.cpp +++ b/src/gfx_12x12.cpp @@ -24,10 +24,10 @@ void gfx_init_12x12(void) "", "", // ############################################################################## - "player1.idle.0", - "player2.idle.0", - "player3.idle.0", - "player4.idle.0", + "player.idle.0", + "", + "", + "", "", "", "", diff --git a/src/gfx_16x16.cpp b/src/gfx_16x16.cpp index 51e5513..893875f 100644 --- a/src/gfx_16x16.cpp +++ b/src/gfx_16x16.cpp @@ -27,7 +27,7 @@ void gfx_init_16x16(void) "", "", // ############################################################################## - "player1.idle.0", + "player.idle.0", "player2.idle.0", "player3.idle.0", "player4.idle.0", diff --git a/src/level.cpp b/src/level.cpp index 0458f00..96981aa 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -294,14 +294,11 @@ void level_map_set(Gamep g, Levelsp v, Levelp l, const char *in) DIE("bad map size, expected %d, got %d", (int) strlen(in), (int) expected_len); } - auto tp_wall = tp_random(is_wall); - auto tp_door = tp_find_mand("door"); - auto tp_floor = tp_find_mand("floor"); - auto tp_exit = tp_find_mand("exit"); - auto tp_player1 = tp_find_mand("player1"); - auto tp_player2 = tp_find_mand("player2"); - auto tp_player3 = tp_find_mand("player3"); - auto tp_player4 = tp_find_mand("player4"); + auto tp_wall = tp_random(is_wall); + auto tp_door = tp_find_mand("door"); + auto tp_floor = tp_find_mand("floor"); + auto tp_exit = tp_find_mand("exit"); + auto tp_player = tp_find_mand("player"); for (auto y = 0; y < MAP_HEIGHT; y++) { for (auto x = 0; x < MAP_WIDTH; x++) { @@ -323,21 +320,9 @@ void level_map_set(Gamep g, Levelsp v, Levelp l, const char *in) break; case CHARMAP_TREASURE : break; case CHARMAP_MONST1 : break; - case CHARMAP_PLAYER1 : + case CHARMAP_PLAYER : need_floor = true; - tp = tp_player1; - break; - case CHARMAP_PLAYER2 : - need_floor = true; - tp = tp_player2; - break; - case CHARMAP_PLAYER3 : - need_floor = true; - tp = tp_player3; - break; - case CHARMAP_PLAYER4 : - need_floor = true; - tp = tp_player4; + tp = tp_player; break; case CHARMAP_EXIT : need_floor = true; diff --git a/src/level_display.cpp b/src/level_display.cpp index 8057f00..93a0be8 100644 --- a/src/level_display.cpp +++ b/src/level_display.cpp @@ -217,16 +217,11 @@ void level_display(Gamep g, Levelsp v, Levelp l) // game_visible_map_mouse_get(g, &visible_map_mouse_x, &visible_map_mouse_y); - fprintf(stderr, "ZZZ NEIL %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); for (auto y = v->miny; y < v->maxy; y++) { - fprintf(stderr, "ZZZ NEIL %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); FOR_ALL_Z_PRIO(z_prio) { - fprintf(stderr, "ZZZ NEIL %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); for (auto x = v->minx; x < v->maxx; x++) { - fprintf(stderr, "ZZZ NEIL %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); for (auto slot = 0; slot < MAP_SLOTS; slot++) { - fprintf(stderr, "ZZZ NEIL %s %s %d\n", __FILE__, __FUNCTION__, __LINE__); level_display_slot(g, v, l, point(x, y), slot, z_prio); } } diff --git a/src/level_dungeon.cpp b/src/level_dungeon.cpp index a81fc3f..6b9a7da 100644 --- a/src/level_dungeon.cpp +++ b/src/level_dungeon.cpp @@ -9,7 +9,7 @@ void level_dungeon_create_and_place(Gamep g, Levelsp v, Levelp l) level_map_set(g, v, l, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "x..............................x" - "x..CC..1.....x.................x" + "x..CC..@.....x.................x" "x..CC.......x..................x" "x..........x...................x" "x..x...........................x" diff --git a/src/my_charmap.hpp b/src/my_charmap.hpp index 731f4ff..0c0c495 100644 --- a/src/my_charmap.hpp +++ b/src/my_charmap.hpp @@ -14,10 +14,7 @@ enum { CHARMAP_EXIT = 'E', CHARMAP_KEY = 'k', CHARMAP_MONST1 = 'm', - CHARMAP_PLAYER1 = '1', - CHARMAP_PLAYER2 = '2', - CHARMAP_PLAYER3 = '3', - CHARMAP_PLAYER4 = '4', + CHARMAP_PLAYER = '@', CHARMAP_TREASURE = '$', CHARMAP_WALL = 'x', // end sort marker1 } diff --git a/src/thing_move.cpp b/src/thing_move.cpp index 57d2322..886ff54 100644 --- a/src/thing_move.cpp +++ b/src/thing_move.cpp @@ -357,8 +357,9 @@ void thing_push(Gamep g, Levelsp v, Levelp l, Thingp t) // // Save where we were pushed so we can pop the same location // - t->is_on_map = true; - t->last_pushed_at = p; + t->is_on_map = true; + t->last_pushed_at = p; + l->thing_id[ p.x ][ p.y ][ slot ] = t->id; // // Sort the map slots by z prio for display order. diff --git a/src/things/player/tp_player.cpp b/src/things/player/tp_player.cpp index 4aecdae..67e3fba 100644 --- a/src/things/player/tp_player.cpp +++ b/src/things/player/tp_player.cpp @@ -9,26 +9,24 @@ bool tp_load_player(void) { - for (auto player = 1; player <= 4; player++) { - auto name = "player" + std::to_string(player); - auto tp = tp_load(name.c_str()); + auto name = "player"; + auto tp = tp_load(name); - // begin sort marker1 { - tp_flag_set(tp, is_animated_can_hflip, true); - tp_flag_set(tp, is_blit_on_ground, true); - tp_flag_set(tp, is_player, true); - tp_flag_set(tp, is_tickable, true); - tp_speed_set(tp, 100); - tp_z_prio_set(tp, MAP_Z_PRIO_INFRONT); - // end sort marker1 } + // begin sort marker1 { + tp_flag_set(tp, is_animated_can_hflip, true); + tp_flag_set(tp, is_blit_on_ground, true); + tp_flag_set(tp, is_player, true); + tp_flag_set(tp, is_tickable, true); + tp_speed_set(tp, 100); + tp_z_prio_set(tp, MAP_Z_PRIO_INFRONT); + // end sort marker1 } - auto delay = 100; + auto delay = 100; - for (auto frame = 0; frame < 1; frame++) { - auto tile = tile_find_mand(name + ".idle." + std::to_string(frame)); - tile_delay_ms_set(tile, delay); - tp_tiles_push_back(tp, tile); - } + for (auto frame = 0; frame < 1; frame++) { + auto tile = tile_find_mand(name + std::string(".idle.") + std::to_string(frame)); + tile_delay_ms_set(tile, delay); + tp_tiles_push_back(tp, tile); } return true; diff --git a/src/tp.cpp b/src/tp.cpp index 888a914..2121195 100644 --- a/src/tp.cpp +++ b/src/tp.cpp @@ -26,10 +26,7 @@ std::initializer_list< std::string > tps = { // clang-format off "", // ID 0 means unused "wall1", - "player1", - "player2", - "player3", - "player4", + "player", /* begin shell marker1 */ /* shell for i in $(find . -name "*.cpp" | xargs grep -h "tp_load(\"" | awk '{print $4}' | cut -d\" -f2) */ /* shell do */ diff --git a/src/wid_leftbar.cpp b/src/wid_leftbar.cpp index 49b080f..5a7d215 100644 --- a/src/wid_leftbar.cpp +++ b/src/wid_leftbar.cpp @@ -74,7 +74,7 @@ static bool wid_leftbar_create_window(Gamep g) y_at = 8; { TRACE_AND_INDENT(); - auto w = wid_new_square_button(wid_leftbar, "player1"); + auto w = wid_new_square_button(wid_leftbar, "player"); point tl(0, y_at); point br(width - 1, y_at); auto s = dynprintf("%04u %04u", 0, 100); diff --git a/src/wid_rightbar.cpp b/src/wid_rightbar.cpp index 6ab2950..49e0a50 100644 --- a/src/wid_rightbar.cpp +++ b/src/wid_rightbar.cpp @@ -74,7 +74,7 @@ static bool wid_rightbar_create_window(Gamep g) y_at = 8; { TRACE_AND_INDENT(); - auto w = wid_new_square_button(wid_rightbar, "player1"); + auto w = wid_new_square_button(wid_rightbar, "player"); point tl(0, y_at); point br(width - 1, y_at); auto s = dynprintf("%04u %04u", 0, 100);