mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: add scores
This commit is contained in:
parent
bc645e9361
commit
7f5fd8d147
1 changed files with 6 additions and 1 deletions
7
game.js
7
game.js
|
|
@ -80,6 +80,7 @@ const arena = {
|
||||||
/** @type {Player} */
|
/** @type {Player} */
|
||||||
const player = {
|
const player = {
|
||||||
state: 'default',
|
state: 'default',
|
||||||
|
score: 0,
|
||||||
key: {
|
key: {
|
||||||
history: '',
|
history: '',
|
||||||
buffer: '',
|
buffer: '',
|
||||||
|
|
@ -185,7 +186,7 @@ function drawArena() {
|
||||||
function drawInterface() {
|
function drawInterface() {
|
||||||
drawMorse(player.key.buffer, 102, 123, 15, 36)
|
drawMorse(player.key.buffer, 102, 123, 15, 36)
|
||||||
|
|
||||||
print('0', 145, 121, 6)
|
print(player.score, 145, 121, 6)
|
||||||
print(player.key.history.padStart('13'), 18, 121, 6, true)
|
print(player.key.history.padStart('13'), 18, 121, 6, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -415,6 +416,7 @@ function spawnEnemies() {
|
||||||
const type = getType(arena.wave)
|
const type = getType(arena.wave)
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
|
value: 100,
|
||||||
letter: alphabet[rnd(0, alphabet.length - 1)],
|
letter: alphabet[rnd(0, alphabet.length - 1)],
|
||||||
positions: [getSpawnPosition(), getSpawnPosition()],
|
positions: [getSpawnPosition(), getSpawnPosition()],
|
||||||
dangerZone: getDangerZone(type),
|
dangerZone: getDangerZone(type),
|
||||||
|
|
@ -447,6 +449,7 @@ function destroyEnemiesByLetter(letter) {
|
||||||
enemies
|
enemies
|
||||||
.filter((enemy) => enemy.letter === letter)
|
.filter((enemy) => enemy.letter === letter)
|
||||||
.forEach((enemy) => {
|
.forEach((enemy) => {
|
||||||
|
player.score += enemy.value
|
||||||
const [type, frames] =
|
const [type, frames] =
|
||||||
destructionEffects[rnd(0, destructionEffects.length - 1)]
|
destructionEffects[rnd(0, destructionEffects.length - 1)]
|
||||||
|
|
||||||
|
|
@ -685,6 +688,7 @@ const BTN_Y = 7
|
||||||
*
|
*
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
* state: keyof typeof playerStates,
|
* state: keyof typeof playerStates,
|
||||||
|
* score: number,
|
||||||
* key: {
|
* key: {
|
||||||
* history: string,
|
* history: string,
|
||||||
* buffer: string,
|
* buffer: string,
|
||||||
|
|
@ -700,6 +704,7 @@ const BTN_Y = 7
|
||||||
* positions: Point[],
|
* positions: Point[],
|
||||||
* letter: string,
|
* letter: string,
|
||||||
* dangerZone: number,
|
* dangerZone: number,
|
||||||
|
* value: number,
|
||||||
* }} Enemy
|
* }} Enemy
|
||||||
*
|
*
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue