Skip to content

Commit

Permalink
mejoras
Browse files Browse the repository at this point in the history
  • Loading branch information
brisabrussa28 committed Oct 13, 2024
1 parent 762c69a commit 454d5db
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 53 deletions.
Binary file removed assets/goku.png
Binary file not shown.
Binary file added assets/goku2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions example.wlk → jugador.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ object helado {
position = game.at(posicion.x(), posicion.y())
}
}
/*
method mover(){
keyboard.w().onPressDo {position.up(2)}
keyboard.a().onPressDo {position.left(2)}
keyboard.s().onPressDo {position.down(2)}
keyboard.d().onPressDo {position.right(2)}
}
*/
method image() = "goku.png"

method image() = "goku2.png"

method recolectar(fruta){
game.removeVisual(fruta)
Expand Down
49 changes: 5 additions & 44 deletions mainExample.wpgm
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
import wollok.game.*

import example.*
import jugador.*

import muros.*

object posicionAleatoria {
method generarPosX() = 1.randomUpTo(39).truncate(0)
method generarPosY() = 1.randomUpTo(20).truncate(0)

method generarPosicionAleatoria(){
const x = self.generarPosX()
const y = self.generarPosY()

if(escenario.mismaPosicion(game.at(x, y))){
return self.generarPosicionAleatoria()
}
escenario.enlistarObjeto(game.at(x, y))
return game.at(x, y)
}
}

class Fruta{
var property position = posicionAleatoria.generarPosicionAleatoria()

method image(){
if(points.frutasObtenidas() < 10){
return "banana.png"
}if(points.frutasObtenidas() < 20){
return "uva2.png"
}
return "sandia.png"
}

method esFruta() = true
method dibujar(){
game.addVisual(self)
}
}

object juego{
const frutas = [new Fruta(), new Fruta(),new Fruta(),new Fruta(),new Fruta(),new Fruta(),new Fruta(),new Fruta(),new Fruta(),new Fruta()]
method dibujarFrutas(){
frutas.forEach({fruta_n => fruta_n.dibujar()})
}
}
import puntos.*

object fondo_de_pausa{
var property position = game.origin()
Expand All @@ -65,7 +26,7 @@ program BadIceCreamGame {
//dibujar escenario
escenario.generarEscenario()
//dibujar frutas
juego.dibujarFrutas()
spawn.dibujarFrutas()
//dibujar puntos
game.addVisual(points)
//dibujar helado
Expand All @@ -80,10 +41,10 @@ program BadIceCreamGame {
points.sumarFrutas()
}
if(points.frutasObtenidas() == 10){
juego.dibujarFrutas()
spawn.dibujarFrutas()
}
if(points.frutasObtenidas()==20){
juego.dibujarFrutas()
spawn.dibujarFrutas()
}
if(points.frutasObtenidas() == 30){
game.removeVisual(helado)
Expand Down
42 changes: 42 additions & 0 deletions puntos.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import jugador.*
import muros.*
class Fruta{
var property position = posicionAleatoria.generarPosicionAleatoria()

method image(){
if(points.frutasObtenidas() < 10){
return "banana.png"
}if(points.frutasObtenidas() < 20){
return "uva2.png"
}
return "sandia.png"
}

method esFruta() = true
method ubicarYDibujar(posicion){
self.position(posicion)
game.addVisual(self)
}
}

object spawn{
method dibujarFrutas(){
(0..9).forEach({x => new Fruta().ubicarYDibujar(posicionAleatoria.generarPosicionAleatoria())})
}
}

object posicionAleatoria {
method generarPosX() = 1.randomUpTo(game.width() - 1).truncate(0)
method generarPosY() = 1.randomUpTo(game.height() - 1).truncate(0)

method generarPosicionAleatoria(){
const x = self.generarPosX()
const y = self.generarPosY()

if(escenario.mismaPosicion(game.at(x, y))){
return self.generarPosicionAleatoria()
}
escenario.enlistarObjeto(game.at(x, y))
return game.at(x, y)
}
}

0 comments on commit 454d5db

Please sign in to comment.