Skip to content

Commit

Permalink
Algunos test del mapa y del jugador
Browse files Browse the repository at this point in the history
  • Loading branch information
Miranda-03 committed Oct 30, 2024
1 parent c57febf commit d7f4533
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
1 change: 1 addition & 0 deletions enemigos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Enemigo1{
method image() = apariencia

method soyBloque() = false
method esFruta() = false

var property vector_movimiento = [0, 1, 0, 0]

Expand Down
1 change: 1 addition & 0 deletions jugador.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Jugador inherits FiguraConMovimiento(position = game.at(1, 1)) {
}

method soyBloque() = false
method esFruta() = false

method volver(){
if(sincronizadorDePantallas.pantallaActual() == "jugar"){
Expand Down
2 changes: 2 additions & 0 deletions miscelaneos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ object fondoJuego{
var property position = game.origin()
var property valor = "f_slime.png"
method image() = valor
method esFruta() = false
method soyBloque() = false
/*method image(){
if(jugador.image() == "helado.png"){
return "f_slime.png"
Expand Down
2 changes: 2 additions & 0 deletions muros.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Bloque{
var property position = game.center() //habrá que posicionar los limites
method image() = visual.valor()
method soyBloque() = true
method esFruta() = false
method ubicarYDibujar(posicion){
self.position(posicion)
game.addVisual(self)
Expand All @@ -17,6 +18,7 @@ class Bloque_mapa{
method image() = visual.valor()

method soyBloque() = true
method esFruta() = false

method Dibujar(){
game.addVisual(self)
Expand Down
75 changes: 71 additions & 4 deletions pruebas.wtest
Original file line number Diff line number Diff line change
@@ -1,9 +1,76 @@
import pepita.*
import muros.*
import wollok.game.*
import jugador.*
import puntos.*
import niveles.*

describe "group of tests for pepita" {
describe "gruop of test for the map"{

test "pepita has initial energy" {
assert.equals(100, pepita.energy())
method initialize(){
game.clear()
game.cellSize(40)
game.height(18)
game.width(18)
game.start()
nivel_1.iniciar_mapa()
}



test "Well allocated blocks on the map"{
assert.that(game.getObjectsIn(game.at(2, 2)).get(0).soyBloque())
assert.that(game.getObjectsIn(game.at(2, 3)).get(0).soyBloque())
assert.notThat(game.getObjectsIn(game.at(0, 0)).get(0).soyBloque())
}

test "Well allocated fruits on the map"{
assert.equals(10, game.allVisuals().count({element => element.esFruta()}))
}


}

describe "group of tests for the player" {

const jugador = new Jugador()

method initialize(){
game.clear()
game.cellSize(40)
game.height(18)
game.width(18)
game.start()
jugador.posicionate()
}

test "Player spaw is correct" {
assert.equals(game.at(1, 1), jugador.position())
}

test "Player collides to the left wall"{
jugador.position(game.at(0, 1))
assert.equals(game.at(1, 1), jugador.position())
}

test "Player collides to the right wall"{
jugador.position(game.at(20, 1))
assert.equals(game.at(1, 1), jugador.position())
}

test "Player collides to the top wall"{
jugador.position(game.at(1, 20))
assert.equals(game.at(1, 1), jugador.position())
}

test "Player collides to the bottom wall"{
jugador.position(game.at(1, 0))
assert.equals(game.at(1, 1), jugador.position())
}

/*test "Player can pick up a fruit"{
var fruta = new Fruta()
fruta.ubicarYDibujar(game.at(1, 1))
assert.equals(2, jugador.position())
}*/

}

0 comments on commit d7f4533

Please sign in to comment.