The aim of this session was to turn our rectangle into a spaceship, add a scrolling starfield, add a asteroid which 'falls' down the screen and keep a score of all the asteroids avoided. The aim of the game we are developing is to avoid the falling asteroids - one point should be awarded for every asteroid avoided.
We started with the spaceship. Lee opened his rectangle symbol and added three triangles to it - one for the nose cone and the other two for fins or wings. He then opened his asteroid symbol and added some more circle shapes to it to make a more realistic looking and irregular asteroid. Some extra actionscript code was added to the asteroid movie clip to make it repeatedly 'fall' down the screen. Here's a screenshot of the rocket:
Lee then tested his game to see if it worked - the spaceship moved left, right, up and down and the asteroids fell down the screen. If one hit the spaceship, the 'You have crashed!' screen appeared and the game ended. Everything as it should be so far.
To add the scrolling starfield, Lee created a new movie clip by drawing a black backgound and painting some white blobs all over it for stars. Then he copied it to make the starfield twice the size. Some actionscript code was added to the movie clip to make it move down the screen five pixels at a time. When the background reaches the bottom of the screen, it jumps back to the top again and repeats the movement. This is done so quickly and smoothly that it gives the appearance that the starfield is continuously scrolling.
A new layer was added to the timeline and named 'backgound'. The starfield movie clip was added to this layer and the layer was dragged to the bottom of the layer stack so that it appeared behind everything else. When this layer was tested it didn't work first time, and it took several goes to debug the code and make it work - but when it was working it looked great!
We then added a new layer with a dynamic text box to display the score - one point for each asteroid which reaches the bottom of the screen without hitting the spaceship (in other words, the spaceship has been moved out of the way by the player, thus avoiding contact with the asteroid). A variable called 'score' was used to hold the score value, and some actionscript was added to increase the variable value by one every time an asteroid reached the bottom of the screen. The value of the score variable was displayed in the dynamic text box in the top right hand corner of the screen.
Lee then experimented for a while with changing the speed of the falling asteroids to make the game more challenging, and at times, impossible! This was done by making the asteroid move more pixels at at time. He settled on an _y value of 15 pixels which was challenging but achievable.
The last part of this evening's session was spent experimenting on how to add more falling asteroids to make the game more interesting. We want to have several asteroids of different sizes randomly spread out over the screen and falling at different speeds. One idea of copying the existing asteroid movie clip and it's code was tried, but this resulted in them all falling at the same speed and so it did not look very good. This obviously needs more thought and work! Here's a screenshot of the final version created tonight:
Phew! - we really got though a lot tonight, and much progress and understanding took place. Let's see what Lee comes up with for next week's meeting.
Mr. J.
No comments:
Post a Comment