Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You would need a stronger model to account for the time component of changes:</p> <ol> <li><p>Each sprite needs to maintain a queue of animation actions it is supposed to carry out. Adding animations to the queue should be a zero-time action (game time). Queued animations proceed on a frame-by-frame basis when they get a tick from the animation clock. Queuing lets you separate the model from the graphics subsystem and the animations.</p></li> <li><p>Each animation in the queue carries with it a model action to perform when the animation is complete. Some languages make that easier, e.g. with anonymous functions in C# or JavaScript. In other languages, you could use a callback instead. The model action lets you specify how the model would change when the animation completes.</p></li> <li><p>Sprites can carry high resolution coordinates (e.g. floating point), while the model stays with integer ones. Sprites don't need to know anything about the game rules though -- the queued animation-completion model-actions deal with that.</p></li> <li><p>Model entities should be able to account for a transitional states: appearing, disappearing, and moving. This lets you avoid checking the rules for objects in transition.</p></li> </ol> <p>To implement Snuffle's quest, you could then:</p> <ul> <li><p>User asked to move Snuffle north? -(1) check that the rules allow the move, (2) queue a <em>move animation</em> on Snuffle's sprite, coupled with a <em>landing</em> model action. Put the bunny's model into a transitional moving state.</p></li> <li><p>Snuffle's <em>landing</em> model action brings the bunny's model back to a normal state, and checks the landing spot and the rules. Finding a hat, it queues a potato appearance animation (the "merger") and two disappearance animations for the bunny and hat.</p></li> <li><p>The model actions for the disappearance animations delete the bunny and hat when complete.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload