-
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.
añadi posible tienda, generador de plantas y junte
funciones de movimiento del cursor dentro de un solo metodo
- Loading branch information
1 parent
7cce3a8
commit ed302e2
Showing
8 changed files
with
127 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import wollok.game.* | ||
|
||
object cursor { | ||
var property position = new MutablePosition(x=7, y=3) | ||
var property vida = 3 // Le doy una propiedad vida para que reciba daño cuando choca con un zombie | ||
|
||
method perderVida(danio) { vida -= danio} | ||
|
||
method image() = "marcoRojo.png" | ||
|
||
method accion(){ | ||
keyboard.right().onPressDo({ self.moverseDerecha() }) | ||
keyboard.left().onPressDo({ self.moverseIzquierda() }) | ||
keyboard.up().onPressDo({ self.moverseArriba() }) | ||
keyboard.down().onPressDo({ self.moverseAbajo() }) | ||
} | ||
|
||
method moverseDerecha() = if (self.position().x()<14) position.goRight(1) | ||
method moverseIzquierda() = if (self.position().x()>0) position.goLeft(1) | ||
method moverseArriba() = if (self.position().y()<4) position.goUp(1) | ||
method moverseAbajo() = if (self.position().y()>0) position.goDown(1) | ||
|
||
method noEstaViva() = vida < 0 | ||
|
||
method morir(){ | ||
if (self.noEstaViva()){ game.say(self, "Durisimo Helmano")} // Delego la resonsabilidad de morir a pepita | ||
} | ||
} |
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,22 @@ | ||
import plantas.* | ||
object generadorDePlantas { | ||
var nombrePlanta = 0 /*asigno el nombre a los enemigos que voy creando segun numeros, asi puedo crear nombres nuevos | ||
automaticamente*/ | ||
|
||
const plantas = #{}/*contiene cada enemigo que fue creando*/ | ||
|
||
method nombre() = nombrePlanta /*para poder consultar el ultimo nombre usado*/ | ||
method sumarPlanta() { /*suma 1 a nombre enemigo para asi crear enemigos nuevos, luego hay que hacer la funcion para que reste 1 cuando maten a un enemigo*/ | ||
nombrePlanta+=1 | ||
} | ||
method generarPlanta(planta, posicion){/*segun el numero ingresado, se generara un tipo de enemigo distinto*/ | ||
var nombreParaPlanta = self.nombre() /* esto esta hecho porque sino wollok se enoja,para poder crear un enemigo*/ | ||
if (planta=="papa") | ||
nombreParaPlanta = new Papa(position= posicion) | ||
else if (planta=="guisante") | ||
nombreParaPlanta = new Guisante(position= posicion) | ||
plantas.add(nombreParaPlanta)/*se añade a la lista de enemigos activos*/ | ||
return game.addVisual(nombreParaPlanta)/*muestra al enemigo en el juego*/ | ||
|
||
} | ||
} |
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,33 @@ | ||
import generadorDePlantas.* | ||
import plantas.* | ||
import cursor.* | ||
|
||
object menu { | ||
const position = new MutablePosition(x=0, y=5) | ||
method position() = position | ||
|
||
var property imagen = "marcoRojo.png" | ||
method image() = imagen | ||
|
||
method accion(){ | ||
keyboard.d().onPressDo({self.moverseDerecha()}) | ||
keyboard.a().onPressDo({self.moverseIzquierda()}) | ||
keyboard.enter().onPressDo({self.generarPlanta()}) | ||
} | ||
method moverseDerecha() = if (self.position().x()<6) position.goRight(1) | ||
method moverseIzquierda() = if (self.position().x()>0) position.goLeft(1) | ||
method generarPlanta(){ | ||
const plantaAgenerar = game.colliders(self) // no usamos uniqueColliders porque tira error si no hay ninguna | ||
const plantaSeleccionada = plantaAgenerar.first().tipo() | ||
const posicion = game.at(cursor.position().x(),cursor.position().y()) | ||
generadorDePlantas.generarPlanta(plantaSeleccionada,posicion) | ||
} | ||
|
||
method iniciarTienda(){ | ||
const papaTienda = new Papa(position = game.at(0,5)) | ||
game.addVisual(papaTienda) | ||
const guisanteTienda = new Guisante(position = game.at(1,5)) | ||
game.addVisual(guisanteTienda) | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
class Papa{ | ||
const position | ||
const property tipo = "papa" | ||
var property vida=100 | ||
method position() = position | ||
var property imagen = "golondrina.png" | ||
method image() = imagen | ||
|
||
method recibeDanio(danio) { | ||
self.vida(self.vida() - danio) | ||
} | ||
} | ||
|
||
class Guisante{ | ||
const position | ||
const property tipo = "guisante" | ||
var property vida=100 | ||
method position() = position | ||
var property imagen = "zombie.png" | ||
method image() = imagen | ||
|
||
method recibeDanio(danio) { | ||
self.vida(self.vida() - danio) | ||
} | ||
} | ||
const pepe = new Guisante (position=game.at(0,0)) |
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