Skip to content

Commit

Permalink
Ataque de gokú V1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoSantinoValenzuelaMaltas committed Oct 28, 2024
1 parent 552df24 commit 8325673
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 8 deletions.
Binary file added assets/cell1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/goku_Kamehameha_Derecha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/goku_Kamehameha_Izquierda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kamehameha_Derecha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kamehameha_Izquierda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion enemigos.wlk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Enemigo1{
var property position = game.at(4,16)
var lado = 0
method image() = "piopio.png"
method image() = "cell1.png"

method moverseH(limite1, limite2){
game.onTick(500, self, {self.muevete(limite1, limite2)})
Expand Down
69 changes: 69 additions & 0 deletions jugador.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Jugador inherits FiguraConMovimiento(position = game.at(1, 1)) {
game.addVisualCharacter(self)
}

method volver(){
game.addVisualCharacter(self)
}

var property valor = "helado.png"

method image() = valor
Expand All @@ -25,12 +29,77 @@ class Jugador inherits FiguraConMovimiento(position = game.at(1, 1)) {
method eliminate(){
game.removeVisual(self)
}

method atacarDerecha() = new KamehamehaDerecha().energia(self.position(), "goku_Kamehameha_Derecha.png", 1)
method atacarIzquierda() = new KamehamehaIzquierda().energia(self.position(), "goku_Kamehameha_Izquierda.png", -1)
}

object datosJugador {
var property imagen = null
}

object gokuAtacando {
var property position = null
var property lado = null
method image() = lado
}

class KamehamehaDerecha{
var personaje = null

var property position = null

method image() = "kamehameha_Derecha.png"

method energia(posicion, lado, valor){
gokuAtacando.lado(lado)
gokuAtacando.position(posicion)
self.position(game.at(posicion.x() + valor, posicion.y()))
if(!escenario.mismaPosicion(self.position())){
game.addVisual(gokuAtacando)
personaje = game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head()
game.removeVisual(game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head())
game.addVisual(self)
game.schedule(500, {self.avanzar()})
}
}

method lugarValido() = escenario.mismaPosicion(self.position())

method avanzar(){
if(!escenario.mismaPosicion(game.at(self.position().x() + 1, self.position().y())) && self.position().x() + 1 < game.width() - 1){
self.position(game.at(self.position().x() + 1, self.position().y()))
game.schedule(500, {self.avanzar()})
}
else{
personaje.position(gokuAtacando.position())
personaje.volver()
self.eliminate()
}
}

method eliminate(){
game.removeVisual(gokuAtacando)
game.removeVisual(self)
}
}

class KamehamehaIzquierda inherits KamehamehaDerecha{
override method image() = "kamehameha_Izquierda.png"

override method avanzar(){
if(!escenario.mismaPosicion(game.at(self.position().x() - 1, self.position().y())) && self.position().x() - 1 > 0){
self.position(game.at(self.position().x() - 1, self.position().y()))
game.schedule(500, {self.avanzar()})
}
else{
personaje.position(gokuAtacando.position())
personaje.volver()
self.eliminate()
}
}
}

object points{
var frutasObtenidas = 0
method sumarFrutas(){
Expand Down
13 changes: 9 additions & 4 deletions mainExample.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ program BadIceCreamGame {
game.height(18)
game.width(18)
//Inicio menu
menuPersonaje.cargar()
//menuPersonaje.cargar()
new MenuPersonaje().cargar()
//inicio
game.start()

Expand All @@ -35,11 +36,15 @@ program BadIceCreamGame {
}
if(points.frutasObtenidas() == 30){
sincronizadorDePantallas.cambiarPantalla("ganador")
const menuGanaste = new MenuGanaste()
menuGanaste.cargar()
//const menuGanaste = new MenuGanaste()
//menuGanaste.cargar()
new MenuGanaste().cargar()
}
})

keyboard.e().onPressDo({game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head().atacarDerecha()})
keyboard.q().onPressDo({game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head().atacarIzquierda()})


// Si tocas shift se gana el juego automaticamente. Asi cuando probamos no tenemos que jugarlo completo. Despues esto se saca.
keyboard.shift().onPressDo({
Expand All @@ -48,7 +53,7 @@ program BadIceCreamGame {
menuGanaste.cargar()})*/
new MenuGanaste().cargar()})

game.onCollideDo(lineaEnemiga.enemigo(), {elemento => if(elemento.jugador()){ elemento.eliminate() sincronizadorDePantallas.cambiarPantalla("perdedor") menuPerdiste.cargar()}})
game.onCollideDo(lineaEnemiga.enemigo(), {elemento => if(elemento.jugador()){ elemento.eliminate() sincronizadorDePantallas.cambiarPantalla("perdedor") new MenuPerdiste().cargar()}})
}

object interactuador{
Expand Down
6 changes: 3 additions & 3 deletions menus.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Menus{
}


object menuPersonaje inherits Menus(add_1 = menuPersonajes, /* add_2 = marcoDeSeleccion,*/ moverA = marcoDeSeleccion, cantidadDeIncrementoParaPosiciones = 5, equisMax = 12, equisMin = 2, yeMax = 5, yeMin = 5, tipoDeMenu = "personajes"){
class MenuPersonaje inherits Menus(add_1 = menuPersonajes, /* add_2 = marcoDeSeleccion,*/ moverA = marcoDeSeleccion, cantidadDeIncrementoParaPosiciones = 5, equisMax = 12, equisMin = 2, yeMax = 5, yeMin = 5, tipoDeMenu = "personajes"){
override method cargar(){
super()
keyboard.enter().onPressDo({
Expand Down Expand Up @@ -135,11 +135,11 @@ class MenuGanaste inherits Menus(add_1 = ganaste, /*add_2 = seleccionGanaste,*/
})
}
}
object menuPerdiste inherits Menus(add_1 = perdiste, /*add_2 = seleccionGanaste,*/ moverA = new SeleccionGanaste(), cantidadDeIncrementoParaPosiciones = 4, equisMax = 10, equisMin = 6, yeMax = 7, yeMin = 7, tipoDeMenu = "perdedor"){
class MenuPerdiste inherits Menus(add_1 = perdiste, /*add_2 = seleccionGanaste,*/ moverA = new SeleccionGanaste(), cantidadDeIncrementoParaPosiciones = 4, equisMax = 10, equisMin = 6, yeMax = 7, yeMin = 7, tipoDeMenu = "perdedor"){
override method cargar(){
super()
//game.removeVisual(jugador)
game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head().eliminate()
//game.allVisuals().filter({objeto => objeto.image() == datosJugador.imagen()}).head().eliminate()
lineaEnemiga.enemigo().limpiarEnemigos()
game.removeVisual(fondoJuego)
game.removeVisual(points)
Expand Down
5 changes: 5 additions & 0 deletions miscelaneos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class SeleccionGanaste{
method image() = "nivel_s.png"
}

class SeleccionPerdiste{
var property position = game.at(6, 5)
method image() = "nivel_s.png"
}

object bloqueado{
var property position = game.at(1, 1)
method image() = "bloqueado.png"
Expand Down

0 comments on commit 8325673

Please sign in to comment.