Thursday, January 27, 2011

Making a Flash game like Plants Vs Zombies – Step 4

Making a Flash game like Plants Vs Zombies – Step 4:

Welcome to step four. In this step we’ll make plants fire and eventually kill zombies.

Let’s start defining when a plant can fire:

* When there is at least one zombie on the same row the plant is placed
* When it’s not already firing (plants can fire only one bullet at once)
* When a certain amount of time passed since the last time the plant fired

Now let’s define the bullet life:

* The bullet flies from left to right
* The bullet is removed when it hits a zombie
* The bullet is removed when it flies outside the stage

These six concepts bring some great changes in our script, and I tried to organize it in the clearest way possible, while being conscious that putting all the code in a single class starts making the script a bit messy. Anyway, I tried to do my best to keep it readable.

Before showing you the script, you have to say I created a new object called bulletMc which is the bullet itself.

Ready to see an almost 300 lines long code? [...]

No comments:

Post a Comment