From 6c2a3e3a6f7d60175d1ed925b96be76dc124f8d4 Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Thu, 11 Jul 2024 16:44:31 -0700 Subject: [PATCH] Rename some single letter variables --- libs/game/spritemap.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libs/game/spritemap.ts b/libs/game/spritemap.ts index 08d9ba449..c05eb02b0 100644 --- a/libs/game/spritemap.ts +++ b/libs/game/spritemap.ts @@ -32,9 +32,11 @@ namespace sprites { * @param sprite */ overlaps(sprite: Sprite): Sprite[] { - const n = this.neighbors(sprite); - const o = n.filter(neighbor => sprite.overlapsWith(neighbor)); - return o; + const potentialNeighbors = this.neighbors(sprite); + const neighbors = potentialNeighbors.filter(neighbor => + sprite.overlapsWith(neighbor) + ); + return neighbors; } draw(camera: scene.Camera) { @@ -43,9 +45,9 @@ namespace sprites { for (let y = 0; y < this.rowCount; ++y) { const left = x * this.cellWidth - camera.drawOffsetX; const top = y * this.cellHeight - camera.drawOffsetY; - const k = this.key(left, top); - const b = this.buckets[k]; - if (b && b.length) + const key = this.key(left, top); + const bucket = this.buckets[key]; + if (bucket && bucket.length) screen.drawRect( left, top, @@ -101,9 +103,9 @@ namespace sprites { } private insertAtKey(x: number, y: number, sprite: Sprite) { - const k = this.key(x, y); - let bucket = this.buckets[k]; - if (!bucket) bucket = this.buckets[k] = []; + const key = this.key(x, y); + let bucket = this.buckets[key]; + if (!bucket) bucket = this.buckets[key] = []; if (bucket.indexOf(sprite) < 0) bucket.push(sprite); }