Workshop › Doodle Jump-style Climber › Step 20 of 24
Soon there will be several kinds of platform. Each one gets a kind and a sideways speed vx, and its color is looked
up in a table by its kind.
```js
const COLORS = { normal: '#16a34a' }
platforms = [{ x: 170, y: START_Y, w: 60, h: 12, kind: 'normal', vx: 0 }]
const platform = { x: Math.random() * (canvas.width - 60), y: highest, w: 60, h: 12, kind: 'normal', vx: 0 }
platforms.push(platform)
for (const p of platforms) {
ctx.fillStyle = COLORS[p.kind]
```COLORS maps a kind to a color; COLORS[p.kind] looks it up.MAX_GAP, write COLORS.kind: 'normal', vx: 0 to the platform in reset, and build the new platform in a variable in fillPlatforms.draw, pick each platform's color inside the loop.Skills: Game states
← Best score Moving platforms →