From 8027b4b2df722b639304c8d3d1272b9da527c02e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 14 Oct 2023 20:33:14 +0200 Subject: [PATCH] added options "game.forced_scroll_x" and "game.forced_scroll_y" This adds the above two "graphicsinfo.conf" options to override the automatically calculated playfield scroll values when starting a game. The purpose of these options is to force an initial scroll position (which is used for all levels), which means that the visible part of the playfield when the game is started is not determined by the player position, but by the values defined using the above options. This may be useful in combination with a large value for the option "game.forced_scroll_delay_value" to limit the visible part of the playfield to a smaller, screen-sized area, while the remaining part of the playfield contains some control elements. It may also be useful for levels using teleportation from one area to another area while still controlling which parts of the playfield entered by the player are visible. It can also be used to force a certain initial visible part of the playfield, regardless of the exact position of the player within that area. And it is currently the only way to force showing levels with an even width or even height with the player near the border of the playfield with half-tile border elements, which would also be needed for teleporting the player to a different part of the playfield without scrolling the playfield relative to the player's screen position. Therefore, this feature should probably be considered experimental. --- src/conf_gfx.c | 2 ++ src/game.c | 5 +++++ src/game.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 0fe69a8d..73eb60db 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -10077,6 +10077,8 @@ struct ConfigInfo image_config[] = { "game.graphics_engine_version", "-1" }, { "game.forced_scroll_delay_value", "-1" }, + { "game.forced_scroll_x", ARG_UNDEFINED }, + { "game.forced_scroll_y", ARG_UNDEFINED }, { "game.use_native_emc_graphics_engine", "false" }, { "game.use_native_sp_graphics_engine", "true" }, { "game.use_masked_pushing", "false" }, diff --git a/src/game.c b/src/game.c index 53410d5a..88fa0a6e 100644 --- a/src/game.c +++ b/src/game.c @@ -4445,6 +4445,11 @@ void InitGame(void) scroll_y = SCROLL_POSITION_Y(local_player->jy); } + if (game.forced_scroll_x != ARG_UNDEFINED_VALUE) + scroll_x = game.forced_scroll_x; + if (game.forced_scroll_y != ARG_UNDEFINED_VALUE) + scroll_y = game.forced_scroll_y; + // !!! FIX THIS (START) !!! if (level.game_engine_type == GAME_ENGINE_TYPE_EM) { diff --git a/src/game.h b/src/game.h index 7eb19cde..dee1bdb1 100644 --- a/src/game.h +++ b/src/game.h @@ -163,6 +163,8 @@ struct GameInfo boolean use_masked_pushing; boolean use_masked_elements; boolean use_masked_elements_initial; + int forced_scroll_x; + int forced_scroll_y; int forced_scroll_delay_value; int scroll_delay_value; int tile_size; -- 2.34.1