Skip to content

Commit

Permalink
funcional
Browse files Browse the repository at this point in the history
  • Loading branch information
CatalinaCorrea-png committed Oct 2, 2024
1 parent c56e586 commit 49cc8ad
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 34 deletions.
25 changes: 14 additions & 11 deletions dinoGame.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ object juego{
}

method jugar(){
if (dino.estaVivo())
dino.saltar()
else {
if (dino.estaVivo()) {
dino.saltar()
} else {
game.removeVisual(gameOver)
self.iniciar()
}

}

method terminar(){
method terminar() {
game.addVisual(gameOver)
cactus.detener()
reloj.detener()
Expand Down Expand Up @@ -87,9 +87,10 @@ object cactus {
}

method chocar(){
game.onCollideDo(self, {dino => juego.terminar()})
if(self.position() == dino.position()) juego.terminar()
}
method detener(){

method detener(){
game.removeTickEvent("moverCactus")
}
}
Expand All @@ -103,14 +104,17 @@ object suelo{

object dino {
var vivo = true
var inAir = false
var property position = game.at(1,suelo.position().y())

method image() = "dino.png"

method saltar(){
if (!self.restriccion()){
keyboard.space().onPressDo({ self.subir() })
game.schedule(200, {self.bajar()})
if (self.estaEnSuelo() && !inAir){
inAir = true
self.subir()
game.schedule(700, {self.bajar()})
game.schedule(750, {inAir = false})
}
}

Expand All @@ -120,7 +124,6 @@ object dino {

method bajar(){
position = position.down(1)
//game.removeTickEvent("bajar")
}
method morir(){
game.say(self,"¡Auch!")
Expand All @@ -133,6 +136,6 @@ object dino {
return vivo
}

method restriccion() = position.y().max(2)
method estaEnSuelo() = suelo.position().y() == self.position().y()

}
Loading

0 comments on commit 49cc8ad

Please sign in to comment.