2023-04-06

Last modified: Apr 12, 2023
Word count: 386

harvey actions api refactor: a stunning success

+186 lines, -451 lines

+186 lines, -451 lines

Harvey Actions API refactor netted ~300 fewer lines

captured: 2023-04-06 11:09

Pretty stoked about that one!

til github supports /compare/commit..main urls

i.e. from any commit view, change commit to compare and add ...main to the

url. (or some other commit hash instead of main )

dino refactors epic 2

> DONE harvey using actions api

> DONE mvania game breakdown

Couple things to decomplect in this refactor

'Game' global object fills several rows (across all my games)

we want a Player focused autoload/namespace. or something like 'Game' filling the same purpose

breaking down mvaniaArea, mvaniaRoom, mvaniaGame

feels like they could serve dungeon crawlers and beat em ups. maybe runners? Likely platformers.

this abstraction supports maps as well - room has funcs for calcing rectangles

from tilemaps and what not

>> Game/Player abstraction

  • maybe_spawn_player() - deferred ensure player call
  • is_managed_game()
  • respawn_player() - after death
  • .player - reference to the player, often useful
  • mvania bosses _physics_process() uses this for targetting
  • mvania bosses swoop impl uses this for player position
  • mvania shooty-crawly _physics_process() uses this to guard constant los checks

assigning all powers if not managed game

respawning player after death

>> 'MvaniaGame' Area-support abstraction

  • register_areas()
  • used in editor-mode
  • used in hotel UI rebuild button
  • .current_area
  • travel_to(area_name, elevator_path)
  • essentially the game load-next-area func

kind of a register and ensure-current-area feel

minimap uses this for current area highlight

>>> 'Areas'

  • attempt to spawn a player (in 'dev' mode, i.e. 'unmanaged' games)

>>> 'Rooms'

  • update_rooms() in mvGame pauses 'inactive' rooms
  • impl could vary, for now is if 'player' in .used_rect()
  • have camera activation/deactivation helpers

duck typing on room children:

  • "on_room_entered"

rooms:

  • auto-add camera poas
  • add a roombox to react to player enter/exit events
  • pause/unpause and fade in/out

>> 'HatBot' specific rules and details

  • Powerup enum (sword/climb/doublejump)
  • mvania HUD uses all_powerups, powerup enum
  • menu uses MvaniaGame.restart_game

>> restore areas registering siblings for elevator assignment

>> restore hotel ui rebuild

use whatever scene_file_paths were already in there

might need some other hack for it to discover more scenes

>> restore running/playing areas/rooms in isolation

'unmanaged' games