phantasia

Phantasia - 2D SDL3 RPG prototype.
git clone git://git.beep.wimdupont.com/phantasia.git
Log | Files | Refs | README | LICENSE

commit ae151fed5672c21a4e3f470304b661c8b6f30012
parent 3b6199d981cd247037f571ad1740c3c73e4e73d8
Author: beep <beep@wimdupont.com>
Date:   Thu, 30 Jul 2026 09:55:11 +0000

Align shop bounds and add Vim movement

Diffstat:
Mconfig.def.h | 6+++++-
Mphantasia.6 | 6+++---
Msrc/engine/world.h | 2+-
Msrc/game/content.c | 16++++++++--------
Msrc/game/main.c | 12++++++++----
Msrc/tests/smoke.c | 5+++++
6 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,7 +1,7 @@ #ifndef CONFIG_H #define CONFIG_H -#define PH_CONFIG_VERSION 9 +#define PH_CONFIG_VERSION 10 #define PH_VIEW_W 320 #define PH_VIEW_H 240 @@ -50,12 +50,16 @@ #if PH_USE_SDL #define PH_KEY_LEFT_1 SDL_SCANCODE_LEFT #define PH_KEY_LEFT_2 SDL_SCANCODE_A +#define PH_KEY_LEFT_3 SDL_SCANCODE_H #define PH_KEY_RIGHT_1 SDL_SCANCODE_RIGHT #define PH_KEY_RIGHT_2 SDL_SCANCODE_D +#define PH_KEY_RIGHT_3 SDL_SCANCODE_L #define PH_KEY_UP_1 SDL_SCANCODE_UP #define PH_KEY_UP_2 SDL_SCANCODE_W +#define PH_KEY_UP_3 SDL_SCANCODE_K #define PH_KEY_DOWN_1 SDL_SCANCODE_DOWN #define PH_KEY_DOWN_2 SDL_SCANCODE_S +#define PH_KEY_DOWN_3 SDL_SCANCODE_J #define PH_KEY_INTERACT_1 SDL_SCANCODE_E #define PH_KEY_INTERACT_2 SDL_SCANCODE_SPACE #define PH_KEY_CHARACTER SDL_SCANCODE_C diff --git a/phantasia.6 b/phantasia.6 @@ -1,4 +1,4 @@ -.Dd July 29, 2026 +.Dd July 30, 2026 .Dt PHANTASIA 6 .Os .Sh NAME @@ -13,8 +13,8 @@ is a small top-down RPG prototype with connected map areas, item pickup, shops, visible in-world encounters, independently roaming and pursuing monsters, and turn-based battles. .Sh KEYBINDINGS -.Bl -tag -width "Arrow keys / WASD" -.It Arrow keys / WASD +.Bl -tag -width "Arrow keys / WASD / HJKL" +.It Arrow keys / WASD / HJKL Move the player. .It Space / E Interact, pick up nearby loot, or speak to a facing shopkeeper. diff --git a/src/engine/world.h b/src/engine/world.h @@ -3,7 +3,7 @@ #include <stddef.h> -#define PH_CONFIG_API_VERSION 9 +#define PH_CONFIG_API_VERSION 10 enum { PH_MAP_MAGIC = 0x50484d50, diff --git a/src/game/content.c b/src/game/content.c @@ -70,15 +70,15 @@ const PhTileDef ph_tile_defs[PH_TILE_DEF_COUNT] = { .sprite_tile_x = 0, .sprite_tile_y = 16, .background_asset_id = PH_ASSET_TILESET, .background_sprite_tile_x = 1, .background_sprite_tile_y = 1 }, - { '[', 1, PH_ASSET_TILESET, 9, 1, 0, 0, 0, 0, 0 }, - { '^', 1, PH_ASSET_TILESET, 10, 1, 0, 0, 0, 0, 0 }, - { ']', 1, PH_ASSET_TILESET, 11, 1, 0, 0, 0, 0, 0 }, - { '{', 1, PH_ASSET_TILESET, 9, 2, 0, 0, 0, 0, 0 }, + { '[', 0, PH_ASSET_TILESET, 9, 1, 0, 0, 0, 0, 0 }, + { '^', 0, PH_ASSET_TILESET, 10, 1, 0, 0, 0, 0, 0 }, + { ']', 0, PH_ASSET_TILESET, 11, 1, 0, 0, 0, 0, 0 }, + { '{', 0, PH_ASSET_TILESET, 9, 2, 0, 0, 0, 0, 0 }, { '=', 0, PH_ASSET_TILESET, 10, 2, 0, 0, 0, 0, 0 }, - { '}', 1, PH_ASSET_TILESET, 11, 2, 0, 0, 0, 0, 0 }, - { '(', 1, PH_ASSET_TILESET, 9, 3, 0, 0, 0, 0, 0 }, - { '_', 1, PH_ASSET_TILESET, 10, 3, 0, 0, 0, 0, 0 }, - { ')', 1, PH_ASSET_TILESET, 11, 3, 0, 0, 0, 0, 0 }, + { '}', 0, PH_ASSET_TILESET, 11, 2, 0, 0, 0, 0, 0 }, + { '(', 0, PH_ASSET_TILESET, 9, 3, 0, 0, 0, 0, 0 }, + { '_', 0, PH_ASSET_TILESET, 10, 3, 0, 0, 0, 0, 0 }, + { ')', 0, PH_ASSET_TILESET, 11, 3, 0, 0, 0, 0, 0 }, { '+', 0, PH_ASSET_TILESET, 5, 15, 0, 0, 0, 0, 0 }, }; diff --git a/src/game/main.c b/src/game/main.c @@ -49,10 +49,14 @@ ph_read_input(const bool *keys) { PhInput input = { 0 }; - if (keys[PH_KEY_LEFT_1] || keys[PH_KEY_LEFT_2]) input.move_x -= 1; - if (keys[PH_KEY_RIGHT_1] || keys[PH_KEY_RIGHT_2]) input.move_x += 1; - if (keys[PH_KEY_UP_1] || keys[PH_KEY_UP_2]) input.move_y -= 1; - if (keys[PH_KEY_DOWN_1] || keys[PH_KEY_DOWN_2]) input.move_y += 1; + if (keys[PH_KEY_LEFT_1] || keys[PH_KEY_LEFT_2] || keys[PH_KEY_LEFT_3]) + input.move_x -= 1; + if (keys[PH_KEY_RIGHT_1] || keys[PH_KEY_RIGHT_2] || keys[PH_KEY_RIGHT_3]) + input.move_x += 1; + if (keys[PH_KEY_UP_1] || keys[PH_KEY_UP_2] || keys[PH_KEY_UP_3]) + input.move_y -= 1; + if (keys[PH_KEY_DOWN_1] || keys[PH_KEY_DOWN_2] || keys[PH_KEY_DOWN_3]) + input.move_y += 1; if (keys[PH_KEY_INTERACT_1] || keys[PH_KEY_INTERACT_2]) input.interact = 1; return input; } diff --git a/src/tests/smoke.c b/src/tests/smoke.c @@ -354,6 +354,11 @@ ph_area_shop_test(void) if (ph_enter_portal(&world, PH_AREA_MIRA_SHOP) != 1 || world.area_id != PH_AREA_MIRA_SHOP || world.initialized_area_count != 3) goto fail; + if (ph_area_tile_blocked(&world.area, 0, 0) || + ph_area_tile_blocked(&world.area, world.area.width - 1, + world.area.height - 1) || + !ph_area_tile_blocked(&world.area, -1, 0) || + !ph_area_tile_blocked(&world.area, world.area.width, 0)) goto fail; for (i = 0; i < world.area.marker_count; ++i) { const PhMarkerDef *def = ph_area_catalog_marker(ph_game_world.areas, world.area_id, world.area.markers[i].symbol);