Scratch lesson plans.
Scratch lesson plans is a small, structured guide. The Scratch programming language is made for…
The objective of the game is to defend the key in the center. Ninjas will attempt to steal it, while the game player is going to shot them down through a rifle scope. Lets begin.Start by changing the background to ”neon tunnel” backdrop from the Scratch library. Then click on the ”paint a new sprite” icon to draw a scope, through which the ninjas will be shot from. A fresh canvas will open. Click on the ”convert to vector’ icon to have a scalable vector graphic. This data type allows to change the size of the object without losing the quality of it. Then use the ”ellipse” drawing tool to draw a circle. Use outline only and adjust the thickness of the outer line. When drawing, hold the Shift key to draw a perfect circle. Make sure that the size is not too big or to small. Look on the stage area to immediately see the result. Draw two straight lines to make a cross in the middle of the scope. Then add a red dot in the middle of it. This is going to me the default scope sight. Duplicate this costume, and add a yellow flash on top of the red dot.
This will create the appearance of shooting. Awesome, we are doing real good so far in this scratch tutorial. Next, I am going to write a script for it to make it useful for the game. Add one ‘when flag clicked’ block. Then add the ‘forever’ block under it. Inside it, add one ‘go to mouse-pointer’ motion block. And lastly, add one ‘go to front’ looks block. The script will loop these two blocks making the scope sight stick to the mouse pointer at all times. Making it possible to shot down the ninjas. And the looks block makes the sight be in front of all the other game objects. Then add another ‘when flag clicked’ and ”forever” block. Now I am going to make an ‘if then’ statement. Inside the conditional window add the ‘mouse down’ Sensing block. When I press the mouse button, I want the second costume to appear. Add ”switch costume to” block inside its mouth. In the drop down menu choose costume 2. This will make the shooting sight appear whenever I press the mouse button, and, to make it go back to the default sight, add one ”switch costume to ‘costume1’ block above the ‘if then’ block. That is all for the sight sprite. Next add the ‘key’ sprite from the character library, and place it in the middle of the stage. Adjust it size, so it is not too spacious. Also, adjust the size of the scope. Below this paragraph I have provided you with ninja characters. Right click on them, and save them on your computer. Then go to the Scratch editor, click on ”upload sprite from file” and upload the red ninja character to the game. Then go to its Costumes tab, and click ”upload costume from file”. Here you upload the yellow ninja. Shrink these character if they appear too big for the game by using the ‘shrink’ tool on the top panel.
Now I am going to script the ninja character to make the game live! Start by adding the ‘when green flag’ clicked block and add one ‘forever’ block. Next I will make the ninja spawn its clones at random time intervals. Make a variable, name it ”spawn time”. Add one ”set spawn time to” block inside the ‘forever’ loop. Then add the ‘wait 1 second” Control block, and one ”create clone of myself” block under it. All this should be inside the ”forever” block. Now, to differ the spawning time, add one ‘pick random’ Operators block inside the ”set spawn time to” window, and set the range from 1 to 2. Now, grab the ‘spawn time’ variable block and place it inside the ‘wait 1 seconds’ block. The time will randomly vary from 1 to 2 seconds now. And to change the costume of each spawn, add the ‘next costume’ Looks block before the ”create clone” block. We are half way through this Scratch programming tutorial.
Next I am going to make a program that will make them spawn in random places, move towards the key, and they will die, if I shoot them. Start by adding the ‘when I start as a clone’ block. Then make a new variable, and name it ‘left-right’. Add one ”set left-right to” block under the clone Control block. Inside its window, add the ‘pick random’ Operators block, and set the range from 1 to 2, because there are going to be two side from which the ninjas will spawn from. Either from right or left. Now, I am going to add the ‘if-then-else’ loop block. Inside the conditional window add one ‘equal’ Operators block. Now the ‘left-right’ variable block on the left side, and set it to be equal to 1. Now, when the ‘left-right’ variable is going to be equal to 1, chosen randomly by the ‘pick random’ block, the script will make it spawn on the right side of the screen. And to do so, add the ‘go to x y’ coordinates block inside the ‘if’ portion, and add another one inside the ‘else’ portion. The first motion block’s x coordinate value should be 240, which means far right side, and the second one should be set to -240, which means far left side of the stage. Now I will make them spawn at random heights, and to do so, add ‘pick random’ Operator blocks for both y coordinates. Set the range for both of them from -240 to 240, which means it can spawn at any height. It is a very cool addition to a game. It makes it much more unpredictable and challenging.
Finally, add one ‘repeat until’ loop block. Inside the condition window, add the ‘touching color’ Sensing block. Click on the color window, and pick the same color as you used for the shooting sight costume. Inside the Control block, add one ‘move 10 steps’ block, and change it to 5 steps instead. Also, add one ‘point towards Motion block, and choose to point towards Key sprite. The blocks inside its mouth will be repeated until the ninja touches the yellow color, which will appear when we have a lock-on the ninja, and we press the mouse button to shoot at it. Lastly, add one ‘delete this clone’ Control block at the very bottom of the script. This will make it disappear when we shot at it. Before the program test, add one ‘hide’ block just below the ‘when flag clicked’ block, and one ‘show’ Looks block under the ‘when I start as a clone’ Control block. Well done! I hope you enjoyed this Scratch programming tutorial, where I showed you how to make a first person shooter game. Check out this YouTube channel for more free information on Scratch programming tutorial. https://www.youtube.com/channel/UCEuFWqWHlib3yeTe1JU7ZCA