space ship game
Download
Skip this Video
Download Presentation
Space Ship Game

Loading in 2 Seconds...

play fullscreen
1 / 35

Space Ship Game - PowerPoint PPT Presentation


  • 121 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Space Ship Game' - abba


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction
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
    • Right and left arrows will turn the ship
stage
Stage

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

It can be found in the Nature folder.

spaceship sprite
Spaceship Sprite

Draw a Spaceship sprite.

Make sure you point the ship to the right.

Make two costumes, one with flames and one without.

variables
Variables

Create the following Variables: (For this sprite only)DirectionChangeNewXNewYThrust

up arrow event script
Up Arrow Event Script

We need to create three event scripts:

Up ArrowRight ArrowLeft Arrow

We will begin with the Up Arrow script.

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

Connect a repeat until block to the when up arrow key pressedblock.

up arrow event script1
Up Arrow Event Script

Under Operators, drag an not operator block into the repeat untilblock.

up arrow event script2
Up Arrow Event Script

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

up arrow event script3
Up Arrow Event Script

Put a next costume block in the repeat until block.

up arrow event script4
Up Arrow Event Script

Put three change DirectionChange by blocks into the repeat untilblock.Change the variables to Thrust, NewX, and NewY

up arrow event script5
Up Arrow Event Script

Put a value of 0.1 in the change Thrustby block.

up arrow event script6
Up Arrow Event Script

Drag two multiplication operator blocks into the script area.

up arrow event script7
Up Arrow Event Script

Put the Thrust variable block into the left side of both multiplicationoperatorblocks.

up arrow event script8
Up Arrow Event Script

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

up arrow event script9
Up Arrow Event Script

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

up arrow event script10
Up Arrow Event Script

Change the other sqrt of 10 block to cos of 10

up arrow event script11
Up Arrow Event Script

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

up arrow event script12
Up Arrow Event Script

Put theThrust* cos by 10 block into the change NewY block

up arrow event script13
Up Arrow Event Script

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

up arrow event script14
Up Arrow Event Script

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

up arrow event script15
Up Arrow Event Script

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

right arrow event script
Right Arrow Event Script

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 arrow key pressed block and connect the blocks as shown in the image to it.

left arrow event script
Left Arrow Event Script

Create a duplicate of the when right arrow key pressedblocks by right clicking the when right arrow key pressedblock and clicking duplicate.

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

action scripts
Action Scripts

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 Flag clicked block and connect the specified blocks as shown in the image to the right.

action scripts1
Action Scripts

Create another when Green Flag clickedblock 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.

testing
Testing

Click the Green flag and test your ship!

creating the laser
Creating The Laser

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.

creating the laser1
Creating The Laser

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

creating the laser2
Creating The Laser

Create a new when Green Flag clickedblock 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)

creating the laser3
Creating The Laser

Create a new when 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.

testing1
Testing

Test your laser beam!

targets
Targets

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.

targets1
Targets

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.

conclusion
Conclusion
  • Congratulations! You’ve finished creating your own space ship game.
  • See the next slide for challenges.
challenges
Challenges
  • 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 targets
  • Implement your own creative features!
ad