![]() Let’s write the code when rocks started as a clone.In Scratch, you can program the clones using “when I start as a clone”?.You can see five clones of rock created.After this drag and drop a “hide” block as shown below.Drag & drop the “create a clone of myself” block as shown below.Drag & drop the “repeat” loop and run it five times.Drag & drop “when green flag clicked” and “show” blocks as shown below.First, make it visible when the game start.Make multiple rocks that will come as enemies.Place the rock on the right side of the rocketship because the rock should come from right to left.Also, set the direction 90 as shown below. To make the game design cool, reduce the size of your sprite rock.Now, let’s add an enemy sprite to the game. Rocketship comes to the start point (-178, 5) when the game start.Drag & drop the “when green flag clicked” block on top as shown below.Drag & drop the “go to x y” block and set the value (-178, 5).Make a starting point for the rocketship when the game start.You can control the rocketship in upward & downward order using the up & down arrow keys.To check the condition continuously whether the up-arrow and down-arrow key is pressed or not put this code in the “forever” loop.Similarly, write a conditional statement for the “down arrow” key as shown below.From the “sensing category” drag and drop the “key pressed?” block and click on the drop-down and select “up arrow” as shown below.Drag and drop the “if-then” block from the “Control” category as shown below.Write a conditional statement to determine whether the “up arrow” key is pressed or not.Control rocketship with up & down arrow keys.Drag & drop the “change y by” block from the “motion category” positive y value will move upward, and the negative y value will move downward. ![]() As we want to move the rocketship in up & down order we have to do that by changing the y value. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |