Ononmin Flash prototype – step 3

In this 3rd part we’ll manage stage edges and balls collisions. You’re invited to read steps 1 and 2 if you didn’t already.

The main function does not change.

field_mc now decides the color of the balls in the stage (like in the original game, they must change color at every level) and places all balls in a container called balls_cont. This will make our life easier when we’ll remove balls from stage.

mushroom_mc class does not change

bullet_mc now must manage three types of collision: the collision with left and right sides (the bullet rebounds just changing its x speed), the collision with the upper side (the bullet rebounds changing its y speed) and the collision with the bottom side (the bullet is removed and the player can shoot again)

madball_mc now has a frame listener… if the mushroom is firing, then checks the distance between the bullet and the mad ball itself. If they collide, then turn the ball black as in the original game and remove the bullet, so the player can shoot again.

And this is the result:

You know how to play :)

Download the source code.

During next step, we’ll finish the game.

  • Would it be more efficient to loop through all the circles from a centralized location, rather than having so many events for enterframes?

    Seems what the main controller for the game would do.