Introduction to Flash and Actionscript

S7 - Really Cheesy Avoiding Game

 

Create a new Air Application for IOS or Android (Finally!!!!)

 

 

Assignment 1 - Using Single Instances

Find 2 different angry bird images, one with on open beak and one with a closed beak (or any character you like with 2 different positions)

 

 

Step 2 - Use the images to create a movie clip so that it appears as if the mouth of the bird is opening and closing

 

Step 3 - Using addchild to create instances of the AngryBird. 

Just create 2 for now we will modify this later with Arrays. You could also create different birds!

Set the y coordinate off the screen at the top

 

Randomly generate the x coordinate of the AngryBird instead of setting them to a specific number

AngryBird1_mc.x =

// change this at the start and add when the bird spawns at the top

 

 

Step 4 - Move the birds down the screen (The +2 and +3 are the speed of the birds)

Step 5 -  Your turn!!! Have the birds start over at the top when they reach the bottom.

HINT:  In the function birdsFall use an if statement to check

if (AngryBird1_mc.y > than some number)
{

// reset the y coordinate

// generate a new random x coordinate

}

 

 

Step 6 - Randomly generate the speed of the birds.

a. Create 2 variables (randomSpeed1) and (randomSpeed2) at the top of your program

b. Calculate the starting value of each

randomSpeed1= Math.random()* 30 + 5 (30 is max speed, 5 is min speed)

c. Change the fall speed in the function to the random variable


AngryBird1_mc.y += randomSpeed1

d. Recalculate the random speed when you respawn

randomSpeed1= Math.random()* 30 + 5

Step 8  -  Add a Character that will try to avoid the birds. (Use code). Use the Keyboard to Move the Pig. To avoid having to click on the stage every time add the following after your last addchild

stage.focus = stage;

 

 

If your Keycode is glitchy you can modify using the code below. This uses arrays but you do not need to have completed the array tutorial to modify your code. See below.

 

 

 

Step 8- Checking for collisions and end the game. (Note: Don't forget to add stop() to both scenes)

 

Hittest each bird using the OR function (|| found over the ENTER key)

 

 

 

Step 9 - Adding Sound Effects and Background Music

Adding a Sound Effect

 

Adding Background Music

 

Step 10 - Add a scoring system(time elapsed) and lives.

Using a Timer for Time Elapsed

 

 

Step 11 - Show the time elapsed in the Game Over Screen

 

Tutorial 1 - Using Arrays

 

Hittest using Arrays

 

 

Assignment 2 - Using Arrays of Birds

 

Step 1 - Add a second level that uses arrays to create and hittest the birds

 

Using arrays to make multiple birds

 

To make your birds start at different times place the above code on a timer, you may want to use less than 10 each tick.

 

Your Turn

Create EventListeners and functions for the following:

1. Speed

Create a RandomSpeed array to change the speed of each bird.
var RandomSpeed:Array = new Array();
Use a for loop to create the RandomSpeed for each bird
Hint: In a for loop RandomSpeed[i] = formula

2. Falling

Use a for loop to make the birds fall at the RandomSpeed

3. Reset

Use a for loop to reset the birds back to the top when they exit at the bottom.

 

This time use the Mouse to move the Pig

 

You may want to hide the mouse at the start

 

Step 2 - Create a function that uses a for loop to hittest the pig and the bird

Add a Scoring System and Lives

 

Level 3 (ICS3U)

Randomly Generate the Bird that will Appear and the number of birds.

Hint: Generate a random number, then use if statements to determine which bird is created.

 

 

Your Turn

1. An Intro Screen

2. A Menu Screen that allows you to pick your Level

3.Game Over Screen with a Play Again Option

4. University students 1 additional level - It must be completely different than the other levels, use arrays and have some purpose or target other than just avoiding.

College students 2 different levels

5. An Icon for your App

 

Upload files to your website as usual

Load your app onto your device or one of the schools.

Evaluation Sheet