This is the final activity of the Space Battle Game! We will now program the ghost enemy to move around the Stage unpredictably and detect when it is hit by a bullet or when it reaches the rocketship. Let the battle begin!
Planning the Ghost Behavior
Ghost Behavior
Programming the Ghost Movement
Select the Ghost sprite and build the following script. You will find the blocks in the mentioned palettes:
- When flag clicked: Go to a random position, Show, point in random direction — Events, Motion, Looks
- Forever: Move 3 steps, If on edge bounce — Control, Motion
- Every few seconds: Turn a random number of degrees to change direction unpredictably

Detecting Bullet Hit
- Inside the Forever loop, add an 'If (touching Bullet?) Then' block.
- Inside it: Hide the ghost, wait 1 second, go to a random position, Show.
Detecting Rocketship Collision
- Inside the Forever loop, add an 'If (touching Rocketship?) Then' block.
- Inside it: Change Lives by -1, go to a random position.
- Add an 'If (Lives = 0) Then' block: Say (Game Over!) for 3 seconds, Stop all.

Testing the Complete Game
- Click the green flag to start the Space Battle Game.
- Move the rocketship with the left and right arrow keys.
- Press the spacebar to shoot bullets at the ghost.
- Avoid letting the ghost reach your rocketship — you only have 3 lives!
- Try to score as many points as possible before losing all your lives.

Congratulations! You have built a complete Space Battle Game from scratch using everything you have learned — variables, conditionals, loops, sensing, and more. Save your file as Space Battle Game — Final!

.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)