Skip to content

Commit

Permalink
Limites del mapa (sujeto a modificaciones) ewe
Browse files Browse the repository at this point in the history
  • Loading branch information
CeDimotta27 committed Oct 10, 2024
1 parent af5758e commit bd82d2b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
34 changes: 33 additions & 1 deletion homero.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,54 @@ object puntosHomero {

}

/* NO ANDA JAJA
object mapMoves {
const limitRightPosition = new MutablePosition (x=14, y=0)
const limitLeftPosition = new MutablePosition (x=0, y=0)
method movimiento(){
if (homero.position != limitLeftPosition){
homero.position.goLeft(homero.velocidad)
}
if (homero.position != limitRightPosition)
{
homero.position.goRight(homero.velocidad)
}
}
}
*/

object homero{
var puntos = 0
var velocidad = 1
const position = new MutablePosition(x=7, y=0)
const limitRightPosition = new MutablePosition (x=14, y=0)
const limitLeftPosition = new MutablePosition (x=0, y=0)

method image() = "homero.png"
method position() = position

//
method moverseIzquierda(){
if(position != limitLeftPosition)
position.goLeft(velocidad)
}
}

method moverseDerecha(){
if(position != limitRightPosition){
position.goRight(velocidad)
}
}
//

/*
method moverseIzquierda(){
position.goLeft(velocidad)
}
method moverseDerecha(){
position.goRight(velocidad)
}
*/
method alterarPuntos(nuevosPuntos){
puntos += nuevosPuntos
puntos = puntos.max(0)
Expand Down
5 changes: 2 additions & 3 deletions main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ program homeroGame{
game.onCollideDo(homero, {banana => homero.alterarVelocidad(banana.velocidad())})
game.onCollideDo(homero, {banana => game.removeVisual(banana)})


keyboard.a().onPressDo({ homero.moverseIzquierda()})
keyboard.d().onPressDo({ homero.moverseDerecha()})
keyboard.a().onPressDo({homero.moverseIzquierda()})
keyboard.d().onPressDo({homero.moverseDerecha()})

game.start()
}

0 comments on commit bd82d2b

Please sign in to comment.