Space Invaders is a classic arcade game in which you need to shoot the alien to gain points.
As the final project, components of Canvas, Image Sprites, Clock, Ball will be practiced.
Step 1: Design the layout
Tips for you to do the layout design:
Canvas is the area where the moles can move.
Two ImageSprites (Enemy, myUFO) are the main characters of the game.
A Ball is to set as the bullet.
Two Labels (Score, Time) shows the score and the time you still have to try the game.
A Button (reset) to reset the game.
Two Clock (behind the scene) to arrange for the enemy to change position periodically and to set the countdown timer.
Two Sound (hit_sound, game_over_sound) to be played.
To find the graphic resources and sound effects you may need, go to the following link to download:
https://drive.google.com/drive/folders/1uJXFxA6f4D_4pWMZ-G75zv9-jDhPK6DT?usp=sharing
Step 2: Identify the procedures of coding the app
Based on the following targets now to design your game:
Target 1: Move my UFO
Tips:
Since my UFO can only be moved at the bottom, should I change the X coordinate or Y coordinate of it?
Target 2: Move the enemy
Tips:
How long does it take for the enemy to move its position? (set the time interval)
Since the enemy can only move in the upper part of the canvas, how to set its X and Y?
Target 3: Program the bullet behaviour
Tips:
Can the character "bullet" be seen when the game starts?
When the player touches "my UFO":
(1) where does the bullet shoot from? (Set its starting position)
(2) the bullet should be seen now
(3) the speed of the bullet?
(4) the heading angle of the bullet? (the bullet should be shoot to the top)
If the bullet doesn't hit the enemy but reaches the edge of the canvas, can it still be seen?
Target 4: When the bullet hits the enemy?
Tips:
Should the bullet disappear when it hits the enemy?
Reward? (variable) (+1 point)
What should the enemy do? (change random position)
Target 5: Program the countdown timer & Game over
In this game, we have set 2 clocks. "Clock1" is to keep checking the time interval for the enemy to change its position (it will change position every 3 seconds). Another clock "countdown_time" is to countdown the time for players to play. Player will be given 1 min to play the game.
Tips:
Use a variable to store the time. What is the initial value of "time" when the game starts?
When the value of time is not equal to 0, how to show a countdown time? (variable, set text to... )
Game over:
(1) Should the timer stop to count? (set TimerEnabled to...)
(2) Stop all the animation of all characters (set enabled to ...)
Target 6: Program the reset button
Tips:
Reset the score value and text?
Reset the countdown timer value and text?
Enable the countdown timer to count?
Enable the animation of all characters?
Step 3: Extra challenge?
Let's brainstorm more challenges to increase the interest of the game!
Suggested ideas:
Set up a big boss UFO, it will show up at random locations every 10 seconds, Hit big boss = 10 points
Points > 20, give extra 5 seconds; Points > 40, give extra 5 seconds
Points > 20, UFO will change position every 2 seconds; Points > 40, UFO will change position every second
You can even create your own challenges!