Skip to content

Commit

Permalink
El juego se comporta lento pero compila.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed May 25, 2024
1 parent 0e4a0e6 commit 8d4d9d3
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 114 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@

Juego hecho con Wollok-Game. Ayuda a Orson a salir de la granja!

Wollok v1.5.2
### Instrucciones

- Usa las flechas del teclado para mover a Orson. Y la tecla 'H' para pedirle alguna ayuda.
- Ayúdalo a comprarse un tractor para que pueda salir de la granja.

> NOTA: por el momento el juego tiene problemas de performance. Estaremos solucionándolo próximamente.
3 changes: 2 additions & 1 deletion arbustos.wlk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Arbusto {
const image = "arbusto.png"
const property image = "arbusto.png"
var property position
}

class ArbustoArriba inherits Arbusto {
Expand Down
1 change: 1 addition & 0 deletions cultivos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const tomate = new Especie(nombre = "tomate",precio = 50)

object maizEjemplo inherits Cultivo(especie = maiz ) {
override method oroGanado() = 150
var property position = new Position(x = 3, y = 2)

override method image() = "maiz_adulto.png"
}
50 changes: 31 additions & 19 deletions elementos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,49 @@ import wollok.game.*
import exceptions.*
import cultivos.*

object bolsa inherits Elemento(game.at(2,9), "bolsa.png") {

method usate(plantador) { plantador.planta(self.cultivo()) }
object bolsa inherits Elemento (
posicionInicial = game.at(2, 9),
image = "bolsa.png"
) {
method usate(plantador) {
plantador.planta(self.cultivo())
}

method cultivo() = [new Cultivo(especie = trigo), new Cultivo(especie = maiz), new Cultivo(especie = tomate)].anyOne()
method cultivo() = [
new Cultivo(especie = trigo),
new Cultivo(especie = maiz),
new Cultivo(especie = tomate)
].anyOne()
}

object regadera inherits Elemento(game.at(9,2), "regadera.png") {

method usate(regador) { regador.rega() }
object regadera inherits Elemento (
posicionInicial = game.at(9, 2),
image = "regadera.png"
) {
method usate(regador) {
regador.rega()
}
}

object espada inherits Elemento(game.at(2,2), "espada.png") {

method usate(cosechador) { cosechador.cosecha() }
object espada inherits Elemento (
posicionInicial = game.at(2, 2),
image = "espada.png"
) {
method usate(cosechador) {
cosechador.cosecha()
}
}

class Elemento {
const property image
const _posicionInicial
var property position
const posicionInicial
var property position

constructor(posicionInicial, _imagen) {
image = _imagen
_posicionInicial = posicionInicial
method initialize() {
position = posicionInicial
}

method soltar() {
position = _posicionInicial
method soltar() {
position = posicionInicial
}


}
7 changes: 4 additions & 3 deletions exceptions.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ object methodNotImplemented inherits Exception (message = "Falta implementar el
}
*/
class MethodNotImplemented inherits Exception {
var methodName
var aObject
override method message() = "Falta implementar el método '" + methodName + "' en " + aObject
const methodName
const anObject

override method message() = "Falta implementar el método '" + methodName + "' en " + anObject

}
22 changes: 11 additions & 11 deletions factories.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import visuales.*
import arbustos.*

object arbustoFactory {
method draw(arbusto, posicion) {
posicion.drawElement(arbusto)
game.whenCollideDo(arbusto, { g => arbusto.empuja(g) })
method draw(arbusto) {
game.addVisual(arbusto)
game.whenCollideDo(arbusto, { elemento => arbusto.empuja(elemento) })
}

method drawVerticalBlock(x, y) {
self.draw(new ArbustoDerecha(), new Position(x=x, y=y))
self.draw(new ArbustoDerecha(), new Position(x=x, y=y+1))
self.draw(new ArbustoIzquierda(), new Position(x=x+1, y=y))
self.draw(new ArbustoIzquierda(), new Position(x=x+1, y=y+1))
self.draw(new ArbustoDerecha(position = new Position(x=x, y=y)))
self.draw(new ArbustoDerecha(position = new Position(x=x, y=y+1)))
self.draw(new ArbustoIzquierda(position = new Position(x=x+1, y=y)))
self.draw(new ArbustoIzquierda(position = new Position(x=x+1, y=y+1)))
}

method drawHorizontalBlock(x, y) {
self.draw(new ArbustoArriba(), new Position(x=x, y=y))
self.draw(new ArbustoArriba(), new Position(x=x+1, y=y))
self.draw(new ArbustoAbajo(), new Position(x=x, y=y+1))
self.draw(new ArbustoAbajo(), new Position(x=x+1, y=y+1))
self.draw(new ArbustoArriba(position = new Position(x=x, y=y)))
self.draw(new ArbustoArriba(position = new Position(x=x+1, y=y)))
self.draw(new ArbustoAbajo(position = new Position(x=x, y=y+1)))
self.draw(new ArbustoAbajo(position = new Position(x=x+1, y=y+1)))
}
}
10 changes: 5 additions & 5 deletions granero.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ object granero {
* las posiciones.
*/
method planta(_cultivo) {
throw new MethodNotImplemented(methodName= "planta", aObject = self)
throw new MethodNotImplemented(methodName= "planta", anObject = self)
}


/*
* Debe hacer crecer todos los cultivos que plantó el granero
*/
method rega() {
throw new MethodNotImplemented(methodName="rega", aObject = self)
throw new MethodNotImplemented(methodName="rega", anObject = self)
}


/*
* Debe cosechar todos los cultivos que plantó el granero
*/
method cosecha() {
throw new MethodNotImplemented(methodName="cosecha", aObject = self)
throw new MethodNotImplemented(methodName="cosecha", anObject = self)
}


Expand All @@ -38,8 +38,8 @@ object granero {


method borde() {
var x = position.x()
var y = position.y()
const x = position.x()
const y = position.y()
return [
new Position(x=x-1,y=y-1),
new Position(x=x,y=y-1),
Expand Down
7 changes: 3 additions & 4 deletions granjero.wlk
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import cultivos.*
import elementos.*
import exceptions.*

object granjero {
var oro = 0
var property position
var property position = new Position(x = 0, y = 0)
/*
* Este método debe retornar la cantidad de oro que posee el granjero.
*/
Expand All @@ -18,15 +17,15 @@ object granjero {
* Para cosechar un cultivo basta con enviarle el mensaje 'cosechate()'.
*/
method cosecha(cultivo) {
throw new MethodNotImplemented(methodName="cosecha", aObject = self)
throw new MethodNotImplemented(methodName="cosecha", anObject = self)
}


/*
* Al regar un cultivo éste crece. Mientras más crezca, más oro dará cuando se coseche.
*/
method rega(cultivo) {
throw new MethodNotImplemented(methodName="rega", aObject = self)
throw new MethodNotImplemented(methodName="rega", anObject = self)
}


Expand Down
Loading

0 comments on commit 8d4d9d3

Please sign in to comment.