Skip to content

Commit

Permalink
Merge branch 'master' into chuy
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed May 26, 2023
2 parents 0af6b80 + 1ff022c commit c4d9715
Show file tree
Hide file tree
Showing 24 changed files with 305 additions and 10 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.2.17",
"version": "1.2.18",
"description": "Exercises for Pilas Bloques",
"homepage": "http://pilasbloques.program.ar",
"author": {
Expand Down
4 changes: 3 additions & 1 deletion src/actores/CompuAnimada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

class CompuAnimada extends ActorAnimado {

static _grilla = 'compu_animada.png'

private _yaFuePrendida: boolean = false

constructor(x, y) {
super(x, y, { grilla: 'compu_animada.png', cantColumnas: 8, cantFilas: 1 })
super(x, y, { cantColumnas: 8, cantFilas: 1 })
this.definirAnimacion("parado", [0], 5, true)
this.definirAnimacion("prendida", [1], 5)
this.definirAnimacion("claveok", [2], 5)
Expand Down
21 changes: 21 additions & 0 deletions src/actores/segundoCiclo/Yvoty/Celular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference path="../../ActorAnimado.ts"/>
class Celular extends ActorAnimado {
static _grilla = 'actor.celular.png'

constructor(prendido = false) {
super(0, 0, {cantColumnas: 2});
this.definirAnimacion("cargado", [1], 1);
this.definirAnimacion("prendido", [1], 1);
this.definirAnimacion("descargado", [0], 1);

if(prendido) this.cargarAnimacion("prendido")
}
}

class Cargador extends ActorAnimado {
static _grilla = 'actor.cargador.png'

constructor() {
super(0, 0, { cantColumnas:1, cantFilas: 1});
}
}
11 changes: 11 additions & 0 deletions src/actores/segundoCiclo/Yvoty/Luciernaga.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="../../ActorAnimado.ts"/>
class Luciernaga extends ActorAnimado {
static _grilla = 'actor.luciernaga.png'

constructor() {
super(0, 0, {cantColumnas: 2});
this.definirAnimacion("dormida",[0],1);
this.definirAnimacion("despierta",[1],1);
}

}
9 changes: 9 additions & 0 deletions src/actores/segundoCiclo/Yvoty/Mariposa.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="../../ActorAnimado.ts"/>

class Mariposa extends ActorAnimado {
static _grilla = 'actor.mariposa.png'

constructor() {
super(0, 0, {cantColumnas:1, cantFilas: 1});
}
}
30 changes: 30 additions & 0 deletions src/actores/segundoCiclo/Yvoty/Yvoty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference path="../../ActorAnimado.ts"/>
/// <reference path="../../../comportamientos/ComportamientoAnimado.ts"/>

class Yvoty extends ActorAnimado {
static _grilla = 'actor.yvoty.png'

constructor() {
super(0, 0, { cantColumnas: 10, cantFilas: 8 });

this.definirAnimacion("parado",
new Cuadros(0).repetirVeces(16)
.concat([4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 14, 14, 14, 14])
.concat(new Cuadros(0).repetirVeces(30))
.concat([4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 14, 14, 14, 14])
.concat(new Cuadros(0).repetirVeces(30))
.concat([4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 4, 5, 6, 7, 8, 7, 6, 5, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 14, 14, 14, 14])
.concat(new Cuadros(0).repetirVeces(16))
.concat([14])
.concat(new Cuadros(0).repetirVeces(5)),
20, true);
this.definirAnimacion("correr", [52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71], 20);
this.definirAnimacion("correrChocando", [52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71], 20)
this.definirAnimacion("obstaculo", [20, 21, 21, 22, 23, 24, 24, 24, 24, 25, 26, 27, 28, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], 12)
this.definirAnimacion("error", [30, 30, 30, 30, 30, 30, 30, 31, 32, 33, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37], 12)
this.definirAnimacion("recoger", [0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 20);
this.definirAnimacion("usarCelu", [38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 41, 43, 42, 42, 42, 44, 45, 46, 47, 46, 42, 42, 42, 45, 46, 46, 46, 45, 44, 48, 48, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 38, 38, 38, 38, 38, 38, 38], 20);
this.definirAnimacion("sacarFoto", [38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 41, 43, 42, 42, 42, 44, 45, 46, 47, 46, 42, 42, 42, 45, 46, 46, 46, 45, 44, 48, 48, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 38, 38, 38, 38, 38, 38, 38], 20);
this.definirAnimacion("escribir", [16, 16, 17, 17, 18, 18, 18, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18], 20);
}
}
Binary file added src/assets/actor.cargador.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/actor.celular.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/actor.luciernaga.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/actor.mariposa.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/actor.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 added src/assets/casillas.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 added src/assets/fondo.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 added src/assets/obstaculo.yvoty1.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/obstaculo.yvoty2.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/obstaculo.yvoty3.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/obstaculo.yvoty4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/comportamientos/CargarCelular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference path = "../../node_modules/pilasweb/dist/pilasweb.d.ts"/>
/// <reference path = "Encender.ts" />

class CargarCelular extends Encender {

public nombreAnimacion(): String {
return "usarCelu"
}

public nombreProximaAnimacion(): string {
return "cargado"
}

configurarVerificaciones() {
super.configurarVerificaciones()

const escena = pilas.escena_actual()

this.verificacionesPre.push(new Verificacion(() => escena.noHay("Cargador"),
'¡Todavía no recogí el cargador!'))

}

postAnimacion() {
super.postAnimacion()
if (pilas.escena_actual().celularesCargados()) {
pilas.escena_actual().estado = new Estado(() =>
true
)
}
}
}
13 changes: 13 additions & 0 deletions src/comportamientos/SacarFoto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path = "../../node_modules/pilasweb/dist/pilasweb.d.ts"/>
/// <reference path = "Encender.ts" />

class SacarFoto extends Encender {

public nombreAnimacion(): String {
return "sacarFoto"
}

public nombreProximaAnimacion(): string {
return "despierta"
}
}
25 changes: 18 additions & 7 deletions src/escenas/InstalandoJuegos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,30 @@ class InstalandoJuegos extends EscenaActividad {
estado;

iniciar() {
this.fondo = new Fondo('fondos.biblioteca.png', 0, 0);
this.cuadricula = new Cuadricula(20, -50, 1, 4,
{ alto: 100, ancho: 400 },
{ grilla: 'invisible.png', cantColumnas: 1 });
this.fondo = new Fondo(this.imagenFondo(), 0, 0);
this.colocarCuadricula()
for (var i = 1; i <= 3; ++i) {
this.cuadricula.agregarActor(new CompuAnimada(0, 0), 0, i);
let compu = new CompuAnimada(0, 0)
this.cuadricula.agregarActor(compu, 0, i);
this.ajustarCompu(compu)
}
this.colocarAutomata();
this.construirFSM();
}

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

ajustarCompu(compu){}

imagenFondo(){
return 'fondos.biblioteca.png'
}

private construirFSM() {
construirFSM() {
var builder = new BuilderStatePattern(this, 'inicial');
builder.agregarEstadosPrefijados('prendido', 1, 3);
builder.agregarEstadosPrefijados('escritoA', 1, 3);
Expand Down Expand Up @@ -61,7 +72,7 @@ class InstalandoJuegos extends EscenaActividad {
this.estado = builder.estadoInicial();
}

private colocarAutomata() {
colocarAutomata() {
this.automata = new InstaladorAnimado(0, 0);
this.cuadricula.agregarActor(this.automata, 0, 0);
this.automata.escala = 1;
Expand Down
44 changes: 44 additions & 0 deletions src/escenas/InstalandoJuegosYvoty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// <reference path = "EscenaActividad.ts" />
/// <reference path = "../actores/Cuadricula.ts" />
/// <reference path = "../actores/CompuAnimada.ts" />
/// <reference path = "../actores/InstaladorAnimado.ts" />
/// <reference path = "../comportamientos/ComportamientoAnimado.ts" />
/// <reference path = "../comportamientos/MovimientosEnCuadricula.ts" />

class InstalandoJuegosYvoty extends InstalandoJuegos {
compus;
automata;
fondo;
cuadricula;
estado;


colocarCuadricula(){
this.cuadricula = new Cuadricula(0, -20, 1, 4,
{ ancho: 400, alto: 380 },
{ grilla: 'casillas.yvoty.png',
cantFilas: 1,
cantColumnas: 16,
bordesDecorados: true,
relAspecto: 1,
})
}

imagenFondo(){
return 'fondo.yvoty.png'
}

colocarAutomata() {
this.automata = new Yvoty();
this.cuadricula.agregarActor(this.automata, 0, 0);
this.automata.escala *= this.escalaSegunCuadricula(1.5);
this.automata.setY(0);
this.automata.x -= 10
}

ajustarCompu(compu) {
compu.escala *= this.escalaSegunCuadricula(0.6)
compu.setX(compu.getX() + 9)
compu.setY(compu.getY() + 14)
}
}
1 change: 1 addition & 0 deletions src/escenas/libroPrimaria/EscenaDesdeMapa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class GeneradorDeMapasAleatorios implements GeneradorDeMapas {
this.colecciones = opciones.colecciones || {};
this.macros = opciones.macros || {};
this._anotadosParaColeccion = [];
this._anotadosParaColecciones = {};
for (const id in this.colecciones) {
this._anotadosParaColecciones[id] = [];
}
Expand Down
121 changes: 121 additions & 0 deletions src/escenas/libroPrimaria/EscenaYvoty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/// <reference path = "../libroPrimaria/EscenaDesdeMapa.ts" />


class EscenaYvoty extends EscenaDesdeMapa {
automata: Yvoty;

static clasesDeActoresInvolucrados(): typeof ActorAnimado[] {
return [Yvoty, Celular, Luciernaga, Cargador, Mariposa, CompuAnimada];
};

static pathFondo(): string {
return 'fondo.yvoty.png';
}

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

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

ajustarGraficos() {
this.automata.escala *= this.escalaSegunCuadricula(1.8);
this.automata.setY(this.automata.getY() + this.automata.getAlto() / 4);

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

this.obtenerActoresConEtiquetas(["Celular", "Mariposa"]).forEach(actor => {
actor.aprender(Flotar, { Desvio: 4 });
actor.escala *= this.escalaSegunCuadricula(0.6);
});

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

this.obtenerActoresConEtiqueta("Obstaculo").forEach(obstaculo => {
obstaculo.escala *= this.escalaSegunCuadricula(1.1);
});
}

mapearIdentificadorAActor(id, nroFila, nroColumna): ActorAnimado {
switch (id) {
case 'A': return this.automata;
case 'O': return this.obtenerObstaculo(nroFila, nroColumna);
case 'C': return new Celular();
case 'P': return new Celular(true); //celular prendido
case 'K': return new Cargador();
case 'L': return new Luciernaga();
case 'M': return new Mariposa();
case 'T': return new CompuAnimada(0, 0);
default: throw new Error("El identificador '" + id +
"' no es válido en una escena de Yvoty.");
}
}

obtenerAutomata(): Yvoty {
return new Yvoty();
}

obtenerObstaculo(fila: number, columna: number): Obstaculo {
let archivosObstaculos = ["obstaculo.yvoty1.png", "obstaculo.yvoty2.png", "obstaculo.yvoty3.png", "obstaculo.yvoty4.png"];
return new Obstaculo(archivosObstaculos, (fila + 1) + (fila + 1) * (columna + 1));
}

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

luciernagasDespiertas(): boolean {
return this.todosLosActoresCumplen("Luciernaga", "despierta")
}

celularesCargados(): boolean {
return this.todosLosActoresCumplen("Celular", "cargado") && this.noHay("Cargador")
}

celularResuelto(): boolean {
return this.celularesCargados() || this.noHay("Celular")
}

computadorasPrendidas(): boolean {
return this.todosLosActoresCumplen("CompuAnimada", "prendida")
}

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

estaResueltoElProblema(): boolean {
return this.luciernagasDespiertas() && this.celularResuelto() && this.noHay("Mariposa") && this.computadorasPrendidas()
}

archivoFondo() {
return "fondo.yvoty.png";
}
cuadriculaX() {
return 0;
}
cuadriculaY() {
return -20;
}
opsCuadricula() {
return { ancho: 400, alto: 380 };
}
opsCasilla() {
return {
grilla: 'casillas.yvoty.png',
cantFilas: 1,
cantColumnas: 16,
bordesDecorados: true,
relAspecto: 1,
};
}
}

0 comments on commit c4d9715

Please sign in to comment.