Thursday, October 25, 2018

GameScript vs. Hud

The HUD is a bit special in libgeds in that the engine doesn't know what it is, nor what it does. All it knows is how to pass it informations, more in the LUA spirit (afaik).

so when you type

  • hud.load "somefile.spr"
noone ever checks that there is a file. All it does it passing that string untouched (*) to some iHud::showScreen() function. 'hud.show' works similarly, and simply change one boolean argument so that the iHud-derived class knows it should make the picture visible immediately.

The other kind of command,
  • hud.mode=menu
 Will just be recording the first letter ('m') and make that available when the parsing is over through a call to iHud::setup(). The engine doesn't even know how to build such a iHud-derived object: instead it receives it from the rest of the program.

 So the HUD is something that the advanced programmer sets up and that can interprete freely that string that is meant to be a filename. In other words, rather than hacking "let's show the score" when the 'show now' bit was passed, we could have a more explicit
  • hud.show "chapter2.spr" // only while loading
  • hud.show "+score"
  • // all the level setup goes here
  • hud.show "-score"
  • hud.load "hud-basic.spr" // what goes on the bottom screen during one level.
 (*) Well, not exactly untouched. It actually prepends some stuff to make it an absolute path. Like "efs:/" or so. I'll have to work that out.

No comments: