Skip to content

Commit

Permalink
modificaciones en tests, setters de posiciones en comidas
Browse files Browse the repository at this point in the history
  • Loading branch information
acorromolas11 committed Nov 6, 2024
1 parent f3d1b12 commit eb954be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions comida.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class Comida{
var property velocidad
const tipoAvance = aLaDerecha

var position = new MutablePosition(x=(0..8).anyOne()*2, y=16)
var position = new MutablePosition(x=(0..game.width()).anyOne()*2, y=game.height())

method image() = nombre + ".png"
method position() = position

method positionX(nueva_pos_x){
position = new MutablePosition(x=nueva_pos_x, y=16)
position = new MutablePosition(x=nueva_pos_x, y=game.height())
}

method bajar(){
Expand Down Expand Up @@ -63,12 +63,12 @@ object aLaDerecha{

object aLaIzquierda{
method moverseAtras(posicion){
if(posicion.x() <= game.width() - 3 && posicion.x() + 1 <= game.width() - 2)
if(posicion.x() <= game.width() - 3)
posicion.goRight(1)
}

method moverseAdelante(posicion){
if(posicion.x() >= 1 && posicion.x() - 1 >= 0)
if(posicion.x() >= 1)
posicion.goLeft(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion homero.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import niveles.*
object homero{
var puntos = 0
var velocidad = 1
var position = new MutablePosition(x=game.width()/2, y=0)
var position = new MutablePosition(x=(game.width()/2).roundUp(), y=0)
var ultimaComida = rosquilla

method velocidad() = velocidad
Expand Down
24 changes: 19 additions & 5 deletions pruebas.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe "homero" {
// TODO: Si quieren chequear igualdad, deben usar .equals

test "Homero inicia en la posicion x=mitad de la pantalla, y=0" {
assert.equals(homero.position().x(), game.width()/2)
assert.equals(homero.position().x(), (game.width()/2).roundUp())
assert.equals(homero.position().y(), 0)
}

Expand All @@ -32,16 +32,30 @@ describe "homero" {
assert.equals(homero.puntos(),0)
}

test "Cuando homero esta borracho, si se mueve para la derecha va para la izquierda"{
const posicion_anterior = homero.position().x()
homero.come(cerveza)
homero.moverseDerecha()
assert.equals(homero.position().x(),posicion_anterior-1)
}

test "Cuando homero esta borracho, si se mueve para la izquierda va para la derecha"{
homero.positionX(1)
const posicion_anterior = homero.position().x()
homero.come(cerveza)
homero.moverseIzquierda()
assert.equals(homero.position().x(),game.width()/2+1)
assert.equals(homero.position().x(),posicion_anterior+1)
}

test "Cuando homero esta borracho, si se mueve para la derecha va para la izquierda"{

test "los puntos de homero aumentan correctamente"{
homero.come(cerveza)
homero.moverseDerecha()
assert.equals(homero.position().x(),game.width()/2-1)
assert.that(homero.puntos()>0)
}

test "la velocidad de homero aumenta correctamente"{
homero.come(rosquilla)
assert.that(homero.velocidad()>1)
}


Expand Down

0 comments on commit eb954be

Please sign in to comment.