diff --git a/public/assets/hoe/projection-check.js b/public/assets/hoe/projection-check.js index 4023132..edd4d67 100644 --- a/public/assets/hoe/projection-check.js +++ b/public/assets/hoe/projection-check.js @@ -3,12 +3,12 @@ const layer1 = ecs.get(1).TileLayers.layer(1) const filtered = [] -for (let i = 0; i < projected.length; ++i) { +for (const position of projected) { if ( - [1, 2, 3, 4, 6].includes(layer0.tile(projected[i])) - && ![7].includes(layer1.tile(projected[i])) + [1, 2, 3, 4, 6].includes(layer0.tile(position)) + && ![7].includes(layer1.tile(position)) ) { - filtered.push(projected[i]) + filtered.push(position) } } diff --git a/public/assets/hoe/start.js b/public/assets/hoe/start.js index d5487e1..3dc4325 100644 --- a/public/assets/hoe/start.js +++ b/public/assets/hoe/start.js @@ -88,7 +88,7 @@ if (projected?.length > 0) { for (let i = 0; i < 2; ++i) { Sound.play('/assets/hoe/dig.wav'); - for (let i = 0; i < projected.length; ++i) { + for (const {x, y} of projected) { Emitter.emit({ ...dirtParticles, behaviors: [ @@ -98,8 +98,8 @@ if (projected?.length > 0) { config: { type: 'rect', data: { - x: projected[i].x * layer.tileSize.x, - y: projected[i].y * layer.tileSize.y, + x: x * layer.tileSize.x, + y: y * layer.tileSize.y, w: layer.tileSize.x, h: layer.tileSize.y, } @@ -114,8 +114,8 @@ if (projected?.length > 0) { await wait(0.1) } - for (let i = 0; i < projected.length; ++i) { - TileLayers.layer(1).stamp(projected[i], [[7]]) + for (const position of projected) { + TileLayers.layer(1).stamp(position, [[7]]) } Controlled.locked = 0; diff --git a/public/assets/shit-shack/collision-start.js b/public/assets/shit-shack/collision-start.js index 56747c9..a945243 100644 --- a/public/assets/shit-shack/collision-start.js +++ b/public/assets/shit-shack/collision-start.js @@ -1,19 +1,16 @@ -for (let i = 0; i < intersections.length; ++i) { - if (intersections[i][0].tags) { - if (intersections[i][0].tags.includes('door')) { - if (other.Player) { - ecs.switchEcs( - other, - entity.Ecs.path, - { - Position: { - x: 72, - y: 304, - }, +for (const [{tags}] of intersections) { + if (tags && tags.includes('door')) { + if (other.Player) { + ecs.switchEcs( + other, + entity.Ecs.path, + { + Position: { + x: 72, + y: 304, }, - ); - } + }, + ); } } } - diff --git a/public/assets/tomato-seeds/projection-check.js b/public/assets/tomato-seeds/projection-check.js index fe05dab..00422ae 100644 --- a/public/assets/tomato-seeds/projection-check.js +++ b/public/assets/tomato-seeds/projection-check.js @@ -2,9 +2,9 @@ const layer = ecs.get(1).TileLayers.layer(1) const filtered = [] -for (let i = 0; i < projected.length; ++i) { - const x0 = projected[i].x * layer.tileSize.x; - const y0 = projected[i].y * layer.tileSize.y; +for (const position of projected) { + const x0 = position.x * layer.tileSize.x; + const y0 = position.y * layer.tileSize.y; const entities = Array.from(ecs.system('Colliders').within({ x0, x1: x0 + layer.tileSize.x - 1, @@ -12,15 +12,14 @@ for (let i = 0; i < projected.length; ++i) { y1: y0 + layer.tileSize.y - 1, })); let hasPlant = false; - for (let j = 0; j < entities.length; ++j) { - if (entities[j].Plant) { + for (const {Plant} of entities) { + if (Plant) { hasPlant = true } } if (!hasPlant) { - const tile = layer.tile(projected[i]) - if ([7].includes(tile)) { - filtered.push(projected[i]) + if ([7].includes(layer.tile(position))) { + filtered.push(position) } } } diff --git a/public/assets/tomato-seeds/start.js b/public/assets/tomato-seeds/start.js index 9a02eda..eaa3241 100644 --- a/public/assets/tomato-seeds/start.js +++ b/public/assets/tomato-seeds/start.js @@ -129,7 +129,7 @@ if (projected?.length > 0) { Sprite.animation = ['idle', direction].join(':'); const promises = []; - for (let i = 0; i < projected.length; ++i) { + for (const {x, y} of projected) { promises.push(ecs.create({ ...plant, Plant: { @@ -137,8 +137,8 @@ if (projected?.length > 0) { growthFactor: Math.floor(Math.random() * 256), }, Position: { - x: projected[i].x * layer.tileSize.x + (0.5 * layer.tileSize.x), - y: projected[i].y * layer.tileSize.y + (0.5 * layer.tileSize.y), + x: x * layer.tileSize.x + (0.5 * layer.tileSize.x), + y: y * layer.tileSize.y + (0.5 * layer.tileSize.y), }, })) } diff --git a/public/assets/watering-can/projection-check.js b/public/assets/watering-can/projection-check.js index 448c189..bc43924 100644 --- a/public/assets/watering-can/projection-check.js +++ b/public/assets/watering-can/projection-check.js @@ -2,10 +2,9 @@ const layer = ecs.get(1).TileLayers.layer(1) const filtered = [] -for (let i = 0; i < projected.length; ++i) { - const tile = layer.tile(projected[i]) - if ([7].includes(tile)) { - filtered.push(projected[i]) +for (const position of projected) { + if ([7].includes(layer.tile(position))) { + filtered.push(position) } } diff --git a/public/assets/watering-can/start.js b/public/assets/watering-can/start.js index e285eb0..d8fddb0 100644 --- a/public/assets/watering-can/start.js +++ b/public/assets/watering-can/start.js @@ -80,7 +80,7 @@ if (projected?.length > 0) { Sound.play('/assets/watering-can/water.wav'); for (let i = 0; i < 2; ++i) { - for (let i = 0; i < projected.length; ++i) { + for (const {x, y} of projected) { Emitter.emit({ ...waterParticles, behaviors: [ @@ -90,8 +90,8 @@ if (projected?.length > 0) { config: { type: 'rect', data: { - x: projected[i].x * layer.tileSize.x, - y: projected[i].y * layer.tileSize.y - (layer.tileSize.y * 0.5), + x: x * layer.tileSize.x, + y: y * layer.tileSize.y - (layer.tileSize.y * 0.5), w: layer.tileSize.x, h: layer.tileSize.y, } @@ -103,8 +103,8 @@ if (projected?.length > 0) { await wait(0.25); } - for (let i = 0; i < projected.length; ++i) { - const tileIndex = layer.area.x * projected[i].y + projected[i].x + for (const {x, y} of projected) { + const tileIndex = layer.area.x * y + x let w; if (Water.water[tileIndex]) { w = Water.water[tileIndex]