-----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

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-----