Showing posts with label hud. Show all posts
Showing posts with label hud. Show all posts

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.

Monday, October 22, 2018

Showing the score

If I want to have a "leader board" shown in the game won / game over screens, it would be nice too if the player can have a look at her performance. My idea is that you're evaluated either on the distance you covered (when game over) or on the time you took to beat the game (when congratulated). A good time to report that to the player is when we're loading the level, but by then the screen settings are fairly locked.

It looks however, that if I hack the 'window control register' WIN_OUT while we're updating the picture shown on the bottom screen, I could use sprites on the top screen to render some digits without messing up with the scene setup. That's only part of the solution (I'll also need some tiles with digits, which I haven't in the sprites tileset atm), but it's better than nothing.

And it looks like I should be able to use the last 16 tiles of the spriteset to put some 8x8 digits font... We'll see that some tomorrow.