35

Space Ship Game

  • Upload
    abba

  • View
    59

  • Download
    1

Embed Size (px)

DESCRIPTION

Space Ship Game. Introduction. We will be creating a spaceship that simulates real movements in space. The spaceship will fire a laser beam that can destroy targets. The spaceship will be able to pass through the edges of the screen Controls: Up arrow will provide forward thrust - PowerPoint PPT Presentation

Citation preview

Page 1: Space Ship Game
Page 2: Space Ship Game

We will be creating a spaceship that simulates real movements in space.

The spaceship will fire a laser beam that can destroy targets.

The spaceship will be able to pass through the edges of the screen

Controls: Up arrow will provide forward thrust Right and left arrows will turn the ship

Page 3: Space Ship Game

Since we are going to be creating a spaceship, set the stage background to be stars.

It can be found in the Nature folder.

Page 4: Space Ship Game

Draw a Spaceship sprite.

Make sure you point the ship to the right.

Make two costumes, one with flames and one without.

Page 5: Space Ship Game

Create the following VariablesVariables: (For this sprite only)

DirectionChangeNewXNewYThrust

Page 6: Space Ship Game

We need to create three event scripts:

Up ArrowRight ArrowLeft Arrow

We will begin with the Up Arrow script.

Drag a when Space when Space Key pressedKey pressed block to the Ship sprite script area and change it to up arrow.

Connect a repeat untilrepeat until block to the when up when up arrow key pressedarrow key pressed block.

Page 7: Space Ship Game

Under Operators, drag an notnot operator block into the repeat repeat untiluntil block.

Page 8: Space Ship Game

Go to Sensing and put a key up arrow key up arrow pressed?pressed? block into the notnot block.

Page 9: Space Ship Game

Put a next costumenext costume block in the repeat repeat until until block.

Page 10: Space Ship Game

Put three change change DirectionChange byDirectionChange by blocks into the repeat untilrepeat until block.

Change the variables to Thrust, NewX, and NewY

Page 11: Space Ship Game

Put a value of 0.1 in the change Thrustchange Thrust by by block.

Page 12: Space Ship Game

Drag two multiplicationmultiplication operator blocks into the script area.

Page 13: Space Ship Game

Put the ThrustThrust variable block into the left side of both multiplicationmultiplication operator blocks.

Page 14: Space Ship Game

Put a sqrt of 10sqrt of 10 block on the right side of each multiplicationmultiplication block.

Page 15: Space Ship Game

Change one of the sqrt of 10sqrt of 10 blocks to sin of 10sin of 10

Page 16: Space Ship Game

Change the other sqrt of 10sqrt of 10 block to cos of 10cos of 10

Page 17: Space Ship Game

Put the ThrustThrust * sin * sin of 10of 10 block into the change NewX by change NewX by block.

Page 18: Space Ship Game

Put the ThrustThrust * cos * cos by 10by 10 block into the change NewYchange NewY block

Page 19: Space Ship Game

Go to motion and put a directiondirection block into the sin ofsin of and cos of cos of blocks.

Page 20: Space Ship Game

Put a switch to switch to costume NoFlamescostume NoFlames block underneath the repeat until repeat until not not key up arrow key up arrow pressed?pressed? block.

Page 21: Space Ship Game

Put a set Thrust to 0set Thrust to 0 block under the switch to costume switch to costume NoFlamesNoFlames block.

Page 22: Space Ship Game

Now that we have finished the Up Arrow scripts, we need to do the Right Arrow script and Left Arrow script.

Create a when right when right arrow key pressedarrow key pressed block and connect the blocks as shown in the image to it.

Page 23: Space Ship Game

Create a duplicate of the when right when right arrow key pressedarrow key pressed blocks by right clicking the when when right arrow key right arrow key pressedpressed block and clicking duplicate.

Alter this newly duplicated block so it matches the image to the right.

Page 24: Space Ship Game

Up, Right, and Left represent the user controls for the ship.

However, the ship will not move until we put the Action code for the computer to take the commands and translate them to movement.

Create a when Green when Green Flag clickedFlag clicked block and connect the specified blocks as shown in the image to the right.

Page 25: Space Ship Game

Create another when when Green Flag clickedGreen Flag clicked block and connect the blocks as shown in the image to the right.

This will reset the variables and allow the ship to pass through the edges of the screen.

Page 26: Space Ship Game

Click the Green flag and test your ship!

Page 27: Space Ship Game

We want a laser beam to travel to a target and then stop traveling when it hits a target.

We also want the laser beam to go back to the ship and hide when not being fired.

Click Paint New Sprite and draw a laser beam.

Page 28: Space Ship Game

Create the variables as shown in the image to the right for the Laser sprite.

Page 29: Space Ship Game

Create a new when when Green Flag clickedGreen Flag clicked block and connect the blocks as shown in the image to the right to it.

This allows the laser beam to travel a set distance and check its status (fire or not fired)

Page 30: Space Ship Game

Create a new when when space key pressed space key pressed block and connect the blocks as shown in the image to the right to it.

This makes it so when the laser is fired, it’s fired in the same direction the ship is facing.

Page 31: Space Ship Game

Test your laser beam!

Page 32: Space Ship Game

Our final step is to create targets for our space ship to shoot at.

Create a new Sprite.

For this newly created sprite, create a new when Green Flag clicked block and connect the blocks as shown in the image to the right.

This will glide the target sprite around in random directions.

Page 33: Space Ship Game

Complete the when Green Flag clicked block by connecting the additional blocks as shown in the image to the right.

This will now cause the sprite to disappear and re-appear if it is hit by the laser beam.

Page 34: Space Ship Game

Congratulations! You’ve finished creating your own space ship game.

See the next slide for challenges.

Page 35: Space Ship Game

Play a sound every time the laser beam is fired and whenever the laser successfully hits a target.

Add a score feature that increments when the laser beam hits the target and decrements when the target hits the space ship.

Add more targetsImplement your own creative features!