Skip to main content

Featured

Space Explorers Book 7: Answers and Explanations

Memunic Space Explorers › Book 7: Memoon and the Search for Another Home › Answers and Explanations Answers and Explanations Habitable means life could live there; inhabited means life does live there. A world can be habitable and empty, as an unoccupied flat has a roof and water but nobody in it. The Moon has almost no air, so water would boil or freeze, and its gravity is only about one-sixth of Earth’s, too weak to keep air. Accept also: no greenhouse blanket, so it swings between very hot and very cold. Venus. It matches Earth in size and roughly in mass, but its thick carbon dioxide air traps heat, making it hot and crushing. “Twin” is only true for size and weight. A dip of 1 per cent means (planet width divided by star width) squared is 0.01, so the ratio is 0.1: the planet is about a tenth as wide as the star. Repeats at the same gap show the planet is going round the star in 12 days, and rule out a one-time event such as a passing object. A planet shines only by reflected l...

Byte by Byte Book 4: Chapter 7 – Motion, Coordinates and Sequences

Byte by Byte › Book 4: Office Apps and First Programs › Chapter 7: Motion, Coordinates and Sequences

Chapter 7: Motion, Coordinates and Sequences

You will learn: the Scratch stage as a coordinate grid (x and y, including negative numbers), directions in degrees, motion blocks such as go to, glide and point in direction, using waits for timing, and planning a precise sequence.

🌟 The Adventure

The opening act of the festival show was to be a puppet dance in honour of the Queen: the dancer puppet would enter from the left, glide to centre stage, turn to face the audience, bow and spin.

Memoon tried. She used move 10 steps again and again. The puppet stumbled forward in tiny jerks, overshot the centre, walked straight off the right edge of the stage and vanished. When she clicked the green flag again, it started from wherever it had ended up, half hidden behind the curtain.

"Where is the middle, exactly?" asked Kachui. "And how do we tell it to start in the same place every time?"

Memoon thought about her Bharatanatyam teacher, who always told each dancer exactly where to stand on the stage floor, marked with chalk. "We need a map of the stage," she said. "With numbers."

Illustration from Byte by Byte Book 4: Chapter 7 – Motion, Coordinates and Sequences

💡 Learn With Memoon

The stage is a coordinate grid. Every point on the Scratch stage has an address made of two numbers, called coordinates.

  • x tells how far left or right. It runs from -240 at the left edge to 240 at the right edge.
  • y tells how far up or down. It runs from -180 at the bottom to 180 at the top.
  • The centre is (0, 0), called the origin.

So the stage is 480 steps wide and 360 steps tall. We always write x first, then y: (x, y). A handy reminder: you walk along the corridor (x) before you go up the stairs (y).

PositionCoordinates
Centre(0, 0)
Middle of the right edge(240, 0)
Middle of the left edge(-240, 0)
Top centre(0, 180)
Bottom-left corner(-240, -180)
Top-right corner(240, 180)

Negative numbers are numbers less than zero. On the x axis they are to the left of the centre; on the y axis they are below the centre. -100 is further left than -50. You can see the mouse's coordinates by moving it over the stage: they appear below the stage (in the online editor) and in a sprite's information in the sprite pane.

Directions are angles. Scratch measures direction in degrees, like a compass:

DirectionSprite faces
90Right (the default)
0Up
-90Left
180Down

A full turn is 360 degrees; a quarter turn (a right angle) is 90 degrees; a half turn is 180 degrees. turn ↻ 90 degrees turns clockwise a quarter turn; turn ↺ 90 degrees turns anticlockwise.

Motion blocks.

BlockWhat it does
move (10) stepsMoves in the direction the sprite is facing
turn ↻ (15) degrees / turn ↺ (15) degreesRotates clockwise / anticlockwise
go to x: () y: ()Jumps instantly to a position
glide (1) secs to x: () y: ()Slides smoothly to a position over a time
point in direction (90)Faces a direction
change x by (10) / change y by (10)Moves right (or left if negative) / up (or down if negative)
set x to () / set y to ()Sets one coordinate only
if on edge, bounceTurns round when touching the stage edge
set rotation styleAll around, left-right only, or don't rotate

Always set a starting position. A program should put sprites where they belong at the start, called initialising. Begin with go to x: () y: () and point in direction (90) right after the green flag. Otherwise each run starts from wherever the last run ended. Tip: drag a sprite to where you want it, and Scratch fills in its current x and y in the go to and glide blocks in the palette.

Timing. Computers run blocks extremely fast. If a sprite does three things with no pause, you may only see the last one. wait (1) seconds (Control) slows things down so people can see each step. Glide and say for (2) seconds have timing built in.

Planning a sequence. Before coding, plan in plain words (this kind of plan is called pseudocode) or on a sketch of the grid. For the dancer: start at (-200, -100); glide to (0, -100) in 2 seconds; face the audience; say Namaste!; turn 360 degrees in steps.

Illustration from Byte by Byte Book 4: Chapter 7 – Motion, Coordinates and Sequences

✍️ Try It Yourself

Activity 1: Explore the grid. Move your mouse slowly around the stage and watch the x and y numbers change. Find each corner. Find (0, 0). Find (100, -50). Which way did you move to get a negative y?

Activity 2: The Queen's dance. Choose a dancer sprite (for example, Ballerina or Dani) and the Theater backdrop. Build this script:

when green flag clicked
go to x: -200 y: -100
point in direction 90
glide 2 secs to x: 0 y: -100
say Namaste! for 2 seconds
turn ↻ 90 degrees
wait 0.5 seconds
turn ↻ 90 degrees
wait 0.5 seconds
turn ↻ 90 degrees
wait 0.5 seconds
turn ↻ 90 degrees
glide 2 secs to x: 200 y: -100

Click the green flag several times. Does it always start in the same place? How many degrees did it turn altogether? Now remove the go to block and run it twice. What goes wrong?

Activity 3: Draw a square path. Use only move and turn blocks to make a sprite walk around a square and return to where it started. (Hint: four sides, four turns of how many degrees?) Add wait 0.5 seconds after each move so you can see it.

Activity 4: Treasure map. Place a Star sprite at (150, 120). Program a second sprite to glide there in three steps: first change x only, then change y only, then say Found it!

Unplugged: Grid dance. Draw a 5 × 5 grid on paper with x and y from -2 to 2. Give a partner coordinates such as (2, 1), (-1, -2), (0, 0) and have them place a coin on each. Then swap.

🎉 Memoon Solves It

Memoon drew the stage as a grid in her notebook, marked centre stage at (0, -100) where the floor was, and wrote her plan in pseudocode before touching a block. Then she built the script: go to the starting mark, point in direction 90, glide to centre, say Namaste!, four quarter turns with short waits, and a graceful glide off to the right.

She clicked the green flag. The dancer entered smoothly, stopped exactly at centre, bowed with a Namaste and spun once. She clicked it again. Exactly the same. And again. Perfect every time.

"Like chalk marks on the dance floor," said Memoon. Kachui nodded. "But four turns written out four times," he said, peering at the code. "Isn't there a shorter way?"

❓ Check Your Knowledge

  1. What are the x and y coordinates of the centre of the stage? What is that point called?
  2. What range of numbers can x have? What range can y have?
  3. Is (-150, 60) on the left or right half of the stage? The top or bottom half?
  4. Which direction number makes a sprite face up? Left?
  5. How many degrees are in a full turn? A quarter turn?
  6. What is the difference between go to x: y: and glide to x: y:?
  7. Why should a program set a sprite's starting position after the green flag?
  8. Why might you add wait blocks to a sequence?
  9. A sprite at (0, 0) runs change x by -50 then change y by 30. Where does it end up?
  10. Challenge: Plan a sequence that makes a sprite walk around a rectangle 200 steps wide and 100 steps tall.

📚 Word Bank

  • Coordinates: a pair of numbers (x, y) giving a position on a grid.
  • x / y: the horizontal (left-right) / vertical (up-down) coordinate.
  • Origin: the centre point (0, 0).
  • Negative number: a number less than zero.
  • Degree: a unit for measuring turns and angles; a full turn is 360 degrees.
  • Direction: the way a sprite faces, measured in degrees.
  • Initialise: set things to their starting state when a program begins.
  • Glide: move smoothly to a position over time.
  • Pseudocode: a plan for a program written in plain words.

Keep learning with Byte by Byte

Explore Book 4: Office Apps and First Programs. Find the ebook, purchase details and teaching slides on MemuniCity.

Watch this chapter on YouTube

Comments

Popular posts from this blog

CA-7 Job Status and Failure Reason Codes

Here are the various status codes that You may see for jobs in the Queue or Logs in CA-7. R-C0002 R-C0003 R-C0099 R-C0255 R-JCLER A-U0002 A-U0004 A-U0015 A-U0043 A-U4095 A-SOC7 A-U4000 Reason Code/Job Status Code explanation: The indication of the job's current disposition. Values and their meanings are: A-Snnnn-- The job has failed with a system abend. A-Unnnn --The job has failed with a user abend. C-Cnnnn --The job has completed successfully and is going through completion processing. E-ARFATT-- An error occurred during the attempt to attach ARF definitions. This can result if the ARFSET specified is not defined. A diagnostic message may have been written to the CA-7 log, the OS console, or to the trailer queue for the job (in which case it can be displayed using LQ,JOB=x,LIST=ALL). E-ARFERR ---The job encountered an error in the ARF processing. Do a LARFQ command for the job to get more specific information. E-SEGERR --The job has been requeued...

Whistling Winds and Waterfalls: 4 Days of Magic in Shillong

Nestled in the clouds, where the scent of pine trees mingles with the rhythm of waterfalls and the tunes of local guitar-strumming youth—Shillong is more than a place. It’s a vibe. If you’ve got 3 nights and 4 days, you’ve got just enough time to fall in love. Here’s how to make the most of it—food, fun, fog and fantastic views included. Day 1: Shillong, We’re Coming for You! You land in Guwahati, barely out of the airport when the hills start calling. You hop into your cab, Spotify on, windows down, and the three-hour ride to Shillong begins. Just when you think it can’t get better, you stop at Umiam Lake —a lake so calm, it looks like someone ironed the water. By evening, you’re sipping hot chai in Laitumkhrah, maybe nibbling on spicy momos or pork jadoh from a roadside stall. You’re checked into your charming hotel ( Tripura Castle if you fancy old-world royalty, Ri Kynjai if you’re into lakeside poetry). The breeze whispers secrets of waterfalls and pine forests. Sleep well, drea...

Installing and Configuring Hadoop on Ubuntu as a Pseudo Distributed Single Node Cluster

Briefly what is psuedo-distributed single node Hadoop cluster: It is a Hadoop distributed cluster having Single Node. All the five daemons (NN,DN,JT,TT,SNN) are running as individual JVM (java process) instances. We will get all distributed features of Hadoop. This mode is used to develop, test, and staging (before production) Map Reduce programs quickly. It writes all the system, daemon and user logs to different files on the cluster To install Hadoop in this mode, we have to modify the hadoop-env.sh, core-site.xml, hdfs-site.xml, mapred-site.xml. hadoop-env.sh contains all the Environment variables which are required for running Hadoop. All the default values are fine, Only we have to modify the JAVA_HOME=“The location of Java Home Directory” Core-site.xml contains all the cluster specific information like io, temp directory, sorting, file system uri etc. Hdfs-site.xml contains all the parameters which are specific to HDFS like name node directory, data node directory...