From 2f1fa3915feff6eed77ec61a7af9b4a6164a3609 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Mon, 23 Oct 2023 19:27:22 -0300 Subject: [PATCH 1/6] reciclando --- src/comportamientos/Interactuar.ts | 2 + src/escenas/ReciclandoPapeles.ts | 78 ++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/escenas/ReciclandoPapeles.ts diff --git a/src/comportamientos/Interactuar.ts b/src/comportamientos/Interactuar.ts index ec9ae29..c3e67b1 100644 --- a/src/comportamientos/Interactuar.ts +++ b/src/comportamientos/Interactuar.ts @@ -87,6 +87,8 @@ class Interactuar extends ComportamientoAnimado { * Indica si existe una posible interacción entre dos actores. */ hayConQuienInteractuar(): boolean { + console.log(this.etiqueta()) + console.log(this.receptor) return this.receptor.tocando(this.etiqueta()) } diff --git a/src/escenas/ReciclandoPapeles.ts b/src/escenas/ReciclandoPapeles.ts new file mode 100644 index 0000000..40f5817 --- /dev/null +++ b/src/escenas/ReciclandoPapeles.ts @@ -0,0 +1,78 @@ +/// +/// +/// +/// +/// + +class ReciclandoPapeles extends EscenaActividad { + cuadricula : CuadriculaMultiple; + definidor: DefinidorColumnasFijo; + + iniciar() { + this.fondo = new Fondo('fondo.capy.png',0,0); + this.definidor = new DefinidorColumnasFijo(5,[5,6,8,4,7]); + this.cuadricula = new CuadriculaMultiple( + this.definidor, + 0,0, + {separacionEntreCasillas: 5}, + {grilla:'casilla.futbolRobots2.png', + cantFilas: 5, + cantColumnas: 16, + alto:45,ancho:45} + ); + this.cuadricula.cambiarImagenInicio('casillainiciomono.png'); + + + var capy = new Capy(); + this.cuadricula.agregarActorEnPerspectiva(capy, 0, 0); + this.automata = new ActorCompuesto(0, 0, { subactores: [capy] }); + //this.automata.escala *= 3.2; + //this.automata.x -= 10; + this.automata.y += 30; +/* + this.automata = new Capy() + this.cuadricula.agregarActorEnPerspectiva(this.automata, 0, 0); +*/ + + this.cuadricula.forEachFila((nroFila: number) => this.agregarTacho(nroFila)) + this.cuadricula.forEachFila((nroFila: number) => this.agregarPapel(nroFila)) + + /* + 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; + */ + } + + agregarPapel(fila: number) { + var elPapel = new Papel() + this.cuadricula.agregarActor(elPapel, fila, 0) + elPapel.aprender(Flotar, { Desvio: 2 }); + var papel = new ActorCompuesto(0, 0, { subactores: [elPapel] }); + papel.escala *= 0.8; + } + + agregarTacho(fila: number) { + var elTacho = new Tacho() + this.cuadricula.agregarActor(elTacho, fila, this.definidor.tamanos[fila]-1) + var tacho = new ActorCompuesto(0, 0, { subactores: [elTacho] }); + tacho.escala *= 0.8; + } + + estaResueltoElProblema(){ + return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadObjetosConEtiqueta("TachoLleno"); + } + + hayTachosLlenosAlFinalDeLasFilas(){ + return this.ultimasCasillas().every( casilla => casilla.tieneActorConEtiqueta('TachoLleno') ); + } + + ultimasCasillas(){ + return this.cuadricula.filterCasillas(casilla => casilla.esFin()); + } + + +} From a0fe18a25db8a304a737d2fc000468b55bdb7bc2 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Tue, 24 Oct 2023 16:34:40 -0300 Subject: [PATCH 2/6] EstaResueltoElProblema --- src/actores/segundoCiclo/Capy/Tacho.ts | 17 +++++++- src/comportamientos/Interactuar.ts | 2 - src/escenas/ReciclandoPapeles.ts | 56 ++++++++++++++------------ 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/actores/segundoCiclo/Capy/Tacho.ts b/src/actores/segundoCiclo/Capy/Tacho.ts index b7b057b..7cb3d38 100644 --- a/src/actores/segundoCiclo/Capy/Tacho.ts +++ b/src/actores/segundoCiclo/Capy/Tacho.ts @@ -1,15 +1,30 @@ /// class Tacho extends ActorAnimado { + lleno; static _grilla = 'actor.tacho.png' constructor(lleno = false) { super(0, 0, {cantColumnas: 2}); this.definirAnimacion("vacio", [0], 1); this.definirAnimacion("lleno", [1], 1); - + this.lleno = lleno; if(lleno) this.cargarAnimacion("lleno") else this.cargarAnimacion("vacio") } + + vaciar() { + this.cargarAnimacion("vacio") + this.lleno = false; + } + + llenar() { + this.cargarAnimacion("lleno") + this.lleno = true; + } + + estaLleno(): boolean { + return this.lleno; + } } diff --git a/src/comportamientos/Interactuar.ts b/src/comportamientos/Interactuar.ts index c3e67b1..ec9ae29 100644 --- a/src/comportamientos/Interactuar.ts +++ b/src/comportamientos/Interactuar.ts @@ -87,8 +87,6 @@ class Interactuar extends ComportamientoAnimado { * Indica si existe una posible interacción entre dos actores. */ hayConQuienInteractuar(): boolean { - console.log(this.etiqueta()) - console.log(this.receptor) return this.receptor.tocando(this.etiqueta()) } diff --git a/src/escenas/ReciclandoPapeles.ts b/src/escenas/ReciclandoPapeles.ts index 40f5817..bfd4018 100644 --- a/src/escenas/ReciclandoPapeles.ts +++ b/src/escenas/ReciclandoPapeles.ts @@ -7,6 +7,9 @@ class ReciclandoPapeles extends EscenaActividad { cuadricula : CuadriculaMultiple; definidor: DefinidorColumnasFijo; + automata; + tachos; + papeles; iniciar() { this.fondo = new Fondo('fondo.capy.png',0,0); @@ -21,58 +24,61 @@ class ReciclandoPapeles extends EscenaActividad { alto:45,ancho:45} ); this.cuadricula.cambiarImagenInicio('casillainiciomono.png'); - - - var capy = new Capy(); - this.cuadricula.agregarActorEnPerspectiva(capy, 0, 0); + + var capy = new Capy() + capy.escala *= 0.5; this.automata = new ActorCompuesto(0, 0, { subactores: [capy] }); - //this.automata.escala *= 3.2; + this.cuadricula.agregarActor(this.automata, 0, 0); + this.automata.escala *= 0.3; //this.automata.x -= 10; - this.automata.y += 30; -/* - this.automata = new Capy() - this.cuadricula.agregarActorEnPerspectiva(this.automata, 0, 0); -*/ + this.automata.y += 40; + + this.papeles=[] + this.tachos=[] this.cuadricula.forEachFila((nroFila: number) => this.agregarTacho(nroFila)) this.cuadricula.forEachFila((nroFila: number) => this.agregarPapel(nroFila)) - /* - 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; - */ } agregarPapel(fila: number) { var elPapel = new Papel() this.cuadricula.agregarActor(elPapel, fila, 0) elPapel.aprender(Flotar, { Desvio: 2 }); - var papel = new ActorCompuesto(0, 0, { subactores: [elPapel] }); - papel.escala *= 0.8; + this.papeles.push( new ActorCompuesto(0, 0, { subactores: [elPapel] })); + //this.papel.escala *= 0.8; } agregarTacho(fila: number) { var elTacho = new Tacho() this.cuadricula.agregarActor(elTacho, fila, this.definidor.tamanos[fila]-1) - var tacho = new ActorCompuesto(0, 0, { subactores: [elTacho] }); - tacho.escala *= 0.8; + this.tachos.push( new ActorCompuesto(0, 0, { subactores: [elTacho] })); + this.tachos.escala *= 0.8; } estaResueltoElProblema(){ - return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadObjetosConEtiqueta("TachoLleno"); + return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos(); } hayTachosLlenosAlFinalDeLasFilas(){ - return this.ultimasCasillas().every( casilla => casilla.tieneActorConEtiqueta('TachoLleno') ); + return this.tachos.every( tacho => tacho.subactores[0].estaLleno() ); + } + + cantidadDeTachosLlenos(): number { + var cant: number = 0; + this.tachos.forEach( tacho => cant += tacho.subactores[0].estaLleno() ); + return cant; } ultimasCasillas(){ return this.cuadricula.filterCasillas(casilla => casilla.esFin()); } - + actualizar(): void { + super.actualizar(); + if( !this.tachos[this.automata.casillaActual().nroFila].subactores[0].estaLleno() && + this.automata.tieneAlgoEnLaMano() && + this.automata.casillaActual() === this.tachos[this.automata.casillaActual().nroFila].subactores[0].casillaActual() ) + this.tachos[this.automata.casillaActual().nroFila].subactores[0].llenar(); + } } From 8b0205cc17ba4da72412a68d65fa2d78e88a7bc1 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Tue, 24 Oct 2023 16:43:03 -0300 Subject: [PATCH 3/6] EstaResueltoElProblema --- src/escenas/ReciclandoPapeles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/escenas/ReciclandoPapeles.ts b/src/escenas/ReciclandoPapeles.ts index bfd4018..411f5e5 100644 --- a/src/escenas/ReciclandoPapeles.ts +++ b/src/escenas/ReciclandoPapeles.ts @@ -57,7 +57,7 @@ class ReciclandoPapeles extends EscenaActividad { } estaResueltoElProblema(){ - return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos(); + return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos() && !this.papeles.subactores.length; } hayTachosLlenosAlFinalDeLasFilas(){ From 3f77ecd14227434eb0360593d820b7da545608a1 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Tue, 24 Oct 2023 17:07:39 -0300 Subject: [PATCH 4/6] ChequeandoPapeles --- src/escenas/ReciclandoPapeles.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/escenas/ReciclandoPapeles.ts b/src/escenas/ReciclandoPapeles.ts index 411f5e5..cc8c34c 100644 --- a/src/escenas/ReciclandoPapeles.ts +++ b/src/escenas/ReciclandoPapeles.ts @@ -57,13 +57,19 @@ class ReciclandoPapeles extends EscenaActividad { } estaResueltoElProblema(){ - return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos() && !this.papeles.subactores.length; + return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos() && !this.cantidadDePapelesSinLevantar(); } hayTachosLlenosAlFinalDeLasFilas(){ return this.tachos.every( tacho => tacho.subactores[0].estaLleno() ); } + cantidadDePapelesSinLevantar(): number { + var cant: number = 0; + this.papeles.forEach( papel => cant += papel.subactores[0].vivo ); + return cant; + } + cantidadDeTachosLlenos(): number { var cant: number = 0; this.tachos.forEach( tacho => cant += tacho.subactores[0].estaLleno() ); From c4d12f17e14204f4067f52532b0a55594a89af29 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Tue, 24 Oct 2023 17:09:10 -0300 Subject: [PATCH 5/6] no comments --- src/escenas/ReciclandoPapeles.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/escenas/ReciclandoPapeles.ts b/src/escenas/ReciclandoPapeles.ts index cc8c34c..531d5ad 100644 --- a/src/escenas/ReciclandoPapeles.ts +++ b/src/escenas/ReciclandoPapeles.ts @@ -30,7 +30,6 @@ class ReciclandoPapeles extends EscenaActividad { this.automata = new ActorCompuesto(0, 0, { subactores: [capy] }); this.cuadricula.agregarActor(this.automata, 0, 0); this.automata.escala *= 0.3; - //this.automata.x -= 10; this.automata.y += 40; this.papeles=[] @@ -46,7 +45,6 @@ class ReciclandoPapeles extends EscenaActividad { this.cuadricula.agregarActor(elPapel, fila, 0) elPapel.aprender(Flotar, { Desvio: 2 }); this.papeles.push( new ActorCompuesto(0, 0, { subactores: [elPapel] })); - //this.papel.escala *= 0.8; } agregarTacho(fila: number) { From 2094cb66696aa53ba8b6e6ec76070e13183dfe01 Mon Sep 17 00:00:00 2001 From: Daniel Ferro Date: Wed, 25 Oct 2023 08:06:38 -0300 Subject: [PATCH 6/6] 1.4.15 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1685f7a..660b2e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pilas-bloques-exercises", - "version": "1.4.14", + "version": "1.4.15", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 75efc5c..528ebc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pilas-bloques-exercises", - "version": "1.4.14", + "version": "1.4.15", "description": "Exercises for Pilas Bloques", "homepage": "http://pilasbloques.program.ar", "author": {