Skip to content

Commit

Permalink
faltan cosas de plataforma, (muertes no andan), faltan puertas comple…
Browse files Browse the repository at this point in the history
…tamente
  • Loading branch information
tomassagrada committed Oct 14, 2024
1 parent 22acfaf commit d98570f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 49 deletions.
Binary file removed assets/C_game_over.png
Binary file not shown.
Binary file added assets/E_boton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 16 additions & 17 deletions characters.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import config.*

class Character {

// Referencias
// -------------------- Referencias

var property position
var property oldPosition
Expand All @@ -17,10 +17,15 @@ class Character {

const nivelActual

// -------------------- Métodos

// Métodos Sobrescritos en las Subclases

method image() = ""
method tipo() = ""
method tipo() = ""
method setupControls() {}

// Métodos Propios

method setPosition (posX, posY){
position = new MutablePosition(x=posX, y=posY)
Expand All @@ -29,11 +34,10 @@ class Character {
method colision(personaje) {} // Para que no genere error si colisionan entre personajes

method esColisionable () = true // Para los bordes y pisos

// ------------ Movimientos

method esAtravesable () = true

// Movimientos

method moveLeft() {
const nuevaPosicion = [position.left(unidadMovimiento).x(), position.y()]

Expand Down Expand Up @@ -83,8 +87,6 @@ class Character {
game.onTick(100, "Gravedad", {self.moveDown()})
}

method setupControls() {}

method setupCollisions() {
game.onCollideDo(self, {element => element.colision(self)})
}
Expand All @@ -101,27 +103,24 @@ class Character {

method die (){
//game.sound("S_muerte.mp3").play()
//game.addVisual(muerte)
//game.sound("S_game_over.mp3").play()
//game.schedule(3000,{game.removeVisual(muerte)})
game.addVisual(muerte)
game.sound("S_game_over.mp3").play()
game.schedule(3000,{game.removeVisual(muerte)})
game.schedule(3000, {nivelActual.start()}) // Reiniciamos el nivel
// RESTART LEVEL1
}



}

class Fireboy inherits Character {

method puntaje() = puntos

override method tipo() = fuego

override method image() {
return "P_Fireboy.png"
}

method puntaje() = puntos

override method setupControls(){
keyboard.left().onPressDo ({ self.moveLeft() })
keyboard.right().onPressDo ({ self.moveRight() })
Expand All @@ -131,6 +130,8 @@ class Fireboy inherits Character {

class Watergirl inherits Character {

method puntaje() = puntos

override method tipo() = agua

override method image() {
Expand All @@ -142,8 +143,6 @@ class Watergirl inherits Character {
keyboard.d().onPressDo ({ self.moveRight() })
keyboard.w().onPressDo ({ self.jump() })
}

method puntaje() = puntos
}

object fuego {}
Expand Down
39 changes: 24 additions & 15 deletions config.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import elements.*

object settings {

// Referencias
// ---------------------- Referencias
const niveles = [level1, level2]
var nivelActual = 0 // Índice del nivel actual

// Métodos
// ---------------------- Métodos

method init (background, height, width, cellSize){
game.title("FireBoyWaterGirlGame")
game.boardGround(background)
Expand All @@ -17,7 +18,7 @@ object settings {
game.start()
}

method checkLevelCompletion(level) {
method checkLevelCompletion(level) {
game.schedule(100, {
if(level.isLevelComplete()) {
//game.addVisual(nivelSuperado)
Expand All @@ -29,6 +30,8 @@ object settings {
})
}



method pasarSgteNivel(){
nivelActual += 1
if (nivelActual < niveles.size()) { // Avanza al siguiente nivel
Expand All @@ -39,7 +42,7 @@ object settings {
game.schedule(5000,{game.removeVisual(nivelSuperado)})

niveles.get(nivelActual).start()
self.checkLevelCompletion(niveles.get(nivelActual))
self.checkLevelCompletion(niveles.get(nivelActual))

} /*else { // Todos los niveles completados
Expand All @@ -56,7 +59,7 @@ class Level {
// ---------------- JUEGO PRINCIPAL

method start() {
game.clear()
//game.clear()
self.setupElements() // Bloques, palancas, plataformas, etc.
self.setupDiamonds()
self.setupCharacters()
Expand All @@ -77,9 +80,9 @@ class Level {
(0..28).forEach { y => positions.add([38, y]) }
}

method setupPositions(){}

// Métodos Sobrescritos en los Niveles

method setupPositions(){}
method setupDiamonds() {}
method setupElements () {}
method setupCharcos() {}
Expand All @@ -97,6 +100,8 @@ object level1 inherits Level {
const fireboy = new Fireboy(position = new MutablePosition (x=16, y=18), oldPosition = new MutablePosition (x=16, y=18), nivelActual = self, zonasProhibidas = zonasProhibidasFuego, invalidPositions = positions) //Depende del nivel
const watergirl = new Watergirl(position = new MutablePosition (x=24, y=1), oldPosition = new MutablePosition (x=24, y=1), nivelActual = self, zonasProhibidas = zonasProhibidasAgua, invalidPositions = positions) //Depende del nivel

// Lista de Posiciones prohibidas y diamantes

const zonasProhibidasFuego = []
const zonasProhibidasAgua = []
const diamantes = []
Expand All @@ -109,7 +114,7 @@ object level1 inherits Level {
const botonAmarillo = new Boton(posX = 10, posY = 9, plataformaAsoc = plataformaAmarilla)

const botonInvAmarillo1 = new BotonInvisible(posX = 11, posY = 9, botonAsoc = botonAmarillo)
const botonInvAmarillo2 = new BotonInvisible(posX = 11, posY = 9, botonAsoc = botonAmarillo)
const botonInvAmarillo2 = new BotonInvisible(posX = 9, posY = 9, botonAsoc = botonAmarillo)


const plataformaBordo = new PlataformaMovible(posX = 34, posY = 13, maxAltura = 16, minAltura = 13)
Expand All @@ -121,9 +126,6 @@ object level1 inherits Level {
const botonInvBordoB1 = new BotonInvisible(posX = 31, posY = 18, botonAsoc = botonBordoB)
const botonInvBordoB2 = new BotonInvisible(posX = 29, posY = 18, botonAsoc = botonBordoB)




// --------------------- Métodos

// Métodos Sobrescritos
Expand Down Expand Up @@ -151,19 +153,26 @@ object level1 inherits Level {

override method setupElements() {
game.addVisual(new Caja(position = new MutablePosition (x=13, y=18)))

game.addVisual(puertaFireboy)
game.addVisual(puertaWatergirl)

game.addVisual(plataformaAmarilla)

game.addVisual(botonAmarillo)

game.addVisual(botonInvAmarillo1)
game.addVisual(botonInvAmarillo2)

game.addVisual(plataformaBordo)

game.addVisual(botonBordoA)
game.addVisual(botonBordoB)

game.addVisual(botonInvBordoA1)
game.addVisual(botonInvBordoA2)
game.addVisual(botonInvBordoB1)
game.addVisual(botonInvBordoB2)

}

override method setupCharcos() {
Expand Down Expand Up @@ -206,7 +215,7 @@ object level1 inherits Level {
}

override method isLevelComplete() =
self.posicionIgual(fireboy, puertaFireboy) and self.posicionIgual(watergirl, puertaWatergirl)
self.posicionIgual(fireboy, puertaFireboy) and self.posicionIgual(watergirl, puertaWatergirl)


// Métodos Propios
Expand Down Expand Up @@ -238,6 +247,6 @@ object muerte{
object nivelSuperado{
method position() = game.center()
method image() = "F_Nivel_Superado.png"
method text1() {Fireboy.puntaje()}
method text2() {Watergirl.puntaje()}
// method text1() {Fireboy.puntaje()}
// method text2() {Watergirl.puntaje()}
}
52 changes: 36 additions & 16 deletions elements.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ class BotonInvisible {
const posY
const botonAsoc

method esAtravesable() = true
method esColisionable() = true

method position() = game.at(posX, posY)

method colision(personaje) {
botonAsoc.personajeMovido()
botonAsoc.personajeMovido(personaje)
}

}
Expand All @@ -118,30 +121,36 @@ class Boton {
const posX
const posY
const plataformaAsoc
const unidadMovimiento = 1
var enColision = false


method esAtravesable() = false
method esColisionable() = true

method position() = game.at(posX, posY)

method colision(personaje){
enColision = true
if(plataformaAsoc.hastaMaxAltura())
plataformaAsoc.goUp(unidadMovimiento)

enColision = false
if(personaje.position() == self.position()) {
if(self.hastaMaxAltura()) {
plataformaAsoc.moveUp()
game.schedule(100, {self.colision(personaje)})
}
}
}

method personajeMovido() {
if(plataformaAsoc.hastaMinAltura() and !enColision) {
plataformaAsoc.goDown(unidadMovimiento)
self.personajeMovido()
method personajeMovido(personaje) {

if(personaje.position() != self.position()) {
if(self.hastaMinAltura()) {
plataformaAsoc.moveDown()
game.schedule(100, {self.personajeMovido(personaje)})
}
}
}

method image() = "E_button.png"
method image() = "E_cube.png"

method hastaMaxAltura() = plataformaAsoc.position().y() != plataformaAsoc.maxAltura()
method hastaMinAltura() = plataformaAsoc.position().y() == plataformaAsoc.minAltura()
method hastaMinAltura() = plataformaAsoc.position().y() != plataformaAsoc.minAltura()
}

// ------------------ Plataforma Movible
Expand All @@ -152,15 +161,26 @@ class PlataformaMovible {
const posY
const maxAltura
const minAltura

const position = new MutablePosition(x=posX, y=posY)
const unidadMovimiento = 1

method maxAltura() = maxAltura
method minAltura() = minAltura

method position() = game.at(posX, posY)
method position() = position

method colision(personaje) {}

method esAtravesable() = false
method esColisionable() = true

method moveUp() {
position.goUp(unidadMovimiento)
}

method moveDown() {
position.goDown(unidadMovimiento)
}

method image() = "E_horizontal_gate.png"

Expand Down
2 changes: 1 addition & 1 deletion main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ program FireBoyWaterGirlGame {

// Mecanica del Juego
level1.start()
settings.checkLevelCompletion(level1)
settings.checkLevelCompletion(level1)

}

0 comments on commit d98570f

Please sign in to comment.