Skip to content

Commit

Permalink
Merge branch 'master' into gramatica-end
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Oct 24, 2023
2 parents 74d7e51 + d1c0f58 commit d5e028f
Show file tree
Hide file tree
Showing 13 changed files with 427 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pilas-bloques-exercises",
"version": "1.4.12",
"version": "1.4.13",
"description": "Exercises for Pilas Bloques",
"homepage": "http://pilasbloques.program.ar",
"author": {
Expand Down
10 changes: 10 additions & 0 deletions src/actores/segundoCiclo/Capy/Yacare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference path="../../ActorAnimado.ts"/>

class Yacare extends ActorAnimado {
static _grilla = 'actor.yacare.png'

constructor() {
super(0, 0, {cantColumnas: 1});
this.definirAnimacion("parado", [0], 1);
}
}
6 changes: 4 additions & 2 deletions src/actores/segundoCiclo/Chuy/Chuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ class Chuy extends ActorAnimado {
this.definirAnimacion("correr", [68, 69, 70, 71, 72, 73, 74, 75, 76], 12);
this.definirAnimacion("correrChocando", [68, 69, 70, 71, 72, 73, 74, 75, 76], 12)
this.definirAnimacion("obstaculo", [0, 1, 1, 2, 2, 3, 3, 4, 4, 4], 12)
this.definirAnimacion("error", [101, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105]
, 12)
this.definirAnimacion("error", [101, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105], 12)
this.definirAnimacion("recoger", [97, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 100, 97], 12);
this.definirAnimacion("revolearPulpito", [ 97, 97, 97, 109, 109, 109, 108, 108, 108, 107, 107, 107, 106, 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, 109,
109, 109, 109, 108, 108, 108, 107, 107, 107, 106, 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, 109, 97, 97, 97], 12);
this.definirAnimacion("usarPaleta", [51, 52, 53, 54, 55, 56, 57, 58, 57, 56, 55, 56, 57, 58, 57, 56, 55, 56, 57, 58, 57, 56, 55, 56, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67], 12);
this.definirAnimacion("usarPaletaUnaVez", [51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67], 6);
this.definirAnimacion("rebotarPelota", [87, 88, 89, 90, 91, 92, 93, 92, 91, 90, 94, 95, 90, 91, 92, 93, 91, 94, 91, 93, 90, 94, 96, 87, 87, 87, 87], 12);
this.definirAnimacion("patear", [87, 88, 89, 90, 91, 92, 93, 92, 91, 90, 94, 95, 90, 91, 92, 93, 91, 94, 91, 93, 90, 94, 96, 87, 87, 87, 87], 12)
this.definirAnimacion("rebotarPulpito", [77, 78, 79, 80, 81, 82, 83, 82, 81, 80, 84, 85, 80, 81, 82, 83, 81, 84, 81, 83, 80, 84, 86, 77, 77, 77, 77], 12);
Expand Down
Binary file modified src/assets/actor.chuy.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 src/assets/fondo.superMaraton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/comportamientos/CorrerHeroicamente.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path = "ComportamientoConVelocidad.ts" />
/// <reference path = "GirarMarquesina.ts" />

class CorrerHeroicamente extends ComportamientoConVelocidad {
nombreAnimacion(){
return 'correr';
}

preAnimacion(){
this.argumentos.velocidad = 100;
this.argumentos.cantPasos = 1;
super.preAnimacion();
this.receptor.escena.fondo.hacer_luego(GirarMarquesina,{});
}

postAnimacion(){
super.postAnimacion();
if(this.receptor.fraseAlCorrer) this.receptor.decir(this.receptor.fraseAlCorrer());
}
}
44 changes: 44 additions & 0 deletions src/comportamientos/Irse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// <reference path = "../comportamientos/MovimientoAnimado.ts" />

// Si se pasa por argumento "irseCon" entonces el receptor debe ser actor compuesto
class Irse extends MovimientoAnimado {

iniciar(receptor){
this.argumentos.idTransicion = "irse";
super.iniciar(receptor);
}

preAnimacion(){
this.argumentos.direccion = new Direct(1);
this.argumentos.distancia = 600;
this.argumentos.velocidad = 8;
this.argumentos.cantPasos = 40;

if (this.argumentos.irseCon) {

if (typeof this.argumentos.irseCon == 'string') {
this.argumentos.irseCon = eval("pilas.escena_actual()." + this.argumentos.irseCon);
}
this.receptor.agregarSubactor(this.argumentos.irseCon);
}
super.preAnimacion();
}

configurarVerificaciones() {
super.configurarVerificaciones();
this.verificacionesPre.push(new Verificacion(() => {
return this.estaEnTransporte();
}, "Para irse hace falta un transporte"));
}

estaEnTransporte(){
if (typeof this.argumentos.irseCon == 'string') {
this.argumentos.irseCon = eval("pilas.escena_actual()." + this.argumentos.irseCon);
}

let noTieneQueirseConNingunActor = (!this.argumentos.irseCon);
let colisionaConElActorParaIrse = this.receptor.colisiona_con(this.argumentos.irseCon);

return (noTieneQueirseConNingunActor || colisionaConElActorParaIrse);
}
}
20 changes: 20 additions & 0 deletions src/comportamientos/PingPongAnimado.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path = "../../node_modules/pilasweb/dist/pilasweb.d.ts"/>
/// <reference path = "Decir.ts"/>

/*
Comportamiento que hace decir una
frase definida por la escena
*/

class PingPongAnimado extends Decir {
preAnimacion(): void {
this.receptor.escena.antesDeRebotar();
this.argumentos.mensaje = this.receptor.escena.getFraseAlRebotar()
super.preAnimacion();
}

postAnimacion(){
super.postAnimacion();
this.receptor.decir(this.receptor.escena.fraseAlRebotar());
}
}
89 changes: 89 additions & 0 deletions src/escenas/ChuyHaciendoJueguito.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/// <reference path = "EscenaActividad.ts" />
/// <reference path = "../actores/segundoCiclo/Chuy/Chuy.ts" />
/// <reference path = "../actores/segundoCiclo/Chuy/Pelotas.ts" />

class ChuyHaciendoJueguito extends EscenaActividad {
automata;
pulpito;
fondo;
cuadricula;

iniciar() {
this.fondo = new Fondo('fondo.chuy.png',0,0);
this.colocarCuadricula()
this.construirObjeto();
this.construirAutomata();
this.construirFSM();
}

colocarCuadricula(){
this.cuadricula = new Cuadricula(0, 0, 1, 1,
{ alto: 100, ancho: 400 },
{ grilla: 'invisible.png', cantColumnas: 1 });
}

construirAutomata() {
this.automata = new Chuy();
this.automata.escala *= 1.2;
this.cuadricula.agregarActor(this.automata, 0, 0, false);
this.automata.x -= 50;
}

construirObjeto() {
this.pulpito = new Pulpito();
this.pulpito.y = -120;
this.pulpito.escala *= 0.2;
this.pulpito.aprender(Flotar, {Desvio: 4});
this.cuadricula.agregarActor(this.pulpito, 0, 0, false);
}

private construirFSM(){
var builder= new BuilderStatePattern(this, 'inicial',false);
builder.agregarEstado('posCorrecta',false);
builder.agregarEstado('calentar1',false);
builder.agregarEstado('calentar2',false);
builder.agregarEstado('enCalor',false);
builder.agregarEstado('levantarPelota',false);
builder.agregarEstado('tirarAlAire',false);
builder.agregarEstado('jugarConElPie',false);
builder.agregarEstado('resuelto',false);
builder.agregarEstado('noResuelve',false);
builder.agregarEstadoAceptacion('fin');

builder.agregarTransicion('inicial', 'posCorrecta', 'avanzar');
builder.agregarTransicion('posCorrecta','calentar1','retroceder');
builder.agregarTransicion('posCorrecta','calentar2','avanzar');
builder.agregarTransicion('calentar1','enCalor','avanzar');
builder.agregarTransicion('calentar2','enCalor','retroceder');
builder.agregarTransicion('enCalor','levantarPelota','recoger');
builder.agregarTransicion('levantarPelota','tirarAlAire','revolearPulpito');
builder.agregarTransicion('levantarPelota','jugarConElPie','rebotarPiePulpito');
builder.agregarTransicion('tirarAlAire','resuelto','rebotarPiePulpito');
builder.agregarTransicion('jugarConElPie','resuelto','revolearPulpito');
builder.agregarTransicion('resuelto','fin','retroceder');

builder.agregarError('inicial', 'recoger', 'Primero hay que entrar en calor');
builder.agregarError('inicial', 'revolearPulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('inicial', 'rebotarPiePulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('inicial', 'retroceder', 'Primero hay que avanzar y entrar en calor');

builder.agregarError('posCorrecta', 'recoger', 'Primero hay que entrar en calor');
builder.agregarError('posCorrecta', 'revolearPulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('posCorrecta', 'rebotarPiePulpito', 'Primero hay que entrar en calor y agarrar la pelota');

builder.agregarError('calentar1', 'revolearPulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('calentar1', 'rebotarPiePulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('calentar1', 'retroceder', 'Primero hay que avanzar, entrar en calor y agarrar la pelota');

builder.agregarError('calentar2', 'revolearPulpito', 'Primero hay que entrar en calor y agarrar la pelota');
builder.agregarError('calentar2', 'rebotarPiePulpito', 'Primero hay que entrar en calor y agarrar la pelota');

builder.agregarError('enCalor', 'revolearPulpito', 'Primero hay que agarrar la pelota');
builder.agregarError('enCalor', 'rebotarPiePulpito', 'Primero hay que agarrar la pelota');
builder.agregarError('enCalor', 'retroceder', 'Primero hay que agarrar la pelota');

builder.agregarError('levantarPelota', 'retroceder', 'Primero hay que jugar con la pelota');

this.estado = builder.estadoInicial();
}
}
111 changes: 111 additions & 0 deletions src/escenas/LimpiandoElHumedal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/// <reference path = "../../node_modules/pilasweb/dist/pilasweb.d.ts" />
/// <reference path = "EscenaActividad.ts" />
/// <reference path = "../actores/Cuadricula.ts" />
/// <reference path = "../actores/segundoCiclo/Capy/Capy.ts" />
/// <reference path = "../actores/NaveAnimada.ts" />
/// <reference path = "../actores/segundoCiclo/Capy/Papel.ts" />
/// <reference path = "../actores/segundoCiclo/Capy/Lata.ts" />
/// <reference path = "../actores/segundoCiclo/Capy/Tacho.ts" />
/// <reference path = "../actores/Tablero.ts" />
/// <reference path = "../actores/ObservadoAnimado.ts" />
/// <reference path = "../actores/ActorCompuesto.ts" />
/// <reference path = "EstadosDeEscena.ts" />
/// <reference path = "../habilidades/Flotar.ts" />

class LimpiandoElHumedal extends EscenaActividad {
compus;
fondo;
cuadricula;
papel;
lata;
tacho;
yacare;

iniciar() {
this.fondo = new Fondo('fondo.capy.png', 0, 0);

this.cuadricula = new Cuadricula(0, 0, 4, 5,
{ ancho: 380, alto: 380 },
{
grilla: 'casillas.capy.png',
cantFilas: 1,
cantColumnas: 16,
bordesDecorados: true,
relAspecto: 1
});

this.crearActores();
this.crearTableros();
this.crearEstado();
}

private crearActores() {
this.crearAutomata();

var elTacho = new Tacho();
this.cuadricula.agregarActor(elTacho, this.cuadricula.cantFilas - 1, 0);
this.tacho = new ActorCompuesto(0, 0, { subactores: [elTacho] });
this.tacho.escala *= 0.9;
this.tacho.y -= 20;
this.tacho.x += 10;

this.yacare = new Yacare();
this.cuadricula.agregarActor(this.yacare, this.cuadricula.cantFilas - 1, 2);
this.yacare.escala *= 2;
this.yacare.y -= 20;
this.yacare.aprender(Flotar, { Desvio: 2 });

this.lata = new Lata();
this.lata.cantidad = 3;
this.papel = new Papel();
this.papel.cantidad = 3;
this.cuadricula.agregarActor(this.lata, 0, 0);
this.lata.aprender(Flotar, { Desvio: 2 });
this.cuadricula.agregarActor(this.papel, 0, this.cuadricula.cantColumnas - 1);
this.papel.aprender(Flotar, { Desvio: 2 });
this.lata.escala *= 0.8;
this.papel.escala *= 0.8;
}

private crearAutomata() {
this.automata = new ActorCompuesto(0, 0, { subactores: [new Capy()] });
this.cuadricula.agregarActorEnPerspectiva(this.automata, this.cuadricula.cantFilas - 1, 0, false);
this.automata.escala = 0.8;
this.automata.y += 50;
}

private crearTableros() {
Trait.toObject(ObservadoConDisminuir, this.papel);
Trait.toObject(ObservadoConDisminuir, this.lata);

this.lata.registrarObservador(
new Tablero(-150, 190, { texto: "Lata" }));
this.papel.registrarObservador(
new Tablero(150, 190, { texto: "Papel" }));

this.papel.changed();
this.lata.changed();
}

private crearEstado() {
var builder = new BuilderStatePattern(this, 'faltanMateriales');
builder.agregarEstado('tachoLleno');
builder.agregarEstadoAceptacion('montandoYacare');
builder.agregarError('faltanMateriales', 'montar', '¡No puedo montar el yacaré sin antes haber limpiado el humedal!');
builder.agregarError('faltanMateriales', 'irse', '¡No puedo irme sin antes haber limpiado el humedal!');

builder.agregarTransicion('faltanMateriales', 'tachoLleno', 'colocar',
() => this.lata.cantidad == 0 && this.papel.cantidad == 0);
builder.agregarTransicion('tachoLleno', 'montandoYacare','irse');

this.estado = builder.estadoInicial();
}

actualizar(): void {
super.actualizar();
if( this.tacho.nombreAnimacionActual() != "lleno" &&
( this.lata.cantidad != 3 || this.papel.cantidad != 3 ) &&
this.automata.casillaActual() === this.tacho.subactores[0].casillaActual() )
this.tacho.cargarAnimacion("lleno")
}
}
Loading

0 comments on commit d5e028f

Please sign in to comment.