In this project we make a game where you captain a ship and battle against submarines! This is part one of two parts of this project.
We've created a starter project that has some custom backdrops and sprites already setup. Open this starter project by clicking on the following link:
There are 3 backdrops included with this project, a 'title' backdrop to appear at the start of the game, a 'sea' backdrop to appear while you play the game and a 'game over' backdrop to appear when the game is finished.
Add the following code to the backdrop:
Messages are a great way to start a piece of code at a particular time. To create a new message follow these steps:
When the instructions screen is showing, we also want to display a Start button that will start the game when the user clicks on it.
Add the following code to the 'Button2' sprite:
Now we will setup the 'battleship' sprite for the start of the game and code it to move when you press the left and right arrows. Add the following code to the 'battleship' sprite:
Since your tablet or iPad doesn’t have a physical keyboard, you’ll use on-screen buttons to complete this task. Wherever the instructions in this lesson mention pressing a key, you’ll need to tap a button on the screen instead. So, while your steps are a little different, you’ll still be able to make everything happen in your project.
So for example, instead of doing either of these:
You need to add an on-screen button (like an arrow sprite) and use this code:
Now, just tap the button on the screen to perform the same action!
We're going to program the 'x' key to fire our torpedo when it is pressed. When fired, the torpedo will continually move down until it touches a submarine or the edge of the screen.
Add the following code to the 'my torpedo' sprite:
Since your tablet or iPad doesn’t have a physical keyboard, you’ll use on-screen buttons to complete this task. Wherever the instructions in this lesson mention pressing a key, you’ll need to tap a button on the screen instead. So, while your steps are a little different, you’ll still be able to make everything happen in your project.
So for example, instead of doing either of these:
You need to add an on-screen button (like an arrow sprite) and use this code:
Now, just tap the button on the screen to perform the same action!