Skip to content

Commit

Permalink
Creación de niveles y mejora en enemigos
Browse files Browse the repository at this point in the history
  • Loading branch information
Miranda-03 committed Oct 30, 2024
1 parent bd0bad8 commit c57febf
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 33 deletions.
18 changes: 12 additions & 6 deletions enemigos.wlk
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import menus.*
import wollok.game.*


class Enemigo1{
var lado = 0
var property vida

var property position = game.at(7,16)
var property position = game.center()
//var lado = 0
method image() = "piopio.png"
const apariencia = "piopio.png"
method image() = apariencia

method soyBloque() = false

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

method movimiento(){
game.onTick(700, "mover_automaticamente", {self.moverse()})
game.onTick(700, self, {self.moverse()})
}

method detener() {
game.removeTickEvent("mover_automaticamente")
game.removeTickEvent(self)
}

method cambiar_vector_movimiento() {
Expand All @@ -28,9 +32,11 @@ class Enemigo1{

method detectar_colisiones() {
game.onCollideDo(self, {elemento =>
if(elemento.soyBloque()){
self.detener()
self.volver()
self.cambiar_vector_movimiento()
}
})
}

Expand All @@ -50,8 +56,8 @@ class Enemigo1{

method activar_enemigo() {
game.addVisual(self)
self.movimiento()
self.detectar_colisiones()
self.movimiento()
self.detectar_colisiones()
}

method herido() {
Expand Down
2 changes: 2 additions & 0 deletions jugador.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Jugador inherits FiguraConMovimiento(position = game.at(1, 1)) {
game.addVisualCharacter(self)
}

method soyBloque() = false

method volver(){
if(sincronizadorDePantallas.pantallaActual() == "jugar"){
game.addVisualCharacter(self)
Expand Down
35 changes: 8 additions & 27 deletions menus.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import puntos.*

import miscelaneos.*

import niveles.*

class Menus{
const add_1
//const add_2
Expand Down Expand Up @@ -95,9 +97,9 @@ class MenuNivel inherits Menus(add_1 = menuNiveles,/* add_2 = seleccionNivel,*/
if(sincronizadorDePantallas.pantallaActual() == tipoDeMenu){
sincronizadorDePantallas.cambiarPantalla("jugar")
if(moverA.position() == game.at(1,11)){ //Seleccionado nivel 1
escenario.generarLista(0)
juego.nivel(nivel_1)
} else if(moverA.position() == game.at(3,11)){ //Seleccionado nivel 2
escenario.generarLista(1)
juego.nivel(nivel_2)
}
game.removeVisual(menuNiveles)
game.removeVisual(moverA)
Expand Down Expand Up @@ -163,32 +165,11 @@ class MenuPerdiste inherits Menus(add_1 = perdiste, /*add_2 = seleccionGanaste,*

object juego{

method jugar(){ //DIBUJO DE LOS ELEMENTOS DEL MUNDO
//dibujar fondo
game.addVisual(fondoJuego)
//dibujar frutas
spawn.dibujarFrutas()
//dibujar muros
muros.crearBordeSuperior()
muros.crearLaterales()
//?
const nuevo_enemigo = new Enemigo1(vida = 100)
nuevo_enemigo.activar_enemigo()
//lineaEnemiga.activar()

//dibujar escenario
escenario.generarEscenario()
//dibujar jugador
const jugador = new Jugador()
jugador.valor(datosJugador.imagen())
jugador.posicionate()
//game.addVisualCharacter(jugador)
muros.crearBordeInferior()
//dibujar puntos
//game.addVisual(marcadorLeft)
var property nivel = nivel_1

method jugar(){
nivel.iniciar_mapa()
game.addVisual(points)
//game.addVisual(marcadorRight)
game.showAttributes(jugador)
}
}

Expand Down
15 changes: 15 additions & 0 deletions muros.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ class Bloque{
method quitarBloque() = game.removeVisual(self)
}

class Bloque_mapa{
var property position = game.center()

const apariencia = "b_pasto.png"
method image() = visual.valor()

method soyBloque() = true

method Dibujar(){
game.addVisual(self)
}

method quitarBloque() = game.removeVisual(self)
}

object visual{
var property valor = "b_fiesta.png"
}
Expand Down
114 changes: 114 additions & 0 deletions niveles.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import wollok.game.*
import muros.*
import enemigos.*
import miscelaneos.*
import puntos.*
import jugador.*

mixin Generacion_nivel{
var property apariencia_enemigo = "piog"
var property velocidad_de_enemigos = 500

var property fondo = fondoJuego
var property apariencia_bloque = "b_pas.png"

var property mapa = 2

method generarEscenario() {

game.addVisual(fondo)

spawn.dibujarFrutas()
muros.crearBordeSuperior()
muros.crearLaterales()

var ys = game.height() - 2
var xs = game.width() - 2

mapa.forEach{fila =>
fila.forEach{espacio =>
if(espacio == 1){
const bloque = new Bloque_mapa(position = game.at(xs, ys), apariencia = apariencia_bloque)
game.addVisual(bloque)
}
else if(espacio == 2){
const enemigo = new Enemigo1(vida = 10, position = game.at(xs, ys), apariencia = apariencia_enemigo)
enemigo.activar_enemigo()
}
xs = xs - 1
}
xs = game.width() - 2
ys = ys - 1
}

const jugador = new Jugador()
jugador.valor(datosJugador.imagen())
jugador.posicionate()
muros.crearBordeInferior()
game.showAttributes(jugador)
}
}

object nivel_1 inherits Generacion_nivel {
const mapa_1 = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0],
[0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0],
[0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0],
[0,1,0,1,1,1,0,2,0,1,1,1,0,0,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,2,1,0],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,0,2,0,0,0,0,0,0,0,0,0],
[0,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0],
[0,1,0,1,0,1,0,0,2,1,0,1,0,0,1,0],
[0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0],
[0,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
]

method iniciar_mapa(){
self.mapa(mapa_1)
self.apariencia_enemigo("piopio.png")
self.apariencia_bloque("b_pasto.png")
self.fondo(fondoJuego)

self.generarEscenario()
}

}


object nivel_2 inherits Generacion_nivel {
const mapa_2 = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,2,1,0],
[0,1,0,1,1,1,0,1,0,1,1,1,0,0,1,0],
[0,1,0,1,0,1,1,0,1,1,0,1,0,0,1,0],
[0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0],
[0,1,1,1,1,0,1,1,1,1,1,1,0,0,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,2,1,0],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,0],
[0,1,0,1,1,1,0,0,0,1,1,1,0,1,1,0],
[0,1,0,1,0,1,0,2,0,1,0,1,0,0,1,0],
[0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,0],
[0,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
]


method iniciar_mapa(){
self.mapa(mapa_2)
self.apariencia_enemigo("piopio.png")
self.apariencia_bloque("b_pasto.png")
self.fondo(fondoJuego)

self.generarEscenario()
}

}
2 changes: 2 additions & 0 deletions puntos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Fruta{

method impactado() = null

method soyBloque() = false

method image(){
if(points.frutasObtenidas() < 10){
return spawn.puntos().get(0)
Expand Down

0 comments on commit c57febf

Please sign in to comment.