Agregar pantalla de perdida
This commit is contained in:
parent
aca00b6bb2
commit
583468bf7f
3 changed files with 24 additions and 2 deletions
|
@ -38,7 +38,7 @@ export function createJugandoState(): State {
|
||||||
export function update(juego: Juego<State>, dt: number) {
|
export function update(juego: Juego<State>, dt: number) {
|
||||||
juego.state.time -= dt
|
juego.state.time -= dt
|
||||||
if (juego.state.time < 0) {
|
if (juego.state.time < 0) {
|
||||||
// TODO: convertir en baldoza
|
(juego as Juego<any>).state = { current: "lose" }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/lose.ts
Normal file
15
src/lose.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { Juego } from './main'
|
||||||
|
import { drawText } from './utils'
|
||||||
|
|
||||||
|
export type State = {
|
||||||
|
current: "lose"
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update(juego: Juego<State>, dt: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
export function draw(juego: Juego<State>, timestamp: number) {
|
||||||
|
drawText(juego, '¡Te convirtieron en baldosa!',
|
||||||
|
{ x: juego.canvas.width / 2, y: 100 },
|
||||||
|
{ bold: true, size: 3, align: 'center' })
|
||||||
|
}
|
|
@ -3,10 +3,11 @@ import './style.css'
|
||||||
import * as welcome from "./welcome"
|
import * as welcome from "./welcome"
|
||||||
import * as jugando from "./jugando"
|
import * as jugando from "./jugando"
|
||||||
import * as win from "./win"
|
import * as win from "./win"
|
||||||
|
import * as lose from "./lose"
|
||||||
import { Assets, loadAssets } from './assets'
|
import { Assets, loadAssets } from './assets'
|
||||||
import { loadSprite, Sprite } from './sprite'
|
import { loadSprite, Sprite } from './sprite'
|
||||||
|
|
||||||
export type State = welcome.State | jugando.State | win.State
|
export type State = welcome.State | jugando.State | win.State | lose.State
|
||||||
|
|
||||||
export type Juego<T extends State> = {
|
export type Juego<T extends State> = {
|
||||||
canvas: HTMLCanvasElement
|
canvas: HTMLCanvasElement
|
||||||
|
@ -29,6 +30,9 @@ function update(juego: Juego<any>, dt: number) {
|
||||||
case "win":
|
case "win":
|
||||||
win.update(juego, dt)
|
win.update(juego, dt)
|
||||||
break
|
break
|
||||||
|
case "lose":
|
||||||
|
lose.update(juego, dt)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +50,9 @@ function draw(juego: Juego<any>, timestamp: number) {
|
||||||
case "win":
|
case "win":
|
||||||
win.draw(juego, timestamp)
|
win.draw(juego, timestamp)
|
||||||
break
|
break
|
||||||
|
case "lose":
|
||||||
|
lose.draw(juego, timestamp)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue