Skip to content

Commit

Permalink
idea base realizada
Browse files Browse the repository at this point in the history
  • Loading branch information
ramirob03 committed Oct 16, 2024
1 parent a3ad7dd commit 5927bfc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Binary file added assets/carretera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 34 additions & 10 deletions example.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,46 @@ object juegoDeAutos {
game.width(9)
game.height(10)
game.cellSize(50)
game.boardGround("freeway_1.jpg")
game.boardGround("carretera.png")
game.addVisualCharacter(auto)
game.addVisual(obstaculo)
game.addVisual(contador)
game.addVisual(contadorNafta)

keyboard.left().onPressDo({ auto.moverIzquierda() })
keyboard.right().onPressDo({ auto.moverDerecha() })

game.onTick(2000, "moverse", {obstaculo.moverseHaciaAbajo()
game.onTick(5000, "moverse", {obstaculo.moverseHaciaAbajo()
contador.aumentarPuntos()
auto.perderNafta()
if (auto.nafta <= 0) game.stop()
contadorNafta.perderNafta()
if (contadorNafta.nafta <= 0) game.stop()
})
}
}

object auto {
var nafta = 100
var position = game.at(1, 0)
var position = game.at(1, 2)

method nafta() = nafta

method image() = "porsche.png"

method perderNafta() {
nafta -= 2
nafta = nafta - 2
}

method position() = position

method moverIzquierda() {
if (position.x() > 1) {
if (position.x() > 0) {
position = game.at(position.x() - 1, position.y())
}
}


method moverDerecha() {
if (position.x() < game.width() - 2) {
if (position.x() < game.width() - 1) {
position = game.at(position.x() + 1, position.y())
}
}
Expand Down Expand Up @@ -100,13 +103,34 @@ object contador {
var puntos = 0
const property celeste = "279df5cc"

method position () = game.at(5, 9)
method position () = game.at(7, 9)

method aumentarPuntos() {
puntos += 10
}

method text() = "Puntos: " + puntos
method text() = " Puntos: " + puntos
method textColor() = celeste

}

object contadorNafta {
var nafta = 100

method perderNafta() {
if (nafta > 0){
nafta = nafta - 2
} else {
game.stop()
}

}

const property celeste = "279df5cc"

method position () = game.at(0, 0)

method text() = " Nafta: " + nafta
method textColor() = celeste

}

0 comments on commit 5927bfc

Please sign in to comment.