Movimiento a partir de tiempo

This commit is contained in:
Nulo 2021-06-27 14:52:23 +00:00
parent 2c70605ba1
commit a7ceb02333

View file

@ -18,12 +18,12 @@ export function createJugandoState() {
export function updateJugando(juego, dt) { export function updateJugando(juego, dt) {
juego.state.velocity.x = 0 juego.state.velocity.x = 0
if (juego.keyboard.keys.d) { if (juego.keyboard.keys.d) {
juego.state.velocity.x += 20 juego.state.velocity.x += 200
} }
if (juego.keyboard.keys.a) { if (juego.keyboard.keys.a) {
juego.state.velocity.x -= 20 juego.state.velocity.x -= 200
} }
juego.state.pos.x += juego.state.velocity.x juego.state.pos.x += (dt / 1000) * juego.state.velocity.x
} }
function drawBackground(juego, y, height, img) { function drawBackground(juego, y, height, img) {