Here in MAKESHOP, our go-to programming environment is Scratch, developed by MIT. Here are some basics.
This post will delve more deeply into how a character or object on the screen (sprite) can be made to move in Scratch. Below are three ways to do it. Each of these programs has only one sprite, so it should be straightforward to see how these are working.
In the first example, the helicopter moves up, down, left and right when the keyboard’s arrow keys are pressed. This is achieved in Scratch by changing the X and Y values. Imagine a grid covering the stage of a scratch program. The center of the stage is at height (Y) zero, sideways position (X) zero. To move up, we increase the Y number, to lower it, we lower the number. To move right, we increase X, to move left, we decrease it. Remember, numbers lower than zero become negative numbers.
In this one, the arrow rotates left and right when the left and right arrow keys are pressed. The space bar moves the arrow forward in the direction it is pointing.
This last one also uses rotation and movement, but instead of controlling the rotation with the arrow keys, the sprite will always point toward the mouse pointer. The script achieves this through the use of a forever block. When the space bar is pressed, the sprite will move toward the mouse pointer.
How could you combine these different kinds of movements in one project? Are there different ways that you, a human, can move that these sprites cannot?
This post is also the first use of Scratch inside our blog! Look forward to seeing some more animated and interactive posts in the future. Leave us a comment, or tweet us @makeshoppgh.