Learn by Building Workshop Skills GitHub Türkçe Workshop › Angry Birds-style Slingshot › Step 33 of 47
Pigs What we are doing The pigs arrive: green, round and fragile (25 hp). One sits on the beam, one on the ground; the stone block leaves
the level. pigs() returns the pigs still in the game.
```js
pig: { color: '#65a30d', density: 1, hp: 25 },
const LEVEL = [
['wood', 380, 230, 12, 60], ['wood', 440, 230, 12, 60], ['wood', 370, 218, 94, 12], ['pig', 406, 196, 22, 22],
['pig', 480, 268, 22, 22],
]
const pigs = () => bodies.filter((b) => b.kind === 'pig')
if (b.kind === 'pig' || b.kind === 'bird') {
```What it means
pig is a new material: as light as wood but with only 25 hp.
The level's fourth row is a pig on the beam (196 + 22 = 218, the beam's top), the fifth a pig on the ground.
pigs() filters the bodies down to the pigs.
Pigs are drawn as circles, like the bird.
Your turn
In MATERIALS, under stone, write the pig line.
In LEVEL, replace the stone row with the two pigs.
Under mass write pigs.
In draw, change the circle condition to b.kind === 'pig' || b.kind === 'bird'.
Skills: Game states
← Things break Score →
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