mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: main menu
This commit is contained in:
parent
270996ff41
commit
da4171e50e
1 changed files with 33 additions and 9 deletions
42
game.js
42
game.js
|
|
@ -10,27 +10,44 @@ function TIC() {
|
||||||
gameStages[currentStage]()
|
gameStages[currentStage]()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stages */
|
// Stages
|
||||||
|
|
||||||
let currentStage = 'gameplay'
|
|
||||||
|
|
||||||
const gameStages = {
|
const gameStages = {
|
||||||
|
mainMenu,
|
||||||
gameplay,
|
gameplay,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* State */
|
let currentStage = 'mainMenu'
|
||||||
|
|
||||||
|
// State
|
||||||
|
|
||||||
let t = 0
|
let t = 0
|
||||||
let x = 96
|
let x = 96
|
||||||
let y = 24
|
let y = 24
|
||||||
|
|
||||||
/* Main Gameplay */
|
// Main Menu
|
||||||
|
|
||||||
|
function mainMenu() {
|
||||||
|
if ([BTN_A, BTN_B, BTN_X, BTN_Y].map(btn).some(Boolean)) {
|
||||||
|
currentStage = 'gameplay'
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = 'Morse Pit'
|
||||||
|
const instruction = 'Press any key to start'
|
||||||
|
|
||||||
|
cls(0)
|
||||||
|
|
||||||
|
print(title, 12, 12, 3, false, 2)
|
||||||
|
print(instruction, 12, 30, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gameplay
|
||||||
|
|
||||||
function gameplay() {
|
function gameplay() {
|
||||||
if (btn(0)) y--
|
if (btn(BTN_U)) y--
|
||||||
if (btn(1)) y++
|
if (btn(BTN_D)) y++
|
||||||
if (btn(2)) x--
|
if (btn(BTN_L)) x--
|
||||||
if (btn(3)) x++
|
if (btn(BTN_R)) x++
|
||||||
|
|
||||||
cls(13)
|
cls(13)
|
||||||
spr(1 + (((t % 60) / 30) | 0) * 2, x, y, 14, 3, 0, 0, 2, 2)
|
spr(1 + (((t % 60) / 30) | 0) * 2, x, y, 14, 3, 0, 0, 2, 2)
|
||||||
|
|
@ -38,6 +55,13 @@ function gameplay() {
|
||||||
t++
|
t++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
const [BTN_U, BTN_D, BTN_L, BTN_R, BTN_A, BTN_B, BTN_X, BTN_Y] = [
|
||||||
|
...Array(8).keys(),
|
||||||
|
]
|
||||||
|
|
||||||
// <TILES>
|
// <TILES>
|
||||||
// 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc
|
// 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc
|
||||||
// 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c
|
// 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue