On 14 Apr 2008, at 09:17, Phillip Gawlowski wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Zoe Phoenix wrote:
> | I'm playing around with making a small test game with what little  
> Ruby
> | code I've learned so far and I feel like I'm doing good for only  
> having
> | been learning the past couple of weeks or so.  I've mostly been  
> figuring
> | things out as I go, but I need a little help.
> |
> | Say I wanted a character to be afflicted with a "poison" status that
> | removes 5% of their current HP. I know it should be a method that  
> occurs
> | every few seconds (or just every turn) and that it should loop until
> | something is used to cure it or the battle ends, but I'm not sure  
> how to
> | do this. I'd like to make it repeat every, say, 15 seconds or so,  
> but I
> | guess it doesn't really matter how often, since this is just for
> | practice. The following code is incomplete (and possibly  
> incorrect), but
> | please advise:
>
> On every update (tick in your game, be it screen redrawing, or turn,
> whatever), you should have a method updating the game state. In that
> method, you can execute the relevant updating code.
>
> Quick and dirty example:
>
> while game do
> ~  update_enemies
> ~  update_environment
> ~  update_effects
> ~  update_playerstate # You'd check for poison in this method
> ~  draw_screen
> ~  get_input
> end

Can I make a very very strong suggestion that the design de-couples  
game-world logic from both rendering and all other I/O forms. The  
logic bound operations in domain time cannot be regulated with regard  
to the dynamic complexity of a modern logic set (running in 'real  
time' aka. as fast as you can complete that loop), and even more so in  
a very high level language like ruby.

Don't take my word for it either: gaffer.org.

Failure to do so often leaves one with a game that requires very  
specific relative timings on inputs if rapid tapping style input is  
required, and under optic-flow systems causes a coupling between  
twitch flow specifics that turns out to not only feel horrible, but  
also causes damage to the player (eye strain, and rsi from input usage  
styles). Specific frequencies obviously vary from engine to engine,  
however, there have been real failures caused directly by this paradigm.

> If it shouldn't happen always, you could check for a counter (the  
> modulo
> operate could come in handy here ;).
>
> - --
> Phillip Gawlowski
> Twitter: twitter.com/cynicalryan
>
> ~ - You know you've been hacking too long when...
> ...your SO asks you where you want to eat on a friday night and you  
> want to:
> cat yellowpages | grep pizza | grep carryout | more
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkgDEwMACgkQbtAgaoJTgL/toQCbBoLWIgw6Mg6Ykr6Qt7526x28
> 12cAnRMuzf+ygMyaRz5W12TGmMDgv4xy
> =jD1Z
> -----END PGP SIGNATURE-----
>