In this add-on, you’re going to do something completely different and change how the gameis played and won. Before, the object of the game was to get to the goal as fast as possible.
In this add-on, you’ll program the goal sprite to chase the player sprite. Insteadof trying to catch the goal, the player will have to stay away from it.
To start, click on the goal sprite. For the goal sprite to chase the player, itneeds to point towards the player, then move forward repeatedly. To do that, go to themotion menu, and drag out a "point toward" block. Then, change the value to the nameof your player sprite. When that block is clicked, the goal sprite will point towardthe player. Next, the goal sprite needs to move towardthe player. Drag out a "move” block, and attach it to the point towards block.
When that block stack is run, the goal sprite points toward the player, then moves.
Add a forever loop to make this block stack run forever.
Test this. The goal sprite points towards the player,moves ten steps, and so on. This ensures that no matter where the player is, the goal spritewill point towards it, then move forward. Hmmm, that seems way too fast. Tinker withthe value of the move block to slow it down. Great!
Now the goal sprite moves. Program the goal sprite’s position to reset when the gamebegins. Drag the goal sprite to where it should start, then add a “go to x y” block, andplace it at the top of this stack. Add a "when flag clicked" block to start thiscode stack.
Click the flag to test it. Great, it works, but it could be better. The player says “Youwin!” when the goal sprite touches it, but that no longer fits how the game works. Selectthe player sprite, and change the text in the “say” block to something like “Yougot caught!”
Notice that the goal sprite bounces back and forth really fast when it touches the playersprite.
That’s because the goal sprite is still trying to move toward the player over andover. Since the player isn’t moving, the goal sprite just bounces.
The goal sprite should move until it touches the player sprite, not “forever.” A “repeatuntil” block will repeat the actions inside it until its condition is met. In this case,it will make the goal keep moving and pointing toward the player until it touches it.
Select the goal sprite. Replace the “forever” block with a “repeat until” block fromthe control menu. From the sensing menu, add a “touching” block as the condition. Fromthe dropdown, select the name of the player sprite. Now this reads, “repeat moving untiltouching the player sprite.” Click the flag to test.
Great! It works. Now, it’s your turn:Make the goal sprite chase the player using “point towards,” “move” and “forever”blocks. Change the message at the end of the game.
Stop the goal sprite from moving by replacing the “forever” block with “repeat until”and “touching” blocks.
Choose an Add-On
play_circle_filled
Spinning Obstacle
Create a more challenging game by making an obstacle spin.
arrow_forward
play_circle_filled
Overtaken
Create an obstacle that slowly grows throughout the game.
arrow_forward
play_circle_filled
Revenge
Program the goal sprite to chase the player sprite.
arrow_forward
play_circle_filled
Keeping Time (Part 1 of 2)
Create a timer to keep score for this game, and program a way to store the fastest time.
arrow_forward
play_circle_filled
Keeping Time (Part 2 of 2)
Create a timer to keep score for this game, and program a way to store the fastest time.
arrow_forward
play_circle_filled
Redesign Your Maze
Change the look of the maze or draw your own!
arrow_forward
play_circle_filled
Tell a Story
Engage game players with an exciting story for your game.