1/10/2024 0 Comments Super meat boy forever sprites![]() We’ll create clones of the original Energy Blast sprite so that more than one energy blast can be on the Stage. There is only one Energy Blast sprite, but the player should be able to fire many energy blasts at once. We’ll make clones of the Energy Blast sprite, but the clones and original sprite will run different code. Then click the Choose a Sound button in the lower left. Click the Sounds tab above the Block Palette. We want the Energy Blast sprite to make a laser sound when the Spaceship sprite fires it. In the Sprite Pane, rename it Energy Blast. Click the Choose a Sprite button in the lower right. Scratch’s Sprite Library has a sprite we can use for the energy blasts. These blasts will bust up those dangerous space asteroids! In space! 4. The code that controls the Spaceship sprite is complete, so let’s add energy blasts. Because the x velocity and y velocity variables will still be moving the Spaceship sprite at the same speed and in the same direction, the Spaceship sprite will look like it’s moving continuously around the Stage.Īim with the Mouse and Fire with the Spacebar Whenever the x or y position of the Spaceship sprite gets within five steps of these edges, this new code will move the Spaceship sprite to the other side of the Stage. We use these boundaries to write code that changes the position of the Spaceship sprite when it goes past these four coordinates. The bottom and top edges of the Stage are at the y-coordinates −180 and 180. The left and right edges of the Stage are at x-coordinates −240 and 240, respectively. ![]() The following code will make the spaceship travel to the other side of the Stage whenever it reaches an edge. Add the Wrap-Around Code to the Spaceship Sprite But in Asteroid Breaker, we want sprites to go off the side of the Stage and wrap around to the other side. When you tested the code, did you notice that the Spaceship sprite stops immediately when it runs into the edge of the Stage? The reason is that Scratch prevents sprites from moving off the Stage, which is helpful in most Scratch programs. Repeat the preceding steps to create a variable named y velocity. Make x velocity a For this sprite only variable. In the orange Variables category, click Make a Variable and create a variable named x velocity. Then select the Spaceship.png image file from the resources ZIP file. Hover over the Choose a Sprite button and click the Upload Sprite button that appears. We’ll use a flying saucer image for the spaceship, which you’ll find in the resources ZIP file. Start a new project in the Scratch editor and enter Asteroid Breaker as the project name. We won’t use the Cat sprite that Scratch starts with, so right-click or long press that sprite in the Sprite Pane and select delete before continuing, or click the Trash Can icon next to the sprite. Click the Choose a Backdrop button in the lower right and then select Stars. We’ll make this game spacey by adding the stars backdrop and the spaceship sprite. Make a Spaceship That Is Pushed Aroundīefore we code the exciting parts of the game, we need to set up the backdrop and sprite. The skeleton project file has all the sprites already loaded, so you’ll only need to drag the code blocks into each sprite. Go to and download the ZIP file to your computer by right-clicking the link and selecting Save link as or Save target as. If you want to save time, you can start from the skeleton project file, named asteroidbreaker-skeleton.sb3, in the resources ZIP file. Aim with the mouse and fire with the spacebar In our version of the game, the player controls their spaceship with the WASD keys and aims at incoming asteroids with the mouse.Īnd here’s what we’ll be doing in each part: Let’s draw on paper what the game should look like. The other half of the fun is blowing up asteroids.īefore you start coding, look at the final Asteroid Breaker program at. It takes skill to move the spaceship without losing control, but that’s half the fun of the game. To slow down the spaceship, players must push it in the opposite direction. Instead of directly controlling where the spaceship moves, the player pushes the spaceship like a hockey puck on ice because the player’s ship has inertia, it slides around the Stage. in space!” makes everything more exciting.) in space! (It’s a well-known fact that adding “. The player pilots a spaceship that must destroy space asteroids while avoiding the pieces that break off. Since then, many programmers have remade the game, and it’s a great programming project to make in Scratch, too. Steroids is a classic game developed in 1979 by Atari.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |