Instructions for making Cross the Road game on Scratch
Cross the Road This is a game about leading pets across the street that sounds simple but extremely interesting. Here it is How to make a fun Cross the Road game in Scratch.
1. Create a backdrop
In the ‘choose a backdrop’ section, select ‘Paint’. Click the rectangle tool from the tools menu. You can start by drawing a large green rectangle that covers the entire background, then draw a smaller black rectangle for the actual road.
Now, you need to draw road markings. Select the line tool from the tools menu. Set the line thickness to 10. After drawing a line, simply copy and paste it as the remaining lines. Use the selection tool from the corresponding menu to select and move lines around. You need 4 white lines and 2 yellow lines.
2. Select sprite
This is the step of choosing a character image. This example will have 4 chickens (one in each lane) and a car to cross the road. Scratch offers 4 types of chicken character images to choose from. You can also draw your own or upload your favorite custom character image!
3. Customize sprites
Now you need to edit so that all the character images match the background image. First, resize all the chickens to fit the lines, scale the car and rotate it so it’s facing the right direction. You can also change the color of the car if you want. You can use the fill tool to change the color.
This example chooses red! In addition, the chickens need to look very serious when crossing the street. Draw their eyebrows to show this. Use the line drawing tool from the tools menu to draw eyebrows, just like you drew lines on a wallpaper!
4. Make the chicken move
Let’s start with the chick. When you click on the green flag, you just want it to move to the sides automatically. A ‘move 10 steps’ motion block, a ‘if on edge then bounce’ motion block and an ‘infinite’ loop from the control menu will help with this. Set its rotation pattern to ‘left-right’, otherwise the chick will flip upside down when it bounces off the edge. You can do this with the rotation block from the motion block category.
5. Make all the chickens move
Basically, all chickens do the same thing. You can copy code between sprites by clicking and dragging the code you want to copy onto the image of the sprite you want to copy to. The sprite will vibrate when you place the code in the correct position. You will assign the same code to all chickens, except each chicken will move a little faster than the previous one. The more steps you program your chickens to move, the faster they will move and the harder your game will be!
You can always adjust the speed if the game doesn’t look right when testing the code.
6. Control the car with the arrow keys
To control the car, you can use an ‘if-then’ block to check if the arrow key is pressed or not. If correct, you will steer the car towards that arrow key and move a few steps. You must make sure to put ‘if-then’ blocks inside a ‘forever’ loop, so Scratch knows to always check if these keys are pressed or not. If you want the vehicle to always face the same direction no matter where it moves, you can set the vehicle’s rotation pattern to ‘no rotation’.
Run the game and see if your car can move in all directions. If the vehicle does not move in a certain direction, check that the code matches what is written below.
7. Loss condition
Cross the Road game will end if one of the chickens crashes into the vehicle. You can use some ‘touch’ sensor blocks and some ‘or’ operator blocks to check if the chicken collided with the vehicle or not. If so, you’ll stop the car, play some sounds, and stop the game. The chickens will continue to move while the sound is playing but the car will stop. Block ‘stop other scripts in the sprite‘ is responsible for stopping the moving vehicle.
To continue checking the code after losing, make sure to move the vehicle back to its original position by clicking and dragging it.
8. Win conditions
Let’s edit the background and draw a big red line on the other side of the street. In the vehicle sprite, you will check to see if it touches the color of that line. If it does, you have safely reached the other side of the road. You can enjoy your victory with positive sound effects, then stop the game.
Basically, the game Cross the Road on Scratch is completed. Now you can add some effects to make the game more vivid.
9. Animate the chicken
You can animate any sprite using the ‘next costume’ block, but only if that sprite has multiple costumes, and only if those costumes make sense to animate. You can check out the outfits in the outfits tab. This is also where you can add new outfits or draw your own! Don’t forget to add eyebrows to the animation too! The Chicks, Hens, and Roosters sprites all have built-in animations by default. You’ll have them transition through outfits and use a ‘wait’ block to control the speed of execution. You will also stop the chickens from moving if they catch the cart; This code will be applied to all four chickens.
10. Move the vehicle to the starting position
If you lose and try to play again by clicking on the green flag, you will probably lose immediately, because the car is still on the road. You can tell the vehicle where to move when clicking the green flag using its X and Y position. X and Y indicate the object’s location in project space. If you move the object, notice how X and Y change. You will move the vehicle to the desired position, check the X and Y position, and have it move to the same position when clicking the green flag.




Post Comment