-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
elin-winter
committed
Nov 12, 2024
1 parent
1f6d96f
commit 22b7282
Showing
7 changed files
with
165 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import characters.* | ||
import config.* | ||
import visualCarteles.* | ||
|
||
|
||
// -------------------------------- Direcciones | ||
|
||
class Direction { | ||
const unidadMovimiento = 1 | ||
|
||
method puedeMoverse(character, nuevaPosicion) = | ||
character.estaDentroDelMarco(nuevaPosicion) && character.puedeDesplazarse(nuevaPosicion) | ||
|
||
method calcularNuevaPosicion(personaje) | ||
|
||
method actualizarPosicion(personaje, nuevaPosicion) | ||
} | ||
|
||
object left inherits Direction { | ||
override method calcularNuevaPosicion(character) = | ||
character.position().left(unidadMovimiento) | ||
|
||
override method actualizarPosicion(character, _) { | ||
character.position().goLeft(unidadMovimiento) | ||
} | ||
} | ||
|
||
object right inherits Direction { | ||
override method calcularNuevaPosicion(character) = | ||
character.position().right(unidadMovimiento) | ||
|
||
override method actualizarPosicion(character, _) { | ||
character.position().goRight(unidadMovimiento) | ||
} | ||
} | ||
|
||
object up inherits Direction { | ||
override method calcularNuevaPosicion(character) = | ||
character.position().up(unidadMovimiento) | ||
|
||
override method actualizarPosicion(character, _) { | ||
character.position().goUp(unidadMovimiento) | ||
} | ||
} | ||
|
||
object downCharacter inherits Direction { | ||
override method puedeMoverse(character, nuevaPosicion) = true | ||
|
||
override method calcularNuevaPosicion(character) = | ||
character.position().down(unidadMovimiento) | ||
|
||
override method actualizarPosicion(character, nuevaPosicion) { | ||
|
||
self.listaCharcos().anyOne().puedeMorirPersonaje(character, nuevaPosicion) //obtenemos un charco random ya que el control de si puede morir o no esta en el charco | ||
|
||
if (self.posicionValida(character, nuevaPosicion)) { | ||
character.position().goDown(unidadMovimiento) | ||
} else { | ||
character.jumping(false) // evitar doble salto | ||
} | ||
|
||
return | ||
} | ||
|
||
method posicionValida(character, nuevaPosicion) = | ||
character.estaDentroDelMarco(nuevaPosicion) && character.puedeAtravesar(nuevaPosicion) | ||
|
||
method listaCharcos() = settings.objNivelActual().charcos() | ||
} | ||
|
||
object down inherits Direction { | ||
override method puedeMoverse(character, nuevaPosicion) = true | ||
|
||
override method calcularNuevaPosicion(character) = | ||
character.position().down(unidadMovimiento) | ||
|
||
override method actualizarPosicion(character, _) { | ||
character.position().goDown(unidadMovimiento) | ||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.