Skip to content

Commit

Permalink
Merge pull request #56 from Program-AR/casilla-final
Browse files Browse the repository at this point in the history
Casilla final - parte 1
  • Loading branch information
dlopezalvas authored Oct 17, 2023
2 parents f847e71 + 2218a31 commit ad41d95
Show file tree
Hide file tree
Showing 22 changed files with 225 additions and 184 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.7",
"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
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 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.
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
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
19 changes: 5 additions & 14 deletions src/escenas/libroPrimaria/EscenaCapy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class EscenaCapy extends EscenaDesdeMapa {
return 'fondo.capy.png';
}

static imagenesAdicionales(): string[] {
return Casilla.imagenesPara('capy').concat(Obstaculo.imagenesPara('capy'));
static nombreAutomata(): string {
return 'capy'
}

constructor(especificacion: Spec, opciones?: opcionesMapaAleatorio) {
constructor(especificacion: Spec, opciones?: opcionesMapaAleatorio, posFinal?: [number, number]) {
super();
this.initDesdeUnaOVariasDescripciones(especificacion, opciones);
this.initDesdeUnaOVariasDescripciones(especificacion, opciones, posFinal);
}

ajustarGraficos() {
Expand Down Expand Up @@ -57,10 +57,6 @@ class EscenaCapy extends EscenaDesdeMapa {
return new Obstaculo(archivosObstaculos, (fila + 1) + (fila + 1) * (columna + 1));
}

todosLosActoresCumplen(actor, estado) {
return this.obtenerActoresConEtiqueta(actor).every(o => o.nombreAnimacionActual() == estado);
}

tachosLlenos(): boolean {
return this.todosLosActoresCumplen("Tacho", "lleno")
}
Expand All @@ -77,13 +73,8 @@ class EscenaCapy extends EscenaDesdeMapa {
return this.recogidos(actor) || this.noHay(actor)
}


noHay(actor): boolean {
return this.contarActoresConEtiqueta(actor) == 0
}

estaResueltoElProblema(): boolean {
return this.tachoResuelto() && this.recoleccionResuelta("Lata") && this.recoleccionResuelta("Papel")
return super.estaResueltoElProblema() && this.tachoResuelto() && this.recoleccionResuelta("Lata") && this.recoleccionResuelta("Papel")
}

archivoFondo() {
Expand Down
15 changes: 5 additions & 10 deletions src/escenas/libroPrimaria/EscenaChuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ class EscenaChuy extends EscenaDesdeMapa {
return 'fondo.chuy.png';
}

static imagenesAdicionales(): string[] {
return Casilla.imagenesPara('chuy').concat(Obstaculo.imagenesPara('chuy'));
static nombreAutomata(): string {
return 'chuy'
}

constructor(especificacion: Spec, opciones?: opcionesMapaAleatorio, posFinal?: [number, number]) {
super();
this.initDesdeUnaOVariasDescripciones(especificacion, opciones);

if (posFinal) {
this.xFinal = posFinal[0];
this.yFinal = posFinal[1];
}
this.initDesdeUnaOVariasDescripciones(especificacion, opciones, posFinal);
}

ajustarGraficos() {
Expand All @@ -44,7 +39,7 @@ class EscenaChuy extends EscenaDesdeMapa {

this.obtenerActoresConEtiqueta("PelotaAnimada").forEach(actor => {
actor.aprender(Flotar, { Desvio: 4 });
actor.escala *= this.escalaSegunCuadricula(0.5);
actor.escala *= this.escalaSegunCuadricula(0.1);
});

this.obtenerActoresConEtiqueta("PingPong").forEach(actor => {
Expand Down Expand Up @@ -83,7 +78,7 @@ class EscenaChuy extends EscenaDesdeMapa {
}

estaEnPosicionFinalSiLaTiene(): boolean {
return this.xFinal === undefined || this.automata.casillaActual().sos(this.yFinal, this.xFinal) || this.automata.alFinalDelCamino();
return super.estaEnPosicionFinalSiLaTiene() || this.automata.alFinalDelCamino();
}

noHayPelotas(): boolean {
Expand Down
Loading

0 comments on commit ad41d95

Please sign in to comment.