Atölye › Doodle Jump Tarzı Tırmanış › 20/24. adım
Birazdan farklı türde platformlar olacak: hareket eden, kırılan... Her platforma bir kind (tür) ve bir yatay hız
vx veriyoruz; rengini de türüne göre bir tablodan bakıyoruz. Şimdilik tek tür var: normal.
```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]
```const COLORS = { normal: '#16a34a' } → türden renge bir tablo.kind: 'normal', vx: 0 → her platformun türü ve yatay hızı (şimdilik hareketsiz).const platform = { ... } → yeni platformu önce bir değişkende tutup sonra listeye ekliyoruz; sonraki adımlarda
eklemeden önce onu değiştireceğiz.ctx.fillStyle = COLORS[p.kind] → rengi türüne göre tablodan al. Artık döngünün içinde, çünkü her platform farklı
renkte olabilir.MAX_GAP satırının altına COLORS satırını yaz.reset'teki platforma ve fillPlatforms'taki yeni platforma kind: 'normal', vx: 0 ekle; fillPlatforms'ta
platformu önce const platform değişkenine koy, sonra platforms.push(platform).draw içinde ctx.fillStyle = '#16a34a' satırını sil; döngünün içine ctx.fillStyle = COLORS[p.kind] yaz.Beceriler: Oyun durumları
← En iyi skor Hareketli platformlar →