Help with coding approach

Hi, I’d like a little help arranging the logical layout of the code for a game.

The Concept:
Every time you click a button a plastic army man is spawned. You can spawn as many army men as you like. The user also has control over the intensity of a burning fire and can pick up spawned army men and drop them into the fire and they will eventually melt. The intensity of the fire is user controlled through a slider control. If the fire is "High" intensity then it takes 1 second for the army man to melt, if the fire is "Medium" intensity it takes 2 and if the fire is "low" then it takes 3 seconds. A melted army man becomes a blob of plastic which can be picked up and moved.

How would you keep track of it all?

I’m thinking the logical layout would be

1) Create a table to track spawned army men and also give them a health value

Armyman[i].health = 3

2) Once in the fire create some sort of loop that has a timer which subtracts one value from armyman[i].health until it reaches zero. Have the value of armyman[i].health return to 3 if it is removed from the fire before it reaches 0.

3) If armyman.health = 0, then create a melted blob in its place and delete armyman[i]

Is this the best approach?

@ggortva,

1. Have 4/5 images as you want to display the various stages of melting for the army men.
2. have a state for each spawned armyMan (like you have with .health )
3. Everytime you change the state, change the graphic (easy if you use sprites, you just need to change the frame number)
4. Also have another variable .isInFire which will determine if the armyMan needs to melt or not
5. and another called .fireIntensity
6. Have a function onEnterFrame for each of the ArmyMan, if it isInFire then based on the fireIntensity, decrease the health and change the graphic.

Hope it is easy to understand.

If you were not working on this project, I would have loved to make a tutorial out of the concept you just asked for. It has TUTORIAL written all over it...

cheers,

?:)

views:1567 update:2011/10/15 21:01:16
corona forums © 2003-2011