Skip to content

Commit

Permalink
Saltar
Browse files Browse the repository at this point in the history
  • Loading branch information
luchoetapia committed Oct 3, 2024
1 parent 33b676b commit 529d7a5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
9 changes: 6 additions & 3 deletions main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import wollok.game.*

import morcilla.*

program MorcillaGame {
program MorcillaGame {
game.title("La Bizarra Aventura de MORCILLA")
game.height(32)
game.width(32)
game.cellSize(64)
game.width(64)
game.cellSize(100)

game.addVisual(morcilla)

// Mover a morcilla
keyboard.d().onPressDo({ morcilla.caminarDerecha(1) })
keyboard.a().onPressDo({ morcilla.caminarIzquierda(1) })
keyboard.space().onPressDo({ morcilla.saltar(2000) })

game.start()
}
30 changes: 29 additions & 1 deletion morcilla.wlk
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
import wollok.game.*

object morcilla {
var property position = new MutablePosition(x=0, y=2)
var saltando = false

method image() = "morcilla.png"
method image() = "morcilla256.png"

method caminarDerecha(pasos) {
position.goRight(pasos)
}

method caminarIzquierda(pasos) {
position.goLeft(pasos)
}

method saltar(duracion) {
if (!saltando) {
saltando = true
const tiempo = duracion / 10

game.schedule(tiempo * 0, { position.goUp(1) })
game.schedule(tiempo * 1, { position.goUp(1) })
game.schedule(tiempo * 2, { position.goUp(1) })
game.schedule(tiempo * 3, { position.goUp(1) })
game.schedule(tiempo * 4, { position.goUp(1) })

game.schedule(tiempo * 5, { position.goDown(1) })
game.schedule(tiempo * 6, { position.goDown(1) })
game.schedule(tiempo * 7, { position.goDown(1) })
game.schedule(tiempo * 8, { position.goDown(1) })
game.schedule(tiempo * 9, { position.goDown(1) })

game.schedule(tiempo * 9.5, { saltando = false })
}
}

}

0 comments on commit 529d7a5

Please sign in to comment.