Senses
Can get keyboard presses (if on a computer instead of a mobile device)
senses → on key pressed("right") do sprite → move(10, 0) end
- Put the keyboard key inside the quotes
Can get accelerometer input
board → on every frame do var acc := senses → acceleration quick sprite → set speed(acc → x * 100, acc → y * 100) end
The acc variable is a vector with x and y components that are numbers between 0 and 1 that represent the amount of device tilt in the x and y directions
Swipe Input
In addition to taps, can get swipes
sprite → on swipe(swiped) where swiped(x: Number, y: Number, delta x: Number, delta y: Number is sprite → set speed(delta x * 10, delta y * 10) end end
- x and y are the location of the start of the swipe
delta x and delta y are the direction and speed of the swipe
Score, Lives, and Timer
Can change score (number at the top of the window)
game → add score(1) game → set score(0)
- Set the score to negative to hide it
Can change number of lives (hearts at the top of the window)
game → add life(1) game → remove life(1) game → set life(0)
- When there are 0 lives the game automatically ends
If not using the lives, can hide them
game → set life visible(false)
- Can add a countdown timer
- Counts down to zero
The game automatically ends when timer reaches zero
game → start countdown timer(30)
Can add time by starting the timer again with more time
game → start countdown timer(game → current time + 10)
Obstacle
In addition to sprites, can add obstacles, lines, that sprites can interact with
var obstacle := board → create obstacle(0, 0, 100, 100, 1)
- First two numbers are the x and y coordinates of one endpoint
- Second two numbers are the distance right and down of the second end point
The last number is the elasticity, the amount a sprite bounces when it hits