← Teacher guide

Move with the controller

Students hand a sprite to the arrow keys with move with buttons, and see that its two numbers are speeds across and down, not a place.

Arcade Foundations · Sprites and movement · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Run 7 min · Investigate 10 min · Modify 10 min · Make 8 min · Goalkeeper 5 min

Before class

move with buttons (Controller) hands a sprite to the arrow keys: it moves while a key is held. Its two numbers (click + to show them) are the speeds across and up and down, in pixels per second; 0 stops movement that way. They are not a position. on A button pressed is an event: it runs each time A (space or Z) is pressed. Students must click the simulator before it hears keys.

Running the lesson

  1. Predict: some students read the numbers as a place (100, 0). Ask what happens while a key is held.
  2. Run: all four arrows. Up and down do nothing.
  3. Investigate: Kim's cloud shows that the block steers only the sprite it names.
  4. Modify: the dash changes x by 30: a position change, once per press.
  5. Make: speeds 100 and 0, plus stay in screen.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Reading the two numbers as speeds, not a place. Ask what each number does while a key is held.

When students get stuck

What you will seeA question to askThe fix
The arrow keys do nothing.Did you click the simulator? Is there a move with buttons block?Click once on the game screen so it hears the keyboard, and check move with buttons names the right sprite.
The sprite flies off the edge.What stops it at the edge?Add set stay in screen for that sprite.
The sprite moves up and down when it should not.Which number is the speed up and down?Click + on move with buttons; set the second number to 0.

Answers to the checks

  1. Predict: The plane has move with buttons with speeds 100 and 0. You hold the up arrow. What happens?
    Nothing. The second number is the speed up and down, and it is 0, so up and down do nothing. The numbers are speeds, not a place.
  2. What does it do?: Match each block with what it does to a sprite.
    move with buttons → B. lets the arrow keys steer it, while a key is held; set stay in screen → C. stops it at the edge of the screen; set position → A. puts it at one place, once; on A button pressed → D. runs its blocks each time A is pressed
  3. Which way is faster?: A sprite has move with buttons with speeds 50 and 100. Which way does it move faster?
    Up and down
    The first number (50) is the speed across, the second (100) the speed up and down. 100 is faster.
  4. Kim's cloud: Kim's arrow keys move the cloud, not her plane. What did she do?
    Her move with buttons block names the cloud
    move with buttons steers only the sprite it names. Click the sprite's name in the block and choose plane.

Solutions

One possible solution for each task. Other correct programs are fine.

Modify › Only across

The program as blocks
Show as code
scene.setBackgroundColor(9)
let plane = sprites.create(img`
    . . . . 2 . . .
    2 . . . 2 2 . .
    2 2 1 1 1 1 1 2
    2 . . . 2 2 . .
    . . . . 2 . . .
    `, SpriteKind.Player)
plane.setPosition(20, 60)
controller.moveSprite(plane, 100, 0)

Modify › Dash

The program as blocks
Show as code
scene.setBackgroundColor(9)
let plane = sprites.create(img`
    . . . . 2 . . .
    2 . . . 2 2 . .
    2 2 1 1 1 1 1 2
    2 . . . 2 2 . .
    . . . . 2 . . .
    `, SpriteKind.Player)
plane.setPosition(20, 60)
controller.moveSprite(plane, 100, 0)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    plane.x += 30
})

Make

The program as blocks
Show as code
scene.setBackgroundColor(15)
let ship = sprites.create(img`
    . . 1 . .
    . 1 1 1 .
    1 1 1 1 1
    `, SpriteKind.Player)
ship.setPosition(80, 105)
controller.moveSprite(ship, 100, 0)
ship.setStayInScreen(true)

Change a goalkeeper

Open task: any program that does what the step asks.

Stretch and support

Stretch: Make A dash right and B dash left, and make the ship faster across than the plane was.

Support: Give students the ship with move with buttons already in, and ask them only to set the two speeds and keep it on the screen.

Exit ticket

move with buttons has speeds 0 and 80. Which arrow keys do something?

Only up and down. The first number, the speed across, is 0.

What each step is for

Where it leads

Next lesson: a speed the engine applies by itself, so a sprite keeps moving with nobody pressing anything.