Flash Game - Part 2

Ok, this is the next installment in the first person shooter tutorial. In the last one, you should have made a hand holding a gun, with the cross hair (or sights) moving around with the mouse. Not much fun shooting at a blank screen is it? Anyway now we will be working towards preparing the game for some enemies to shoot.

We will prepare the background and hiding places for the enemies in this tutorial.

To begin, open up the previous fla and add these layers to the movie (keep the order):

Now we could just put everything in one layer, but using different layers for different object keeps things neater and makes troubleshooting and editing easier. Besides, the amount of layers you have does not affect the final size of the movie.


The layers "garbage cans" and "wall" are coverings I've used, that the enemies hide behind. You can use your own.

In the wall layer, click on the first frame and draw a wall or a fence, again, it's up to you:

In the ground layer, click in the first frame and draw some ground, or grass. I used a gravel tile image and just duplicated it, then grouped the duplicates together. Tip: if you select an image, press CTRL+K (this brings up the Align panel) then click on:

1: Align centre stage horizontally then
2: Match stage width

This aligns the image to the centre, then makes it the same width as the stage so you don't have to worry about matching the size. The only thing you need to adjust is the height of the image. Be careful though, as if it's a small image, it may become distorted. You should end up with something like this:

In the garbage cans layer, click in the first frame and draw two garbage cans - or whatever covering you've chosen. Place into position. Once they're in position, click on one of them and press F-8 - Convert to Symbol and select Button. Give it the name "garbageCan1":

Do the same for the other one, but give it the name "garbageCan2".

These buttons won't be used in the movie as buttons, it's to stop anything, namely the enemies being shot while they are hiding behind the cans. If you click on the garbage can, around the same area that the enemy is hiding, he would still react as if he has been shot, even though you haven't actually clicked on him, and even though he is not visible. Now we could just simply use, when the character is hidden, a variable like isUp = false to tell us he is not up and can't be shot, or:

this.enabled = false;

which would prevent him from being shot before we want him to be, and when he is fully up and out of the hiding place use:

this.enabled = true;

which would enable him to be shot, but it's more realistic if he can be shot even if a bit of him is visible, whether he is fully up or not. By placing an inactive button in front of him, it forms a layer or barrier, that if clicked on the area the enemy is hiding, the shot won't register with the enemy. The shot will register only if you actually click on the enemy. If this sounds confusing, hopefully you'll understand as you put it into practice.

Now you should have the wall, the ground and the garbage cans all done. I used pre-made graphics for the wall, ground and garbage cans, just to make things easier writing the tutorial. You may want to spend some time, drawing a background you're happy with.

In the next part, we hope to add some enemies into the picture so you should have something to shoot at.