Graphical Window Sprites

version 1 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: Timer-Based Drawing

    Graphical Window Sprites provides an approach to improving perceived performance by using a hack that calls drawing and scaling routines as glulx timer events. Normally, the extension asks glulx to draw images as part of the normal flow of game events. This means that, if an image takes a while to draw, the printing of game text and the appearance of the command prompt will be delayed until drawing is completed. Glulx timer events, however, route around the normal flow. If we move our drawing routines to the timer, they will occur simultaneously with the continued operation of the game. While the drawing routines don't take less time, the player will not experience a delay in the game as a whole, only in the update of the graphics window.

    To switch to timer-based drawing, we need to do two things. We change the current graphics drawing rule so that it redirects to the timer, like so:

        now the current graphics drawing rule is the redirect drawing to timer rule

    This requests a glulx timer event of 1 millisecond. After 1 millisecond, the timer will call a rule known as the current timer-based drawing rule. So, we simply need to assign our actual drawing rule to the timer-based rule, like this:

        now the current timer-based drawing rule is the sprite-background scaled-centered display rule

    Now, all drawing and scaling will proceed as glulx timed events rather than as part of the normal flow of things. Note that this method is not recommended if you are using glulx timer events for other purposes in your story. (And it's really probably not a good idea to use timer-based drawing at all...)