Skip to content

Commit

Permalink
Merge branch 'master' into limpiandoElHumedal
Browse files Browse the repository at this point in the history
  • Loading branch information
danielferro69 authored Oct 20, 2023
2 parents 7e3aa6b + 92c43ff commit 4cdaf65
Show file tree
Hide file tree
Showing 30 changed files with 485 additions and 186 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.11",
"version": "1.4.12",
"description": "Exercises for Pilas Bloques",
"homepage": "http://pilasbloques.program.ar",
"author": {
Expand Down
4 changes: 4 additions & 0 deletions src/actores/Casilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class Casilla extends ActorAnimado {
return this.actores.some( actor => actor.tiene_etiqueta(unaEtq))
}

tieneMasDeUnActor(){
return this.actores.length > 1
}

actoresConEtiqueta(unaEtq) {
return this.actores.filter(actor => actor.tiene_etiqueta(unaEtq));
}
Expand Down
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
13 changes: 5 additions & 8 deletions src/actores/segundoCiclo/Manic/Manic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ class Manic extends ActorAnimado {
constructor() {
super(0,0,{cantColumnas: 10, cantFilas: 9});
this.definirAnimacion("parado",
new Cuadros(0).repetirVeces(16)
new Cuadros(32).repetirVeces(18)
.concat([33, 34, 34, 32, 32, 32, 32, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
.concat(new Cuadros(32).repetirVeces(18))
.concat([33, 34, 34, 32, 32, 32, 32, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
.concat([32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 32, 32, 32, 32, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
.concat(new Cuadros(0).repetirVeces(30))
.concat([32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 32, 32, 32, 32, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
.concat(new Cuadros(0).repetirVeces(30))
.concat([32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 32, 32, 32, 32, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
.concat(new Cuadros(0).repetirVeces(16))
.concat([32])
.concat(new Cuadros(0).repetirVeces(5)),
.concat([32]),
20, true);
this.definirAnimacion("correr", [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 7, 7], 20);
this.definirAnimacion("correrChocando", [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 7, 7], 12)
Expand Down
20 changes: 20 additions & 0 deletions src/actores/segundoCiclo/MetaFinal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path="../ActorAnimado.ts"/>

class MetaFinal extends ActorAnimado {

static imagenesPara(actor) : string[] {
return [`marcador-${actor}.png`];
}

constructor(actor: string) {
super(0, 0, { grilla: `marcador-${actor}.png`, cantColumnas: 1, cantFilas: 1 });
}

enviarAtras() {
this.setZ(Math.min(this.getZ() + 1))
}

ajustarSegunCuadricula(alto){
this.setY(this.getY() + alto / 2)
}
}
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.
Binary file added src/assets/marcador-capy.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/marcador-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/marcador-duba.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/marcador-lita.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/marcador-manic.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/marcador-yvoty.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 modified src/assets/pelotaAnimada.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());
}
}
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();
}
}
14 changes: 14 additions & 0 deletions src/escenas/EscenaActividad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class EscenaActividad extends Base {
automata : ActorAnimado;
cuadricula : Cuadricula;
fondo;
xFinal: number;
yFinal: number;

/**
* Devuelve todos los nombres de archivo de imagen necesarios para
Expand Down Expand Up @@ -99,6 +101,18 @@ class EscenaActividad extends Base {
return this.obtenerActoresConEtiqueta(actor).every(o => o.nombreAnimacionActual() == estado);
}

estaEnPosicionFinalSiLaTiene(): boolean {
return !this.tienePosicionFinal() || this.automataEnPosicionFinal()
}

tienePosicionFinal(): boolean {
return this.xFinal !== undefined
}

automataEnPosicionFinal(): boolean {
return this.automata.casillaActual().sos(this.yFinal, this.xFinal);
}

/**
* Computa un multiplicador que crece según la cantidad de filas y columnas de la cuadrícula.
* El multiplicador es 1 si la cuadrícula es de 1x1, y crece acotado por maxRatio.
Expand Down
78 changes: 78 additions & 0 deletions src/escenas/NoMeCansoDeRebotar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/// <reference path = "EscenaActividad.ts" />
/// <reference path = "../comportamientos/PingPongAnimado.ts"/>
/// <reference path = "../actores/segundoCiclo/Chuy/Paleta.ts" />
/// <reference path = "../actores/segundoCiclo/Chuy/Pelotas.ts" />
/// <reference path = "../actores/segundoCiclo/Chuy/Chuy.ts" />


/**
* @class NoMeCansoDeRebotar
*
* Objetivos: Introducir Repetición
* Enunciado: Repetir reboteso.
*/
class NoMeCansoDeRebotar extends EscenaActividad {
automata
paleta
pingpong
fondo
rebotesFaltantes
cuadricula;

iniciar() {
this.fondo = new Fondo('fondo.chuy.png',0,0);
this.colocarCuadricula()
this.construirObjetos();
this.construirAutomata();
this.rebotesFaltantes=30;
this.automata.decir(" Tengo que hacer " + this.rebotesFaltantes + " rebotes!");
}

colocarCuadricula(){
this.cuadricula = new Cuadricula(70, 0, 1, 1,
{ alto: 100, ancho: 300 },
{ 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 -= 20;
}

construirObjetos() {
this.paleta = new Paleta();
this.paleta.y = -120;
this.paleta.escala *= 0.2;
this.paleta.aprender(Flotar, {Desvio: 4});
this.cuadricula.agregarActor(this.paleta, 0, 0, false);
this.pingpong = new PingPong();
this.pingpong.y = -160;
this.pingpong.escala *= 0.2;
this.pingpong.aprender(Flotar, {Desvio: 4});
this.cuadricula.agregarActor(this.pingpong, 0, 0, false);
}

antesDeRebotar(){
//oculto los objetos
this.pingpong.escala = 0;
this.paleta.escala = 0;
}

getFraseAlRebotar(): string {
if (this.rebotesFaltantes > 0) return " Faltan " + this.rebotesFaltantes + " rebotes";
if (this.rebotesFaltantes == 0) return " ¡Ya hice los rebotes necesarios!";
throw new ActividadError(" ¡Uy! Hice muchos rebotes... ¡Me pasé!");
}

fraseAlRebotar(){
this.rebotesFaltantes--;
return this.getFraseAlRebotar();
}

estaResueltoElProblema() {
return this.rebotesFaltantes == 0;
}

}
49 changes: 49 additions & 0 deletions src/escenas/SuperMaraton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/// <reference path = "EscenaActividad.ts" />
/// <reference path = "Errores.ts" />
/// <reference path = "../actores/FondoAnimado.ts"/>
/// <reference path = "../actores/segundoCiclo/Chuy/Chuy.ts"/>


/**
* @class SuperMaraton
*
*/
class SuperMaraton extends EscenaActividad {
fondo;
automata;

iniciar() {
this.fondo = new FondoAnimado('fondo.superMaraton.png', pilas.derecha(), 0);
this.automata = new Chuy();
this.automata.y = -70;

this.automata.totalKM = 15 + Math.round(Math.random() * 30);
this.automata.restantesKM = this.automata.totalKM;

this.automata.kmsTotales = function(){
return this.totalKM
};

this.crearTablero();

this.automata.fraseAlCorrer = function() {
this.restantesKM--;
if (this.restantesKM == 0) return "¡Llegué!";
if (this.restantesKM == 1) return "¡Falta 1 kilometro!";
if (this.restantesKM < 0) throw new ActividadError("Ya llegué, ¡no debo seguir corriendo!");

return "¡Faltan " + this.restantesKM + " kilometros!";
}
}

crearTablero(){
Trait.toObject(Observado, this.automata);
var tablero = new Tablero(0, 210, { texto: "Kilómetros a recorrer" , atributoObservado: 'kmsTotales'});
this.automata.registrarObservador(tablero);
}

estaResueltoElProblema(){
return this.automata.restantesKM === 0;
}

}
4 changes: 4 additions & 0 deletions src/escenas/libroPrimaria/CustomScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class CustomScene extends EscenaDesdeMapa {
this.initDesdeUnaOVariasDescripciones(options.grid.spec, options.grid.specOptions);
}

static nombreAutomata(): string {
return 'custom'
}

obtenerAutomata(): ActorAnimado {
return this.automata
}
Expand Down
Loading

0 comments on commit 4cdaf65

Please sign in to comment.