Give a sprite gravity with ay, so it falls faster and faster, and a jump rises, slows and comes back down.
Mario, Sonic and every runner game on a phone: you press jump, you rise, you slow down, you fall back. That curve is gravity.
You know velocity: vx and vy say how far the engine moves a sprite every frame. Arcade has a third number, ay: the acceleration down. Every frame, the engine adds a little to vy, so the sprite falls faster and faster. That is gravity. Set ay in Sprites: the same block as set vx, with ay chosen in its dropdown.
A jump is just a speed upwards: a negative vy (y counts down, so up is negative). Gravity then slows the sprite, stops it, and pulls it back down.
Make your prediction first. Help opens once you've locked it in.

scene.setBackgroundColor(9)
let ball = sprites.create(img`
. 2 2 .
2 2 2 2
2 2 2 2
. 2 2 .
`, SpriteKind.Player)
ball.setPosition(80, 10)
ball.ay = 300
Watch the ball closely: does it fall at a steady speed? Press the restart button under the simulator to see it again.

scene.setBackgroundColor(9)
let ball = sprites.create(img`
. 2 2 .
2 2 2 2
2 2 2 2
. 2 2 .
`, SpriteKind.Player)
ball.setPosition(80, 10)
ball.ay = 300
This ball has gravity and a floor. Press A (space) to throw it up.

scene.setBackgroundColor(9)
let ball = sprites.create(img`
. 2 2 .
2 2 2 2
2 2 2 2
. 2 2 .
`, SpriteKind.Player)
ball.setPosition(80, 20)
ball.ay = 300
game.onUpdate(function () {
if (ball.bottom > 100) {
ball.bottom = 100
ball.vy = 0
}
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
ball.vy = -150
})
bottom is the y of the sprite's bottom edge (choose it in the dropdown of the x block). There is no ground in an empty Arcade game, so the program builds one with an if.
Engine note. Arcade can do the floor for you. A tilemap is a game world drawn from squares (tiles) in the tile editor; tiles marked as walls stop sprites by themselves. That is why platformers suit Arcade so well. This course builds the floor by hand first: a wall is this if, done by the engine.
A sprite starts still (vy 0) with ay 300. Gravity adds 300 to vy every second. Fill in vy.
| seconds | vy (speed down) |
|---|---|
| 0 | 0 |
| 0.5 | |
| 1 | |
| 2 |
The ball is thrown up: vy is set to -150, with ay 300. How many seconds until it stops rising (vy is 0)?
Make A throw the ball higher.
In on A pressed, change -150 to -220.
Change ay. What does ay 100 feel like? And ay 600?
Change ay: try 100 for the Moon, 600 for a heavy planet.
Pick the pair (throw and gravity) you like best.
Throw the ball higher: an upward speed of -220.
This ticks by itself when your blocks do what is asked.

let bug: Sprite = null
function spawnEnemy (speed: number) {
bug = sprites.create(img`
. . 7 7 . .
. 7 7 7 7 .
7 7 f 7 f 7
. 7 7 7 7 .
`, SpriteKind.Enemy)
bug.setPosition(150, randint(10, 110))
bug.vx = speed
}
game.onUpdateInterval(1000, function () {
spawnEnemy(-40)
})
Make an apple drop. The basket moves along the bottom:
A timer (on game update every 1000 ms) makes an apple of kind Food at the top, at a random x.
Give each apple gravity: set apple ay to 150, inside the timer.
A Player–Food overlap: destroy the apple and change score by 1.
An apple drop: a timer drops an apple with gravity every second, and catching one scores.
This ticks by itself when your blocks do what is asked.
This acrobat never stops bouncing: the floor sets vy to -180 instead of 0. Make the bounces higher, then make the trampoline a little higher up the screen (both numbers in the if must change).
Students give a sprite gravity (acceleration down), see that a fall speeds up and a throw rises, slows and comes back, and use gravity in a catching game. About 40 minutes.
Open the teacher guide: answers, solutions, slides and a worksheet.
Velocity (vx, vy) is how far the engine moves a sprite every frame. Acceleration (ay) is how much the engine changes the velocity: with ay 300, vy grows by 300 every second, a little each frame. So a sprite with ay falls faster and faster, like a dropped ball. A throw or jump is a speed upwards: vy = -150 (negative, because y counts down). Gravity slows it, stops it at the top, and brings it back down. Nothing in an empty Arcade game is solid, so the lesson's program builds a floor with an if in on game update. Jumping only from the ground is next lesson. Tilemaps (wall tiles) do the floor for you in real platformers.
Gravity as acceleration, not a speed. Ask what vy is after one second, then after two.
Stretch: Make some apples heavier (bigger ay) and worth more points.
Support: Give students the timer that makes apples, and ask them only to add ay and the catch.
Next lesson: a jump that only works from the ground. Skillmaps: Jungle Jump Platformer and Monster Truck Racer (arcade.makecode.com/skillmaps) practise gravity and jumping with tilemaps.