Workshop › Angry Birds-style Slingshot › Step 2 of 47
Sky and ground
What we are doing
Behind the sling we paint a light blue sky over the whole canvas, then a green strip of ground from GROUND down.
```js
ctx.fillStyle = '#bae6fd'
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.fillStyle = '#65a30d'
ctx.fillRect(0, GROUND, canvas.width, canvas.height - GROUND)
// The sling and, while aiming, the pulled-back bird and the path it will take.
ctx.fillStyle = '#78350f'
```
What it means
- The sky: a rectangle from
(0, 0) as big as the canvas (canvas.width × canvas.height).
- The ground: from
x = 0, y = GROUND, the full width and canvas.height - GROUND (30) tall.
- The comment names everything this part of the drawing will show by the end of the game.
Your turn
Write the lines above ctx.fillStyle = '#78350f' (the sling post stays last), then press Run.
Skills: Drawing on a canvas
← The sling Draw it again and again →
All steps
- The sling
- Sky and ground
- Draw it again and again
- The aim: an angle and a pull
- A bird in the sling
- Pull the bird back
- The rubber band
- Aim with the arrow keys
- Bodies
- Launch!
- Move by the velocity
- Gravity
- Land on the ground
- Aiming or flying
- An empty sling in flight
- Gone off the screen
- Wait for calm
- The next bird
- See the path before you shoot
- From a point to an aim
- Grab the sling
- Drag and let go
- Wood and stone
- A level as data
- Push overlapping boxes apart
- Bounce by mass
- Every pair meets
- Friction
- Smaller steps
- Hit points
- Hard hits hurt
- Things break
- Pigs
- Score
- Show the score
- Cracks
- Three birds
- Count the birds
- Won or lost
- The end panel
- Play again
- Three levels of data
- Start any level
- On to the next level
- The best score
- The right words
- Build it yourself: the yellow bird