Skip to content

Commit

Permalink
Primeros pasos de boss fight
Browse files Browse the repository at this point in the history
Co-authored-by: Bruno <[email protected]>
  • Loading branch information
Juanter134 and bcochon committed Oct 16, 2024
1 parent 4891a9a commit f8509da
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 49 deletions.
Binary file added assets/stock_fondo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 73 additions & 36 deletions entorno.wlk
Original file line number Diff line number Diff line change
@@ -1,45 +1,82 @@
import wollok.game.*
import morcilla.*

// =============================================== COLISIONES ===============================================
class Colisiones {
const property position

method image() = "celda_gris.png"
}

const colision0 = new Colisiones(position = new Position(x=0, y=1))
const colision1 = new Colisiones(position = new Position(x=1, y=1))
const colision2 = new Colisiones(position = new Position(x=2, y=1))
const colision3 = new Colisiones(position = new Position(x=3, y=1))
const colision4 = new Colisiones(position = new Position(x=4, y=1))
const colision5 = new Colisiones(position = new Position(x=5, y=1))
const colision6 = new Colisiones(position = new Position(x=6, y=1))
const colision7 = new Colisiones(position = new Position(x=7, y=1))
const colision8 = new Colisiones(position = new Position(x=8, y=1))
const colision9 = new Colisiones(position = new Position(x=9, y=1))
const colision10 = new Colisiones(position = new Position(x=10, y=1))
const colision11 = new Colisiones(position = new Position(x=11, y=1))
const colision12 = new Colisiones(position = new Position(x=12, y=1))
const colision13 = new Colisiones(position = new Position(x=13, y=1))
const colision14 = new Colisiones(position = new Position(x=14, y=1))
const colision15 = new Colisiones(position = new Position(x=15, y=1))
const colision16 = new Colisiones(position = new Position(x=16, y=1))
const colision17 = new Colisiones(position = new Position(x=17, y=1))
const colision18 = new Colisiones(position = new Position(x=18, y=1))
const colision19 = new Colisiones(position = new Position(x=19, y=1))
const colision20 = new Colisiones(position = new Position(x=20, y=1))
const colision21 = new Colisiones(position = new Position(x=21, y=1))
const colision22 = new Colisiones(position = new Position(x=22, y=1))
const colision23 = new Colisiones(position = new Position(x=23, y=1))
const colision24 = new Colisiones(position = new Position(x=24, y=1))
const colision25 = new Colisiones(position = new Position(x=25, y=1))
const colision26 = new Colisiones(position = new Position(x=26, y=1))
const colision27 = new Colisiones(position = new Position(x=27, y=1))
const colision28 = new Colisiones(position = new Position(x=28, y=1))
const colision29 = new Colisiones(position = new Position(x=29, y=1))
const colision30 = new Colisiones(position = new Position(x=30, y=1))
const colision31 = new Colisiones(position = new Position(x=31, y=1))

object jefeInteractuable{
const property position = new Position(x=16, y=2)


// =============================================== VISUALES ===============================================
class Visual {
const property position
const property image
}

const cartelAtaque = new Visual (position = new Position(x=10, y=20), image = "celda_gris.png")


// =============================================== BOSSFIGHTS ===============================================
class BossFight {
const property jefe

method image() = "celda_roja.png"
method iniciarPelea() {
game.boardGround("arena_de_jefe.png")
self.habilitarAtaque()
}

method habilitarAtaque() {
morcilla.posicionDeAtaque()
game.addVisual(cartelAtaque)
keyboard.e().onPressDo({self.gestionarAtaque()})
}

method gestionarAtaque() {
game.removeVisual(cartelAtaque)

const duracionCinematica = 2000
morcilla.atacar()
jefe.disminuirVida()

if(jefe.vida() > 0)
game.schedule(duracionCinematica, { self.etapaDefensa() })
else
self.finalizarBatalla()
}

method etapaDefensa() {
morcilla.activarMovimiento()

const duracionTurnoJefe = 15000
jefe.ataque()
game.schedule(duracionTurnoJefe, { self.habilitarAtaque() })
}

method finalizarBatalla() {

}
}

const bossFightDePrueba = new BossFight(jefe = jefeDePrueba)



// =============================================== JEFES ===============================================
class JefeInteractuable{
const property position
const property image
var property vida = 3

method disminuirVida(){
vida = (vida - 1).max(0)
}
method ataque(){

}
}

// const jefeDePrueba = new JefeInteractuable(position = new Position(x=16, y=2), image() = "celda_roja.png")
const jefeDePrueba = new JefeInteractuable(position = new Position(x=16, y=2), image = "celda_roja.png")
11 changes: 8 additions & 3 deletions main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ import entorno.*

program MorcillaGame {
game.title("La Bizarra Aventura de MORCILLA")
game.boardGround("stock_fondo.jpg")
game.height(32)
game.width(32)
game.cellSize(100)

game.addVisual(jefeInteractuable)
game.addVisual(jefeDePrueba)

game.addVisual(morcilla)

// Mover a morcilla
keyboard.d().onPressDo({ morcilla.caminarDerecha(1) })
keyboard.a().onPressDo({ morcilla.caminarIzquierda(1) })
keyboard.space().onPressDo({ morcilla.saltar(2000) })
keyboard.space().onPressDo({ morcilla.saltar(1000) })

game.whenCollideDo(morcilla, {nose => game.say(morcilla, "Estas colisionando")})
keyboard.l().onPressDo({ game.boardGround("arena_de_jefe.png") })

keyboard.j().onPressDo({ bossFightDePrueba.iniciarPelea() })

game.whenCollideDo(morcilla, {jefe => game.say(jefeDePrueba, "Estas colisionando")})

game.start()
}
63 changes: 53 additions & 10 deletions morcilla.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,79 @@ import wollok.game.*

object morcilla {
var property position = new MutablePosition(x=0, y=2)
var property vidas = 5
var property puedeAtacar = false

var saltando = false
var suspendido = false
var caerActivo = false
var movimientoActivo = true

method image() = "morcilla256.png"
method saltando() = saltando

method caminarDerecha(pasos) {
position.goRight(pasos)
if(movimientoActivo)
position.goRight(pasos)

// FALTA EVALUAR SI QUEDA SUSPENDIDO
self.caer()
}

method caminarIzquierda(pasos) {
position.goLeft(pasos)
if(movimientoActivo)
position.goLeft(pasos)

// FALTA EVALUAR SI QUEDA SUSPENDIDO
self.caer()
}

method saltar(duracion) {
if (!saltando) {
if (!suspendido && movimientoActivo) {
saltando = true
const tiempo = duracion / 10
suspendido = true
const tiempo = duracion / 5

game.schedule(tiempo * 0, { position.goUp(1) })
game.schedule(tiempo * 1, { position.goUp(1) })
game.schedule(tiempo * 2, { position.goUp(1) })
game.schedule(tiempo * 3, { position.goUp(1) })
game.schedule(tiempo * 4, { position.goUp(1) })

game.schedule(tiempo * 5, { position.goDown(1) })
game.schedule(tiempo * 6, { position.goDown(1) })
game.schedule(tiempo * 7, { position.goDown(1) })
game.schedule(tiempo * 8, { position.goDown(1) })
game.schedule(tiempo * 9, { position.goDown(1) })
game.schedule(tiempo * 5, { saltando = false })
game.schedule(tiempo * 5, { self.caer() })
}
}

method gravedad() {
if (position.y() > 2 && !saltando) {
// Está cayendo o saltando
position.goDown(1)
suspendido = true
}
else if (!saltando) {
// Ya cayó
game.removeTickEvent("gravedad")
suspendido = false
caerActivo = false
}
}

game.schedule(tiempo * 9.5, { saltando = false })
method caer() {
if(!caerActivo && suspendido){
game.onTick(100, "gravedad", {self.gravedad()})
caerActivo = true
}
}

method atacar() {

}

method posicionDeAtaque() {
movimientoActivo = false
position = new MutablePosition (x=16, y=2)
}

method activarMovimiento() {movimientoActivo = true}
}

0 comments on commit f8509da

Please sign in to comment.