| |
a-MAZE-ing
|
|
| |
This tutorial develops a basic maze game with collision detection. Collision detection is useful in many different game type scenarios and is easier than you might think. The Collision Detection ensures that the Ball (or Player) does not cross the lines of the Maze. |
|
| |
|
|
| |
Setting Up the Movie |
|
| |
- Open a new: Flash Movie
- Go to: Modify > Document
- Set the Movie to: 550 x 400
- If you wish set a: Background Colour
- Click: OK
- In the Timeline right click (Mac: Ctrl click) Frame 3 and select: Insert Frame
- In the Timeline use the Insert Layer button
to add 5 Layers so you have a total of: 6 Layers
- Name the Layers as follows:
|
 |
|
|
| |
Creating the First Frame |
|
| |
- Select Frame 1 of the: Text & Button Layer
- Create a button with a Label: Click to Play
- Attach the following ActionScript to the Button:
|
|
| |
| |
on(release){
gotoAndStop(2);
} |
|
|
|
| |
- Right click on Frame 2 of the Text & Button Layer and select: Insert Blank Keyframe so the Button to be visible on the next frame :
- Select Frame 1 of the: Background Layer
- Place any other graphics on this frame that you may want. If you wish to to do this come back and do this latter when you have finished creating the Maze: Create a Background
- Right click on Frame 2 of the Background Layer and select: Insert Blank Keyframe so the Background will not be visible on the next frame.
- Select Frame 1 of the: ActionScript Layer
- Attach the following ActionScript to Frame 1:
|
|
| |
|
|
| |
| The timeline should like similar to |
 |
|
|
| |
Creating the Player |
|
| |
In this tutorial, the Player is the small blue circle:
- Right Click on Frame 2 of the Player Layer and select: Insert Blank Keyframe
- Select the Oval Tool:
- Create a small: Circle
- In the Property Inspector set the size to: 8 x 8 pixels
Note: It must be easily small enough to fit through the Maze.
- Return to the standard Selection tool:
- Select the: Circle (make sure the whole thing is selected)
- Right click the Circle and select: Convert it to Symbol
- For Name type: player
- For Behavior select: Movie Clip
- Click: OK
- If the Property Inspector, give the Movie Clip an Instance Name: player
|
|
| |
Creating the End |
|
| |
When the Player hits the object called the End the Movie will go to the next frame. In theory the End could be invisible. This end looks like this: 
- Right Click on Frame 2 of the End Layer and select: Insert Blank Keyframe
- Select the Rectangle Tool:
- Create a small: Rectangle
- In the Property Inspector set the size to about: 30 x 20 pixels
Note: Don't make it too small or your Player could jump right over it rather than hit the end.
- Select the Text tool and type: END
- Return to the standard Selection tool:
- Select the: Rectangle (make sure the whole thing is selected)
- Right click the rectangle and select: Convert it to Symbol
- For Name type: end
- For Behavior select: Movie Clip
- Click: OK
- If the Property Inspector is closed, open it: Window > Properties (Ctrl F3)
- Give the Movie Clip an Instance Name: end
|
|
| |
Creating the Maze |
|
| |
- Right Click on Frame 2 of the ActionScript Layer and select: Insert Blank Keyframe
- Select one of the Drawing tools such as the Pen Tool:
- Draw your: Maze Walls
Note: If your Maze drawing is going to very complex I suggest you only draw a small section of the Maze to start with. You can come back and add to the drawing latter. If the walls are too thin or the path (where your blue dot moves) is too narrow you may find that the Player goes straight through the walls. The thicker the Walls and the wider the Paths the faster you can make your Player move so try not to make the walls too thin.
- My Walls are at least: 6 Pixels Thick
- My Paths are at least: 10 Pixels Wide
- Return back to the standard Selection tool:
- Select the: Drawing (make sure the whole thing is selected)
- Right click the Maze drawing and select: Convert it to Symbol
- For Name type: walls
- For Behavior select: Movie Clip
- Click: OK
- If the Property Inspector is closed, open it: Window > Properties (Ctrl F3)
- Give the Movie Clip an Instance Name: walls
- Right Click on the Movie Clip again and select: Convert it to Symbol
- For Name type: maze
- For Behavior select: Movie Clip
- Click: OK
Note: This creates a series of nested Movie Clips one inside another. The Walls Movie Clip is inside the Maze Movie Clip. The Maze Movie Clip is on the Main Stage:
- Attach the following ActionScript to the outside of the Maze Movie Clip:
|
|
| |
| |
onClipEvent (enterFrame) { with (_root.player) {
mySpeed = 3;
myBounce = 3;
if
(Key.isDown(Key.DOWN)) { _y
+= mySpeed; } if
(Key.isDown(Key.UP)) { _y
-= mySpeed; } if
(Key.isDown(Key.LEFT)) { _x
-= mySpeed; } if
(Key.isDown(Key.RIGHT)) { _x
+= mySpeed; }
if
(walls.hitTest(getBounds(_root).xMax, _y,
true)) { _x
-= myBounce; } if
(walls.hitTest(getBounds(_root).xMin, _y,
true)) { _x
+= myBounce; } if
(walls.hitTest(_x, getBounds(_root).yMax, true)) { _y
-= myBounce; } if
(walls.hitTest(_x, getBounds(_root).yMin, true)) { _y
+= myBounce; }
if
(_root.end.hitTest(_x, getBounds(_root).yMax, true)) { _root.gotoAndStop(3); } } }
|
|
|
|
| |
Creating Frame 3 |
|
| |
- Right Click on Frame 3 of the Text & Buttons Layer and select: Insert Blank Keyframe
- Type something like: You Won !!
- Create a button to return and play again: Replay Button
- Add the following ActionScript to this Button:
|
|
| |
| |
on (release){
gotoAndStop(2);
} |
|
|
|
| |
|
|
| |
Other Mazes |
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|