mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: extract SPRITE_HALF
This commit is contained in:
parent
06523e7ff4
commit
5a712d69c8
1 changed files with 4 additions and 10 deletions
14
game.js
14
game.js
|
|
@ -107,7 +107,6 @@ const arena = {
|
||||||
bottom: 105,
|
bottom: 105,
|
||||||
left: 0,
|
left: 0,
|
||||||
},
|
},
|
||||||
spriteHalfSize: 3,
|
|
||||||
wave: 0,
|
wave: 0,
|
||||||
waveSeed: 0,
|
waveSeed: 0,
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +371,7 @@ function spawnEnemies() {
|
||||||
|
|
||||||
const getSpawnPosition = (type) => {
|
const getSpawnPosition = (type) => {
|
||||||
const minDistance = enemyBlueprints[type].spawnDistance
|
const minDistance = enemyBlueprints[type].spawnDistance
|
||||||
const b = 4 * arena.spriteHalfSize
|
const b = 4 * SPRITE_HALF
|
||||||
let x, y, distance
|
let x, y, distance
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
@ -521,7 +520,7 @@ const effectRenderers = {
|
||||||
},
|
},
|
||||||
detection: ({ to, frames }) => {
|
detection: ({ to, frames }) => {
|
||||||
const color = frames.shift()
|
const color = frames.shift()
|
||||||
const w = arena.spriteHalfSize
|
const w = SPRITE_HALF
|
||||||
const d = frames.length + 2 * w
|
const d = frames.length + 2 * w
|
||||||
const corners = [
|
const corners = [
|
||||||
[+1, +1],
|
[+1, +1],
|
||||||
|
|
@ -672,12 +671,7 @@ function drawSprite(spriteIndex, x, y) {
|
||||||
const colorkey = 0
|
const colorkey = 0
|
||||||
const center = worldToScreen({ x, y })
|
const center = worldToScreen({ x, y })
|
||||||
|
|
||||||
spr(
|
spr(spriteIndex, center.x - SPRITE_HALF, center.y - SPRITE_HALF, colorkey)
|
||||||
spriteIndex,
|
|
||||||
center.x - arena.spriteHalfSize,
|
|
||||||
center.y - arena.spriteHalfSize,
|
|
||||||
colorkey,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function anyKeyPressed() {
|
function anyKeyPressed() {
|
||||||
|
|
@ -698,6 +692,7 @@ const HISTORY_Y = 118
|
||||||
const SCORE_X = 152
|
const SCORE_X = 152
|
||||||
const SCORE_Y = 125
|
const SCORE_Y = 125
|
||||||
const CODE_DISPLAY_W = 7
|
const CODE_DISPLAY_W = 7
|
||||||
|
const SPRITE_HALF = 3
|
||||||
|
|
||||||
/* Screen */
|
/* Screen */
|
||||||
const SCREEN_W = 240
|
const SCREEN_W = 240
|
||||||
|
|
@ -726,7 +721,6 @@ const BTN_Y = 7
|
||||||
* bottom: number,
|
* bottom: number,
|
||||||
* left: number,
|
* left: number,
|
||||||
* },
|
* },
|
||||||
* spriteHalfSize: number,
|
|
||||||
* wave: number,
|
* wave: number,
|
||||||
* waveSeed: number,
|
* waveSeed: number,
|
||||||
* }} Arena
|
* }} Arena
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue