<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://wiki.slq.qld.gov.au/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>SLQ Wiki digital_literacy:technology_resources:scratch:movement</title>
        <description></description>
        <link>https://wiki.slq.qld.gov.au/</link>
        <lastBuildDate>Thu, 09 Apr 2026 06:46:38 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://wiki.slq.qld.gov.au/lib/tpl/mikio/images/favicon.ico</url>
            <title>SLQ Wiki</title>
            <link>https://wiki.slq.qld.gov.au/</link>
        </image>
        <item>
            <title>Lets create characters that respond to the keyboard</title>
            <link>https://wiki.slq.qld.gov.au/doku.php?id=digital_literacy:technology_resources:scratch:movement:start&amp;rev=1616128227&amp;do=diff</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;lets_create_characters_that_respond_to_the_keyboard&quot;&gt;Lets create characters that respond to the keyboard&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Creating characters that move based on keys pressed on the keyboard is simple. In this tutorial, we are going to move the Scratch cat left, right and jump when the arrow keys or the spacebar is pressed.
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;moving_scratch_the_cat_left&quot;&gt;Moving Scratch the Cat Left&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
To begin, we are going to drag the &lt;em&gt;When space key is pressed&lt;/em&gt; hat from the &lt;em&gt;Events&lt;/em&gt; palette and change the key from &lt;em&gt;space&lt;/em&gt; to &lt;em&gt;left arrow&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:left-arrow-hat.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Next lets connect a &lt;em&gt;move X steps&lt;/em&gt; block from the &lt;em&gt;Motion&lt;/em&gt; palette under the &lt;em&gt;When left arrow key is pressed&lt;/em&gt; hat, change the 10 steps to a -10 steps to change our character from moving right to moving left, and finally press the Left Arrow key on the keyboard to see if it works.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:move-minus-10.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Well the Scratch Cat is moving left, but backwards. Lets fix it by first adding the &lt;em&gt;point in direction&lt;/em&gt; block between the event hat and the move steps block, then change the direction to -90 to point left.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:point-in-direction.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
If you press the Left Arrow key now, you will see that the Scratch cat will:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Point the correct direction, left but upside down!&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Will now move right instead of left!&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
This is because by default, the &lt;em&gt;point in direction&lt;/em&gt; block rotates the sprite in a circle, not left-right and now that the sprite is facing to the left, the move -10 steps tells the sprite to move backwards from the direction it is facing.
&lt;/p&gt;

&lt;p&gt;
Lets fix this, first change the &lt;em&gt;move -10 steps&lt;/em&gt; block to &lt;em&gt;move 10 steps&lt;/em&gt;. This fixes the move left problem.
&lt;/p&gt;

&lt;p&gt;
Next we need to let scratch know that when we use the &lt;em&gt;point in direction&lt;/em&gt; block, we want it to act in a left-right style, so lets add a &lt;em&gt;set rotation style left-right&lt;/em&gt; block from the &lt;em&gt;Motion&lt;/em&gt; palette above the &lt;em&gt;point in direction&lt;/em&gt; block.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:move-left-correct.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;moving_scratch_the_cat_right&quot;&gt;Moving Scratch the Cat Right&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
With the moving left code done, we can now create the moving right. As the code is similar to the moving left stack, we can right click on the &lt;em&gt;When left key is pressed&lt;/em&gt; hat and select duplicate.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:duplicate.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Next, we need to change a few variables on this new stack:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The &lt;em&gt;left arrow&lt;/em&gt; needs to change to &lt;em&gt;right arrow&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The &lt;em&gt;point in direction -90&lt;/em&gt; needs to change to &lt;em&gt;point in direction 90&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
And we are done here!
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:move-right.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;resetting_the_scratch_cat&quot;&gt;Resetting the Scratch Cat&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
Before we continue to the jumping code, we need to reset the sprite to its starting location whenever we press the &lt;em&gt;Green Flag&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
On the stage, move the Scratch Cat to where you would like to be whenever the &lt;em&gt;Green Flag&lt;/em&gt; is pressed. Typically this is in the centre of the stage.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:cat-move-center.gif&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Now grab a &lt;em&gt;When Green Flag clicked&lt;/em&gt; hat from the &lt;em&gt;Events&lt;/em&gt; palette and place it in the programming area.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:green-flag-hat.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Next grab a &lt;em&gt;go to x / y &lt;/em&gt; block and connect it under the &lt;em&gt;When Green Flag clicked&lt;/em&gt; hat. The &lt;em&gt;go to&lt;/em&gt; block will be preset to the current position of the Scratch Cat. This is why we moved it around on the stage before grabbing the &lt;em&gt;go to&lt;/em&gt; block.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:goto-x-y.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;jump_cat_jump&quot;&gt;Jump Cat Jump!&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
Onto the tricky part, to make the Scratch Cat jump, we will need a &lt;em&gt;glide 1 secs to x / y&lt;/em&gt; block from the &lt;em&gt;Motion&lt;/em&gt; palette. Here we use a &lt;em&gt;glide&lt;/em&gt; block instead of a &lt;em&gt;go to&lt;/em&gt; block as it &amp;#039;glides&amp;#039; or &amp;#039;slides&amp;#039; instead of &amp;#039;jumping&amp;#039; or &amp;#039;teleporting&amp;#039; to the position.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:glide-initial.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
The X and Y on your block maybe different to this example. That&amp;#039;s ok, we are going to change them in a second.
&lt;/p&gt;

&lt;p&gt;
First we need to know that whenever we are talking about the X position (or X axis) of a sprite, we are talking the horizontal or left-right position. The Y position (or Y axis) is the vertical or up-down position.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:x-y_axis.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Now, the &lt;em&gt;glide&lt;/em&gt; block needs to know the X and Y position to move our Scratch Cat to, but our Scratch Cat can move left or right, along the X axis, so we don&amp;#039;t know what the X position of the cat will be, it could be anywhere depending on how many times the player has pressed the left or right arrows. So what do we do?
&lt;/p&gt;

&lt;p&gt;
We can use a variable block. Under the &lt;em&gt;Motion&lt;/em&gt; palette, find the &lt;em&gt;x position&lt;/em&gt; and move it into the X field of the &lt;em&gt;glide&lt;/em&gt; block. We have now told that we want to move the X position of the Scratch Cat to the current X position of the Scratch Cat! So the Scratch Cat won&amp;#039;t actually move left or right when we jump!
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:x-position-glide.gif&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Next we need to glide the Scratch Cat upwards along the Y position. To do this we are going to use some Math and an operator block.
&lt;/p&gt;

&lt;p&gt;
Grab a &lt;em&gt;X + X&lt;/em&gt; block under the &lt;em&gt;Operators&lt;/em&gt; palette and place it in the Y field of the &lt;em&gt;glide&lt;/em&gt; block. Next we want to the &lt;em&gt;y position&lt;/em&gt; block under the &lt;em&gt;Motion&lt;/em&gt; palette into the first field of the &lt;em&gt;X + X&lt;/em&gt; block, and finally we are going to type the number 10 in the second field of the &lt;em&gt;X + X&lt;/em&gt; block.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:y-position-glide.gif&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Now that the Scratch Cat is able to jump up, we need it to fall back down. We can do this by duplicating the first glide block and changing the &lt;em&gt;X + X&lt;/em&gt; block to a &lt;em&gt;X - X&lt;/em&gt; block.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:y-position-minus.gif&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
and now to finish it off, lets grab a &lt;em&gt;when space key is pressed&lt;/em&gt; hat from the &lt;em&gt;Events&lt;/em&gt; palette and connect our glide blocks underneath.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://wiki.slq.qld.gov.au/lib/exe/fetch.php?media=digital_literacy:technology_resources:scratch:movement:space-jump.png&quot; class=&quot;mediacenter&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Awesome!
&lt;/p&gt;

&lt;p&gt;
You can view the final Scratch project over on the &lt;a href=&quot;https://scratch.mit.edu/projects/503951658/&quot; class=&quot;urlextern&quot; target=&quot;_tab&quot; title=&quot;https://scratch.mit.edu/projects/503951658/&quot; rel=&quot;ugc nofollow noopener&quot;&gt;Scratch Website&lt;/a&gt;

&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
        <category>digital_literacy:technology_resources:scratch:movement</category>
            <pubDate>Fri, 19 Mar 2021 14:30:27 +0000</pubDate>
        </item>
    </channel>
</rss>
