game: merge interface and arena state

This commit is contained in:
He4eT 2025-06-05 17:30:09 +02:00
commit 348eb78bb8

28
game.js
View file

@ -24,18 +24,18 @@ let currentStage = 'mainMenu'
// State // State
let interface = {
arenaX: 7,
arenaY: 7,
spriteSize: 7,
spriteHalfSize: 3,
}
let arena = { let arena = {
// Screen position
x: 7,
y: 7,
// Bounds
top: 0, top: 0,
right: 225, right: 225,
bottom: 89, bottom: 89,
left: 0, left: 0,
// Sprite size
spriteSize: 7,
spriteHalfSize: 3,
} }
let player = { let player = {
@ -54,24 +54,24 @@ function mainMenu() {
currentStage = 'gameplay' currentStage = 'gameplay'
} }
const title = 'Morse Pit'
const instruction = 'Press any key to start'
cls(0) cls(0)
const title = 'Morse Pit'
print(title, 12, 12, 3, false, 2) print(title, 12, 12, 3, false, 2)
const instruction = 'Press any key to start'
print(instruction, 12, 30, 4) print(instruction, 12, 30, 4)
} }
// Gameover // Gameover
function gameover() { function gameover() {
const title = 'Game Over'
cls(0) cls(0)
drawEnemies() drawEnemies()
drawPlayer() drawPlayer()
const title = 'Game Over'
print(title, 12, 12, 10, false, 2) print(title, 12, 12, 10, false, 2)
} }
@ -141,8 +141,8 @@ function drawSprite(spriteIndex, x, y) {
const colorkey = 0 const colorkey = 0
spr( spr(
spriteIndex, spriteIndex,
interface.arenaX + x - interface.spriteHalfSize, arena.x + x - arena.spriteHalfSize,
interface.arenaY + y - interface.spriteHalfSize, arena.y + y - arena.spriteHalfSize,
colorkey, colorkey,
) )
} }