Commit cd4cf2d2 by José Pardo Madera

Merge branch 'Develop' into 'master'

FINAL MERGE

See merge request !1
parents bd7903d4 08afde94
Showing with 1807 additions and 312 deletions
obj/
src/obj/
Agapito.desktop
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ProjectoMultimeda2025.iml" filepath="$PROJECT_DIR$/.idea/ProjectoMultimeda2025.iml" />
</modules>
</component>
</project>
\ No newline at end of file
#include "ColeccionPantallas.h"
#include "PantallaPrincipal.h"
#include "PantallaPrincipal2.h"
PantallaPrincipal pant;
PantallaPrincipal2 pant2;
vector<shared_ptr<Pantalla>> colPantallas={make_shared<PantallaPrincipal>(pant),make_shared<PantallaPrincipal2>(pant2)};
#pragma once
#include <vector>
#include <memory>
#include "GestorPantallas.h"
using namespace std;
extern vector<shared_ptr<Pantalla>> colPantallas;
\ No newline at end of file
No preview for this file type
#include "Objeto.h"
Hitbox & Objeto::getHitbox(){
return colision;
}
void Objeto::renderizar(SDL_Renderer *renderer, int tamx, int tamy){
std::cout<<"Buenos dias, soy el objeto y mi estado es " << estado<<std::endl;
switch (estado){
case normal:
sprite_normal.renderizar(renderer,x,y,w,h, tamx, tamy);
break;
case overworld:
sprite_overworld.renderizar(renderer,x,y,w,h, tamx, tamy);
break;
case overworld_highlight:
sprite_overworld_highlight.renderizar(renderer,x,y,w,h, tamx, tamy);
break;
}
}
#include "PantallaPrincipal.h"
#include "PantallaPrincipal2.h"
#include "ColeccionPantallas.h"
#include "Video.h"
PantallaPrincipal::PantallaPrincipal() :
fuente1("assets/OpenSans-Italic.ttf", 100),
Fondo1("assets/fondoHabitacion.jpg"),
colisionCambioPantalla(1500,-1500,2000,1300)
{
Sprite sprPlanta("assets/planta.png");
Sprite sprInterfaz("assets/InterfazPrincipal.png");
Sprite sprOjoAbierto("assets/ojoAbierto.png");
Sprite sprOjoCerrado("assets/ojoCerrado.png");
Hitbox hitPlanta(0,-10,1200,-1000000000);
Hitbox hitInterfaz(1920,0,900,700);
Hitbox hitOjo(1630,1248,997,839);
Objeto Ojo(sprOjoCerrado,sprOjoAbierto,sprOjoAbierto,hitOjo,1300,890,400,170,normal);
Objeto Planta(sprPlanta,sprPlanta,sprPlanta,hitPlanta,1200,400,300,400, normal);
Objeto Interfaz(sprInterfaz,sprInterfaz,sprInterfaz,hitInterfaz,0,870,1920,216,normal);
Hitbox hitFondo(1000000,-10000000,550,0);
Hitbox hitCama(500, 0, 1200,-10000000);
Hitbox hitDer(510, 450, 10000000,-10000000);
Hitbox hitIzq(-800, -900, 10000000,-10000000);
objetos.push_back(Interfaz);
indice_ojo = objetos.size();
objetos.push_back(Ojo);
objetos.push_back(Planta);
colisionesPasivas.push_back(hitPlanta);
colisionesInterfaz.push_back(hitOjo);
colisionesActivas.push_back(hitFondo);
colisionesActivas.push_back(hitCama);
colisionesActivas.push_back(hitDer);
colisionesActivas.push_back(hitIzq);
}
void PantallaPrincipal::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_LEFT:
Agapito.move(Izquierda);
break;
case SDLK_RIGHT:
Agapito.move(Derecha);
break;
case SDLK_UP:
Agapito.move(Fondo);
break;
case SDLK_DOWN:
Agapito.move(Frente);
break;
}
if(Agapito.comprobarColisionPasiva(colisionCambioPantalla)){
PantallaPrincipal2 pant;
handle.reemplazamePor(colPantallas[1]);
}
for(int i=0;i<colisionesActivas.size();i++){
Agapito.comprobarColision(colisionesActivas[i]);
}
{
bool checkColision=false;
int i=0;
while(!checkColision && i<colisionesPasivas.size()){
checkColision |= Agapito.comprobarColisionPasiva(colisionesPasivas[i]);
i++;
}
if(checkColision){
objetos[indice_ojo].setEstado(overworld);
}else objetos[indice_ojo].setEstado(normal);
}
break;
case SDL_MOUSEBUTTONDOWN:
{
int xRaton=0;
int zRaton=0;
SDL_GetMouseState(&xRaton, &zRaton);
xRaton*=(1920.0/handle.getTamX());
zRaton*=(1080.0/handle.getTamY());
cout<<"Raton x "<<xRaton<<" Raton z "<<zRaton<<endl;
if(colisionesInterfaz[0].colisiona(xRaton, zRaton) && objetos[indice_ojo].getEstado()==overworld){
Agapito.inventario[Agapito.numObjetos]=objetos[2];
Agapito.numObjetos++;
objetos.pop_back();
play_video("assets/videoPrueba", "es");
}
}
break;
case SDL_QUIT:
handle.removeAll();
}
}
}
void PantallaPrincipal::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
Texto texto(fuente1, "AGAPITO 3D", {255, 255, 255});
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
Agapito.renderizar(renderer, tamx, tamy);
for(int i=0;i<objetos.size();i++){
objetos[i].renderizar(renderer, tamx, tamy);
}
Agapito.renderizar_inventario(renderer, tamx, tamy);
texto.renderizar(renderer, 50, 50, tamx, tamy);
}
#include "PantallaPrincipal2.h"
#include "PantallaPrincipal.h"
#include "ColeccionPantallas.h"
PantallaPrincipal2::PantallaPrincipal2() :
fuente1("assets/OpenSans-Italic.ttf", 100),
Fondo1("assets/fondoPuerta.jpg"),
colisionCambioPantalla(1500,-1500,2000,1300)
{
Sprite sprInterfaz("assets/InterfazPrincipal.png");
Sprite sprOjoAbierto("assets/ojoAbierto.png");
Sprite sprOjoCerrado("assets/ojoCerrado.png");
Hitbox hitInterfaz(1920,0,900,700);
Hitbox hitOjo(1630,1248,997,839);
Objeto Ojo(sprOjoCerrado,sprOjoAbierto,sprOjoAbierto,hitOjo,1300,890,400,170,normal);
Objeto Interfaz(sprInterfaz,sprInterfaz,sprInterfaz,hitInterfaz,0,870,1920,216,normal);
objetos.push_back(Interfaz);
indice_ojo = objetos.size();
objetos.push_back(Ojo);
colisionesInterfaz.push_back(hitOjo);
}
void PantallaPrincipal2::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_LEFT:
Agapito.move(Izquierda);
break;
case SDLK_RIGHT:
Agapito.move(Derecha);
break;
case SDLK_UP:
Agapito.move(Fondo);
break;
case SDLK_DOWN:
Agapito.move(Frente);
break;
}
if(Agapito.comprobarColisionPasiva(colisionCambioPantalla)){
handle.reemplazamePor(colPantallas[0]);
}
for(int i=0;i<colisionesActivas.size();i++){
Agapito.comprobarColision(colisionesActivas[i]);
}
{
bool checkColision=false;
int i=0;
while(!checkColision && i<colisionesPasivas.size()){
checkColision |= Agapito.comprobarColisionPasiva(colisionesPasivas[i]);
i++;
}
if(checkColision){
objetos[indice_ojo].setEstado(overworld);
}else objetos[indice_ojo].setEstado(normal);
}
break;
case SDL_MOUSEBUTTONDOWN:
{
int xRaton=0;
int zRaton=0;
SDL_GetMouseState(&xRaton, &zRaton);
xRaton*=(1920.0/handle.getTamX());
zRaton*=(1080.0/handle.getTamY());
cout<<"Raton x "<<xRaton<<" Raton z "<<zRaton<<endl;
if(colisionesInterfaz[0].colisiona(xRaton, zRaton) && objetos[indice_ojo].getEstado()==overworld){
Agapito.inventario[Agapito.numObjetos]=objetos[2];
objetos.pop_back();
}
}
break;
case SDL_QUIT:
handle.removeAll();
}
}
}
void PantallaPrincipal2::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
Texto texto(fuente1, "AGAPITO 3D", {255, 255, 255});
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
Agapito.renderizar(renderer, tamx, tamy);
for(int i=0;i<objetos.size();i++){
objetos[i].renderizar(renderer, tamx, tamy);
}
texto.renderizar(renderer, 50, 50, tamx, tamy);
}
The file could not be displayed because it is too large.
WEBVTT
1
00:00:02.250 --> 00:00:02.750
*Esfuerzo*
2
00:00:03.500 --> 00:00:05.000
Maldita sea
3
00:00:06.250 --> 00:00:08.000
Quizás en este libro venga la solución
4
00:00:12.750 --> 00:00:13.000
*Libro cierre*
5
00:00:13.000 --> 00:00:14.000
Ya lo sé
6
00:00:16.000 --> 00:00:16.250
*Libro colapso*
7
00:01:02.500 --> 00:01:03.000
Uhm
8
00:01:03.500 --> 00:01:04.500
Si hago así
9
00:01:04.800 --> 00:01:06.000
¡Y hago así!
10
00:01:06.800 --> 00:01:07.600
¡Ah ha!
11
00:01:07.600 --> 00:01:08.500
¡Un candado!
12
00:01:08.600 --> 00:01:10.500
Con esto podré salir
WEBVTT
1
00:00:04.500 --> 00:00:05.250
¡Ah ha!
2
00:00:05.500 --> 00:00:06.750
¡Esto nos servirá!
3
00:00:06.750 --> 00:00:08.000
*Impacto cartera*
WEBVTT
1
00:00:01.500 --> 00:00:02.750
Aquí está
2
00:00:02.750 --> 00:00:04.500
Sabía que se me olvidaba algo
3
00:00:06.700 --> 00:00:07.750
¡Mi imán!
No preview for this file type
WEBVTT
1
00:00:00.250 --> 00:00:01.500
¿No hay calendario?
2
00:00:01.500 --> 00:00:02.500
¡Ha desaparecido!
3
00:00:02.750 --> 00:00:04.750
¡Ahora podré ir a por el ordenador!
WEBVTT
1
00:00:00.500 --> 00:00:01.600
*Esfuerzo imán*
2
00:00:01.600 --> 00:00:02.250
*Más esfuerzo imán*
3
00:00:02.500 --> 00:00:03.500
Maldita sea
4
00:00:03.500 --> 00:00:06.750
El poder del magnetismo no está a mi favor
5
00:00:06.750 --> 00:00:07.750
¡Maldita sea!
6
00:00:08.750 --> 00:00:09.750
*Llave cae al suelo*
7
00:00:12.750 --> 00:00:14.750
Parece que al final sí que me ha funcionado
8
00:00:14.750 --> 00:00:17.750
el poder del magnetismo
No preview for this file type
WEBVTT
1
00:00:00.000 --> 00:00:03.500
Agapito estaba comprobando su telefono
2
00:00:03.500 --> 00:00:05.000
cuando de repente...
3
00:00:05.500 --> 00:00:06.000
¡Oh!
4
00:00:06.800 --> 00:00:07.500
¿Que es esto?
5
00:00:08.240 --> 00:00:09.500
Es una revista
6
00:00:11.240 --> 00:00:13.000
Tiene ofertas de trabajo
7
00:00:13.500 --> 00:00:14.250
Huh
8
00:00:14.250 --> 00:00:16.250
Espero que no tengan nada que ver con
9
00:00:16.250 --> 00:00:17.250
las aceitunas
10
00:00:17.500 --> 00:00:19.750
Desde que una se cayo encima de mi abuelo
11
00:00:19.750 --> 00:00:21.250
les tengo mucho miedo
12
00:00:22.000 --> 00:00:22.800
ugh
13
00:00:22.800 --> 00:00:24.250
Supongo que podría ir
14
00:00:24.250 --> 00:00:25.250
¡Gracias, papá!
15
00:00:27.000 --> 00:00:28.800
Así que esta es la habitación donde
16
00:00:28.800 --> 00:00:30.000
van a probar si soy apto
17
00:00:30.000 --> 00:00:31.125
para el trabajo o no
18
00:00:31.250 --> 00:00:32.500
(Distorsionado) Jajaja
19
00:00:32.650 --> 00:00:33.000
¿¿Huh??
20
00:00:33.750 --> 00:00:35.000
¿Qué es esa voz?
21
00:00:35.250 --> 00:00:38.000
*Toques al micrófono*
22
00:00:35.700 --> 00:00:36.500
(Distorsionado) Eh..
23
00:00:36.500 --> 00:00:37.250
(Distorsionado) Esto no va
24
00:00:37.250 --> 00:00:38.000
(Distorsionado) ¡Ah!
25
00:00:38.750 --> 00:00:40.000
(Distorsionado) ¡Te he encerrado!
26
00:00:40.000 --> 00:00:41.000
¡Maldita sea!
27
00:00:41.000 --> 00:00:43.000
¡Me ha encerrado!
WEBVTT
1
00:00:02.000 --> 00:00:04.000
Seguro que ha cerrado la puerta
2
00:00:04.000 --> 00:00:06.000
no podré salir tan fácil
The file could not be displayed because it is too large.
WEBVTT
1
00:00:00.000 --> 00:00:01.000
¡Oh no!
2
00:00:01.000 --> 00:00:02.125
¡Un calendario!
3
00:00:02.125 --> 00:00:03.750
Desde que uno de estos mató
4
00:00:03.750 --> 00:00:05.125
a mi bisabuelo me dan mucho miedo
5
00:00:05.125 --> 00:00:06.250
*Tono de teléfono* aiaiai
6
00:00:06.250 --> 00:00:08.000
*Tono de teléfono* I'm your little butterfly
7
00:00:07.250 --> 00:00:08.125
¿Que está sonando?
8
00:00:08.000 --> 00:00:09.250
*Tono de teléfono* aiaiai I'm your little
9
00:00:10.000 --> 00:00:11.000
Hola bisabuelo
10
00:00:11.000 --> 00:00:13.000
¿Qué tal te va en las Bahamas?
11
00:00:13.500 --> 00:00:15.000
¡Ah! Me alegro
12
00:00:17.000 --> 00:00:19.000
Si hubiera alguna forma de quitarlo
13
00:00:19.000 --> 00:00:22.000
Quizás si cerrase los ojos
14
00:00:22.000 --> 00:00:22.750
es como si
15
00:00:22.750 --> 00:00:25.000
minimizase la pantalla de un ordenador
WEBVTT
1
00:00:00.550 --> 00:00:05.000
No puedo pasar
WEBVTT
1
00:00:01.000 --> 00:00:02.500
¡Oh! Una llave
2
00:00:02.500 --> 00:00:04.500
Con eso podría abrir el candado
3
00:00:05.800 --> 00:00:06.350
*Salto agapito*
4
00:00:06.750 --> 00:00:07.500
No llego
5
00:00:07.500 --> 00:00:08.500
Maldita sea
6
00:00:08.750 --> 00:00:10.000
¡Espera!
7
00:00:10.000 --> 00:00:11.000
Quizas con el iman
8
00:00:11.000 --> 00:00:12.000
que tenía en la cartera
9
00:00:12.000 --> 00:00:12.650
pueda llegar
10
00:00:12.650 --> 00:00:13.500
Pero...
11
00:00:13.500 --> 00:00:14.000
uh
12
00:00:14.000 --> 00:00:30.500
¿Donde tenía la cartera?
WEBVTT
1
00:00:00.500 --> 00:00:01.000
Uh
2
00:00:01.000 --> 00:00:02.500
¿Que habrá en esta caja?
3
00:00:03.000 --> 00:00:04.000
*esfuerzo intenso*
4
00:00:04.000 --> 00:00:05.500
*mas esfuerzo intenso*
5
00:00:05.500 --> 00:00:07.000
No puedo abrirla
6
00:00:07.450 --> 00:00:09.750
Quizas podría con este destornillador
7
00:00:09.750 --> 00:00:10.200
pero
8
00:00:10.200 --> 00:00:11.300
no se usar uno
9
00:00:11.300 --> 00:00:13.200
Tendría que buscar un manual
The file could not be displayed because it is too large.
WEBVTT
1
00:00:00.000 --> 00:00:02.400
*sonidos de liberación*
2
00:00:03.000 --> 00:00:03.600
¡Bien!
3
00:00:03.600 --> 00:00:05.400
El candado se ha abierto
4
00:00:05.400 --> 00:00:07.000
Ahora podre salir de aquí
5
00:00:12.500 --> 00:00:13.000
¡No!
6
00:00:13.000 --> 00:00:14.000
¡Tiene mi nariz!
7
00:00:26.500 --> 00:00:28.000
¿Donde estamos?
8
00:00:28.000 --> 00:00:29.700
Estamos en las olivas Agapito
9
00:00:29.700 --> 00:00:31.000
Este es tu nuevo trabajo
10
00:00:31.000 --> 00:00:31.300
¿Que?
11
00:00:31.300 --> 00:00:32.500
No puede ser...
12
00:00:34.000 --> 00:00:35.500
¿Papá? ¿Eres tu?
13
00:00:35.500 --> 00:00:36.000
Si
14
00:00:38.250 --> 00:00:39.000
Mira
15
00:00:45.000 --> 00:00:46.000
Lo ha hecho tu primillo
16
00:00:46.000 --> 00:00:46.500
el chico
17
00:00:47.000 --> 00:00:48.500
Estoy muy orgulloso de el
18
00:00:49.000 --> 00:00:50.500
Papa, ¿Te has operado la cara?
19
00:00:50.900 --> 00:00:51.700
Un nuevo peinado
20
00:00:52.700 --> 00:00:53.200
Y mira
21
00:00:53.400 --> 00:00:54.700
El tambien ha hecho unos creditos finales
No preview for this file type
No preview for this file type
The file could not be displayed because it is too large.
No preview for this file type
WEBVTT
1
00:00:01.600 --> 00:00:02.350
Pues ya está
2
00:00:02.600 --> 00:00:04.000
Ya he resuelto ese puzle
3
00:00:05.500 --> 00:00:06.750
No sé como lo he hecho
4
00:00:07.000 --> 00:00:08.900
O bien tengo que haber sido muy listo
5
00:00:08.900 --> 00:00:10.700
O bien tengo que haber hecho trampas
6
00:00:11.900 --> 00:00:13.000
*Agapito juicio*
7
00:00:13.900 --> 00:00:15.500
Nah, pero you nunca haría trampas
8
00:00:15.500 --> 00:00:16.500
Soy muy listo
9
00:00:16.800 --> 00:00:17.750
Ahora,
10
00:00:17.750 --> 00:00:19.500
¿Para que voy a necesitar esto?
11
00:00:20.000 --> 00:00:21.500
No creo que lo vuelva a necesitar
12
00:00:21.500 --> 00:00:30.500
*Cartera impacto*

459 KB | W: | H:

410 KB | W: | H:

assets/caja.png
assets/caja.png
assets/caja.png
assets/caja.png
  • 2-up
  • Swipe
  • Onion skin

517 KB | W: | H:

522 KB | W: | H:

assets/cajon.png
assets/cajon.png
assets/cajon.png
assets/cajon.png
  • 2-up
  • Swipe
  • Onion skin

130 KB | W: | H:

78.2 KB | W: | H:

assets/candado.png
assets/candado.png
assets/candado.png
assets/candado.png
  • 2-up
  • Swipe
  • Onion skin

533 KB | W: | H:

468 KB | W: | H:

assets/carne.png
assets/carne.png
assets/carne.png
assets/carne.png
  • 2-up
  • Swipe
  • Onion skin

492 KB | W: | H:

396 KB | W: | H:

assets/cartera.png
assets/cartera.png
assets/cartera.png
assets/cartera.png
  • 2-up
  • Swipe
  • Onion skin
No preview for this file type

127 KB | W: | H:

80 KB | W: | H:

assets/destornillador.png
assets/destornillador.png
assets/destornillador.png
assets/destornillador.png
  • 2-up
  • Swipe
  • Onion skin

72.4 KB | W: | H:

39.6 KB | W: | H:

assets/iman.png
assets/iman.png
assets/iman.png
assets/iman.png
  • 2-up
  • Swipe
  • Onion skin

207 KB | W: | H:

151 KB | W: | H:

assets/llaveHighlight.png
assets/llaveHighlight.png
assets/llaveHighlight.png
assets/llaveHighlight.png
  • 2-up
  • Swipe
  • Onion skin

148 KB | W: | H:

91.8 KB | W: | H:

assets/llaveNormal.png
assets/llaveNormal.png
assets/llaveNormal.png
assets/llaveNormal.png
  • 2-up
  • Swipe
  • Onion skin

366 KB | W: | H:

335 KB | W: | H:

assets/pantalla.png
assets/pantalla.png
assets/pantalla.png
assets/pantalla.png
  • 2-up
  • Swipe
  • Onion skin
No preview for this file type
No preview for this file type
No preview for this file type
@startuml
package "Utils" {
class Fuente {
Permite cargar la fuente de manera lazy y con RAII
..
- camino : string
- tamano_pt : int
- fuente : TTF_Font *
--
+ Fuente(camino : string, tamano_pt : int)
+ operator*() : TTF_Font *
+ ~Fuente()
}
class Hitbox {
+ xMaximo : int
+ xMinimo : int
+ zMaximo : int
+ zMinimo : int
+ colisiona(x, z) : bool
}
class Sprite {
- camino : string
- texture : SDL_Texture *
- get_textura(SDL_Renderer *) : SDL_Texture *
--
+ Sprite(camino : string)
+ Sprite(Sprite)
+ renderizar(SDL_Renderer *)
+ getCamino() : string
}
class Sonido {
- archivo : Mix_Music *
- tocada : bool
- acaba : bool
--
+ Sonido(ruta : string)
+ play()
+ pausar()
+ tocada() : bool
+ acabado() : bool
}
class Texto {
- texto : string
- fg : SDL_Color
- surface : SDL_Surface *
- texture : SDL_Texture *
--
+ renderizar(SDL_Renderer *)
}
Texto --* "1" Fuente
class Video {
{static} + play_video(nombre : string, idioma : string)
}
}
package "GestorPantallas" {
class Handle {
- idPantalla : int
- tamx : int
- tamy : int
- Handle(GestorPantallas &)
--
+ reemplazamePor(Pantalla)
+ addPantalla(Pantalla)
+ removeme()
+ removeAll()
+ getTamX() : int
+ getTamY() : int
+ pantallaMinimizada() : bool
}
class GestorPantallas {
- renderer : SLD_Renderer *
- window : SDL_Window *
- inicializarSDL() : bool
--
+ GestorPantallas(pantallaInicial : Pantalla)
+ mainLoop() : void
}
interface Pantalla {
+ manejarEntrada(Handle)
+ renderizar(SDL_Renderer *)
+ transparente() : bool
+ init()
}
GestorPantallas --* "1..*" Pantalla : "pantallas"
Handle --> GestorPantallas
}
class colPantallas <<Singleton>> {
+operator[](int) : Pantalla
..
+getPantallaPrincipal() : PantallaPrincipal
+getPantallaPrincipal2() : PantallaPrincipal2
+getPantallaFecha() : PantallaFecha
+getPantallaCama() : PantallaCama
+getPantallaTutorial() : PantallaTutorial
+getPantallaGracias() : PantallaGracias
}
colPantallas --o Pantalla
class Historia <<Singleton>> {
- limpiarEstado()
- siguienteEstado(Secuncia)
--
+ getEstadoActual() : Secuencia
+ pasarDeEstadoA(estadoActual : Secuencia, siguienteEstado : Secuencia)
+ soltarCartera : bool
}
enum Secuencia {
PreInicio
Inicio
CalendarioVisto
CalendiarioQuitado
PuzlePantallaResuleto
CajaVista
CajonAbierto
CajaAbierta
LlaveVista
CarteraRecuperada
ImanSacado
LlaveConseguida
}
Historia --* "1" Secuencia : "estadoActual"
package "Personaje" {
enum Facing {
Frente = 0
Derecha = 1
Izquierda = 2
Fondo = 3
}
class Personaje <<Singleton>> {
- momento_ultimo_movimiento : Instant
- x : int
- profundidades : int
- paso : bool
- primerPaso : bool
--
+ move(direcion : Facing)
+ renderizar(SDL_Renderer *)
+ renderizarInventario(SDL_Renderer *)
+ comprobarColision(Hitbox)
+ comprobarColisionPasiva(Hitbox) : bool
+ unsetInventario(pos : unsigned)
+ numObjetos() : unsigned
}
Personaje --* "16" Sprite
Personaje --* "1" Facing
Personaje --* Utils
}
package "Mano" {
class Mano {
- x : int
- profundidades : int
--
+ move(direcion : Facing)
+ renderizar(SDL_Renderer *)
+ renderizarCola(SDL_Renderer *)
+ comprobarColision(Hitbox)
+ comprobarColisionPasiva(Hitbox) : bool
+ reiniciar()
}
class Cola {
+ x : int
+ profundidades : int
}
Mano --* "4" Sprite : "manos"
Mano --* "4" Sprite : "brazos"
Mano --* "0..*" Cola : "cola"
Mano --* "1" Facing : "estado"
Cola --* "1" Sprite : "sprite"
}
class Objeto {
- x : int
- y : int
- w : int
- h : int
- funcionInteracion : bool fn(Objeto*, Handle)
--
+ renderizar(SDL_Renderer *)
+ interactuar(Handle) : bool
+ colisionarObjeto(Hitbox) : bool
}
Objeto --* "1" Sprite : "sprite"
Objeto --* "1" Hitbox : "hitbox"
package "Pantallas" {
class PantallaCama {
- carteraTocada : bool
- movimiento : bool
--
+ comprobarColisionesPasivas(Handle)
+ comprobarColisionesActivas()
}
PantallaCama ..|> Pantalla
PantallaCama --* "1" Mano.Mano
class PantallaFecha {
- combinacionActual : int[4]
- combinacionBuena : int[4]
- AgapitoTieneCarne : bool
}
PantallaFecha ..|> Pantalla
class PantallaGracias {}
PantallaGracias ..|> Pantalla
class PantallaInicio {
- iniciar(Handle)
}
PantallaInicio ..|> Pantalla
class PantallaMundo {
- siguientePantalla : size_t
- ojoAbierto : bool
- indiceColision : int
- comprobarColisionesPasivas()
- comprobarColisionesActivas()
- comprobarColisionSiguientePantalla(Handle)
- hooks : Hook[]
--
# PantallaMundo(posInicioPersonaje : int[2])
+ borrarElementos()
+ anadirObjeto(Objeto)
+ anadirHook(Hook)
+ setOjoAbierto(bool)
}
PantallaMundo ..|> Pantalla
class PantallaPrincipal {}
class PantallaPrincipal2 {}
PantallaPrincipal --|> PantallaMundo
PantallaPrincipal2 --|> PantallaMundo
class PantallaTutorial {}
PantallaTutorial ..|> Pantalla
}
Pantallas --> Utils
Personaje --* "3" Objeto
@enduml
CC = g++
CodeFiles = main.cpp Personaje.cpp Sprite.cpp Objeto.cpp Hitbox.cpp Texto.cpp GestorPantallas.cpp PantallaPrincipal.cpp PantallaPrincipal2.cpp ColeccionPantallas.cpp Video.cpp
bin = Executable
bin = Agapito.desktop
objdir = obj
code_files_in_obj = $(CodeFiles:%=$(objdir)/%)
objs = $(code_files_in_obj:.cpp=.o)
deps = $(code_files_in_obj:.cpp=.d)
srcdir = src
desktop_template = src/desktop_template.desktop
link_flags = -lSDL2 -lSDL2_image -lSDL2_ttf
compile_flags = -w $(link_flags)
$(bin): $(objs)
$(CC) $(objs) $(compile_flags) -o $@
$(objdir)/%.o : %.cpp | $(objdir)
$(CC) -c -o $@ $< $(compile_flags)
$(objdir)/%.d: %.cpp | $(objdir)
$(CC) -M $^ -MT $(patsubst %.d,%.o,$@) -MF $@
$(objdir):
mkdir obj
# Forzamos ejecutarlo siempre porque no sabemos cuando el código
# en src ha cambiado
$(bin): FORCE
$(MAKE) -C $(srcdir)
sed "s|CAMINO|$$(pwd)|" $(desktop_template) > $(bin)
chmod +x $(bin)
.PHONY: clean
clean:
- rm $(bin)
- rm -r obj
FORCE:
include $(deps)
clean:
$(MAKE) -C $(srcdir) clean
#include "ColeccionPantallas.h"
#include "Personaje.h"
#include <iostream>
#include "PantallaInicio.h"
Personaje Agapito;
PantallaPrincipal pant;
PantallaPrincipal2 pant2;
PantallaInicio pant3;
PantallaFecha pant4;
PantallaCama pant5;
PantallaTutorial pant6;
PantallaGracias pant7;
vector<shared_ptr<Pantalla>> colPantallas={
make_shared<PantallaPrincipal>(pant),
make_shared<PantallaPrincipal2>(pant2),
make_shared<PantallaInicio>(pant3),
make_shared<PantallaFecha>(pant4),
make_shared<PantallaCama>(pant5),
make_shared<PantallaTutorial>(pant6),
make_shared<PantallaGracias>(pant7)
};
shared_ptr<PantallaPrincipal> getPantalla1(){
return std::dynamic_pointer_cast<PantallaPrincipal>(colPantallas[0]);
}
shared_ptr<PantallaPrincipal2> getPantalla2(){
return std::dynamic_pointer_cast<PantallaPrincipal2>(colPantallas[1]);
};
shared_ptr<PantallaFecha> getPantallaFecha(){
return std::dynamic_pointer_cast<PantallaFecha>(colPantallas[3]);
}
shared_ptr<PantallaCama> getPantallaCama(){
return std::dynamic_pointer_cast<PantallaCama>(colPantallas[4]);
}
shared_ptr<PantallaTutorial> getPantallaTutorial(){
return std::dynamic_pointer_cast<PantallaTutorial>(colPantallas[5]);
}
shared_ptr<PantallaGracias> getPantallaGracias(){
return std::dynamic_pointer_cast<PantallaGracias>(colPantallas[6]);
}
#pragma once
#include <vector>
#include <memory>
#include "Personaje.h"
#include "GestorPantallas.h"
#include "PantallaPrincipal.h"
#include "PantallaPrincipal2.h"
#include "PantallaFecha.h"
#include "PantallaCama.h"
#include "PantallaTutorial.h"
#include "PantallaGracias.h"
using namespace std;
extern Personaje Agapito;
extern vector<shared_ptr<Pantalla>> colPantallas;
shared_ptr<PantallaPrincipal> getPantalla1();
shared_ptr<PantallaPrincipal2> getPantalla2();
shared_ptr<PantallaFecha> getPantallaFecha();
shared_ptr<PantallaCama> getPantallaCama();
shared_ptr<PantallaTutorial> getPantallaTutorial();
shared_ptr<PantallaGracias> getPantallaGracias();
No preview for this file type
#include "GestorPantallas.h"
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_mixer.h>
void Handle::reemplazamePor(shared_ptr<Pantalla> pant){
pant->init();
gestor.pantallas[idPantalla] =pant;
}
void Handle::addPantalla(shared_ptr<Pantalla> pant){
pant->init();
gestor.pantallas.push_back(pant);
}
......@@ -17,6 +20,13 @@ void Handle::removeAll(){
gestor.pantallas.clear();
}
bool Handle::pantallaMinimizada() {
Uint32 flags = SDL_GetWindowFlags(gestor.window);
return
(flags & SDL_WINDOW_MINIMIZED) != 0
|| (flags & SDL_WINDOW_HIDDEN) != 0;
}
void cambiar_buffers(SDL_Renderer *renderer) {
SDL_RenderPresent(renderer);
}
......@@ -25,7 +35,6 @@ void GestorPantallas::mainLoop(){
if (!inicializarSDL()) {
return;
}
std::cout << "Se ha iniciicididialci SDL" << std::endl;
while(!pantallas.empty()){
int tamx=0;
......@@ -62,6 +71,13 @@ bool GestorPantallas::inicializarSDL(){
return false;
}
if(Mix_Init(MIX_INIT_OGG | MIX_INIT_MP3) < 0){
std::cout << "Error at Mix_Init(Mix_INIT_OGG);"<<std::endl;
std::cout << "Error: " << SDL_GetError() << std::endl;
return false;
}
if (TTF_Init() < 0) {
std::cout << "Error at TTF_Init();"<<std::endl;
std::cout << "Error: " << SDL_GetError() << std::endl;
......
......@@ -26,6 +26,7 @@ class Handle{
void removeAll();
int getTamX(){return tamx;}
int getTamY(){return tamy;}
bool pantallaMinimizada();
};
......@@ -49,6 +50,10 @@ class Pantalla{
virtual void manejarEntrada(Handle &) = 0;
virtual void renderizar(SDL_Renderer*, int tamx, int tamy) = 0;
virtual bool transparente() = 0;
/// Se llama cuando se introduce a la pila
virtual void init() {};
virtual ~Pantalla() {};
};
#pragma once
class Historia{
public:
enum Secuencia {
PreInicio,
Inicio,
CalendarioVisto,
CalendarioQuitado,
PuzlePantallaResuelto,
CajaVista,
CajonAbierto,
CajaAbierta,
LlaveVista,
CarteraRecuperada,
ImanSacado,
LlaveConseguida
};
private:
Secuencia estadoActual=PreInicio;
void limpiarEstado();
void siguienteEstado(Secuencia estado);
public:
Secuencia getEstadoActual(){return estadoActual;}
void pasarDeEstadoA(Secuencia estadoAnterior, Secuencia estadoPosterior);
Historia();
bool soltarCartera=false;
};
extern Historia historiaPrincipal;
......@@ -2,7 +2,6 @@
bool Hitbox::colisiona(int x, int z){
if(x<=xMaximo && x>=xMinimo && z<=zMaximo && z>=zMinimo){
std::cout<<"Esta colisionando";
return true;
}else return false;
}
\ No newline at end of file
#include "Mano.h"
#include <string.h>
Mano::Mano() : manos(array<shared_ptr<Sprite>, 4> {
make_shared<Sprite>(Sprite("assets/manoAbajo.png")),
make_shared<Sprite>(Sprite("assets/manoDerecha.png")),
make_shared<Sprite>(Sprite("assets/manoIzquierda.png")),
make_shared<Sprite>(Sprite("assets/manoArriba.png")),
}) ,
brazos(array<shared_ptr<Sprite>, 4> {
make_shared<Sprite>(Sprite("assets/brazoAbajo.png")),
make_shared<Sprite>(Sprite("assets/brazoDerecha.png")),
make_shared<Sprite>(Sprite("assets/brazoIzquierda.png")),
make_shared<Sprite>(Sprite("assets/brazoArriba.png")),
})
{
}
void Mano::move(Facing direction) {
this->estado = direction;
cola.push_back(Cola(brazos[estado],x,profundidades));
switch (estado) {
case Frente:
profundidades += 209;
break;
case Derecha:
x += 220;
break;
case Izquierda:
x -= 220;
break;
case Fondo:
profundidades -= 209;
break;
}
}
void Mano::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
manos[estado]->renderizar(renderer, x, profundidades, 170, 170, tamx, tamy);
}
void Mano::renderizar_cola(SDL_Renderer *renderer, int tamx, int tamy) {
for (int i = 0; i < cola.size(); i++) {
cola[i].getSprite()->renderizar(renderer,cola[i].getX(),cola[i].getProfundidades(),170,170,tamx,tamy);
}
}
void Mano::comprobarColision(Hitbox &hitbox){
if(hitbox.colisiona(x, profundidades)){
cola.pop_back();
switch (estado) {
case Frente:
profundidades -= 209;
break;
case Derecha:
x -= 220;
break;
case Izquierda:
x += 220;
break;
case Fondo:
profundidades += 209;
break;
}
}
}
bool Mano::comprobarColisionPasiva(Hitbox &hitbox){
if(hitbox.colisiona(x,profundidades)){
return true;
}else return false;
}
void Mano::reiniciar(){
estado=Fondo;
x=870;
profundidades=650;
cola.clear();
}
#pragma once
#include <array>
#include <optional>
#include <SDL2/SDL.h>
#include <chrono>
#include "Sprite.h"
#include "Objeto.h"
#include "Hitbox.h"
#include "Sonido.h"
#include "Personaje.h"
using namespace std;
typedef std::chrono::time_point<std::chrono::system_clock> Instant;
class Mano {
class Cola{
public:
shared_ptr<Sprite> sprite;
int x;
int profundidades;
Cola(shared_ptr<Sprite> spr, int _x, int _prof): sprite(spr),x(_x),profundidades(_prof){}
shared_ptr<Sprite> getSprite(){return sprite;}
int getX(){return x;}
int getProfundidades(){return profundidades;}
};
array<shared_ptr<Sprite>, 4> manos;
array<shared_ptr<Sprite>, 4> brazos;
vector<Cola> cola;
Instant momento_ultimo_movimiento = std::chrono::system_clock::now();
Facing estado = Fondo;
int x = 870;
int profundidades = 650;
public:
Mano();
void move(Facing direcion);
void renderizar(SDL_Renderer *renderer, int tamx, int tamy);
void renderizar_cola(SDL_Renderer *renderer, int tamx, int tamy);
void comprobarColision (Hitbox &hitbox);
bool comprobarColisionPasiva (Hitbox &hitbox);
void setX(int x) {
this->x = x;
};
void setZ(int z) {
this->profundidades = z;
};
void reiniciar();
};
#include "Objeto.h"
Hitbox & Objeto::getHitbox(){
return colision;
}
void Objeto::renderizar(SDL_Renderer *renderer, int tamx, int tamy){
sprite_normal.renderizar(renderer,x,y,w,h, tamx, tamy);
}
bool Objeto::interactuar(Handle& handle){
if (funcionInteraccion != nullptr) {
return funcionInteraccion(this, handle);
}
return false;
}
bool Objeto::colisionaObjeto(int x, int z){
return colision.colisiona(x,z);
}
#pragma once
#include "GestorPantallas.h"
#include "Sprite.h"
#include "Hitbox.h"
#include <iostream>
enum State {
normal = 0,
overworld = 1,
overworld_highlight = 2
};
class Objeto {
Sprite sprite_normal;
Sprite sprite_overworld;
Sprite sprite_overworld_highlight;
Hitbox colision;
State estado=normal;
int x;
int y;
int w;
int h;
bool (*funcionInteraccion)(Objeto*,Handle&);
public:
Hitbox &getHitbox();
Objeto(Sprite sprite_normal_, Sprite sprite_overworld_, Sprite sprite_overworld_highlight_, Hitbox colision_, int _x, int _y, int _w, int _h, State estado_):
sprite_normal(sprite_normal_), sprite_overworld(sprite_overworld_),
sprite_overworld_highlight(sprite_overworld_highlight_), colision(colision_), x(_x), y(_y), w(_w), h(_h), estado(estado_){}
Objeto(Sprite sprite_normal_, Hitbox colision_, int _x, int _y, int _w, int _h, bool (*_funcionInteraccion)(Objeto*, Handle&)):
sprite_normal(sprite_normal_), colision(colision_), x(_x), y(_y), w(_w), h(_h), funcionInteraccion(_funcionInteraccion){}
void renderizar(SDL_Renderer *renderer, int tamx, int tamy);
void setEstado(State estado_){estado=estado_;}
State getEstado(){return estado;}
void setX(int x) {
this->x = x;
......@@ -40,4 +31,8 @@ public:
void setY(int y) {
this->y = y;
}
bool interactuar(Handle &handle);
bool colisionaObjeto(int x, int z);
};
#pragma once
#include "GestorPantallas.h"
#include "Sprite.h"
#include "Hitbox.h"
#include <iostream>
#include "Objeto.h"
class ObjetoCombinable: public Objeto {
bool pulsado=false;
public:
using Objeto::Objeto;
bool getPulsado(){return pulsado;}
void setPulsado(bool pul){pulsado=pul;}
};
#include "PantallaCama.h"
#include "ColeccionPantallas.h"
#include "Historia.h"
#include <iostream>
PantallaCama::PantallaCama() :
fuente1("assets/OpenSans-Italic.ttf", 100),
Fondo1("assets/puzleMover.jpeg"),
atras(Sprite("assets/volver.png"),Hitbox(1800,1600,300,200),1600,200,100,100,nullptr),
reiniciar(Sprite("assets/reiniciar.png"),Hitbox(1700,1600,500,400),1600,400,100,100,nullptr),
cartera("assets/cartera.png"),
obstaculos{
Sprite("assets/nuez.png"),
Sprite("assets/marcianito.png"),
Sprite("assets/pez.png"),
Sprite("assets/bomba.png"),
Sprite("assets/cabezaRata.png"),
Sprite("assets/senorCongelado.png"),
Sprite("assets/piano.png"),
Sprite("assets/pinguino.png")
},
hitObs{
Hitbox(420,0,10000,0),
Hitbox(10000,1480,10000,0),
Hitbox(10000,0,10000,800),
Hitbox(10000,0,19,-2000),
Hitbox(840,400,840,400),
Hitbox(1280,840,630,430),
Hitbox(1300,1050,430,230),
Hitbox(835,610,230,0)
},
hitCartera(630,0,230,0),
cancion("assets/LonesomeJourneyByKeysOfMoonMusic.wav",true),
sonidoBoton("assets/SonidoClicar.wav",false)
{
for(int i=0;i<colPantallas.size();i++){
if(PantallaMundo *p= dynamic_cast<PantallaMundo*>(colPantallas[i].get())){
p->setOjoAbierto(false);
}
}
}
void PantallaCama::comprobarColisionesActivas() {
for(int i=0;i<hitObs.size();i++){
mano.comprobarColision(hitObs[i]);
}
for(int i=0;i<colisionesParedes.size();i++){
mano.comprobarColision(colisionesParedes[i]);
}
}
void PantallaCama::comprobarColisionesPasivas(Handle &handle) {
if(mano.comprobarColisionPasiva(hitCartera)){
cancion.pausar();
historiaPrincipal.pasarDeEstadoA(historiaPrincipal.LlaveVista,historiaPrincipal.CarteraRecuperada);
handle.removeme();
}
}
void PantallaCama::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_LEFT:
if(movimiento)mano.move(Izquierda);
movimiento=false;
break;
case SDLK_RIGHT:
if(movimiento)mano.move(Derecha);
movimiento=false;
break;
case SDLK_UP:
if(movimiento) mano.move(Fondo);
movimiento=false;
break;
case SDLK_DOWN:
if(movimiento)mano.move(Frente);
movimiento=false;
break;
};
comprobarColisionesActivas();
comprobarColisionesPasivas(handle);
break;
case SDL_KEYUP:
movimiento=true;
break;
case SDL_MOUSEBUTTONDOWN:
{
int xRaton=0;
int zRaton=0;
SDL_GetMouseState(&xRaton, &zRaton);
xRaton*=(1920.0/handle.getTamX());
zRaton*=(1080.0/handle.getTamY());
int contadorCorrectos=0;
if(atras.colisionaObjeto(xRaton,zRaton)){
sonidoBoton.play();
cancion.pausar();
movimiento=true;
handle.removeme();
}
else if(reiniciar.colisionaObjeto(xRaton,zRaton)){
mano.reiniciar();
movimiento=true;
}
}
break;
case SDL_QUIT:
handle.removeAll();
}
}
}
void PantallaCama::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
if(!cancion.getTocada() && sonidoBoton.acabado()){
cancion.play();
}
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
cartera.renderizar(renderer,430,60,170,170,tamx,tamy);
obstaculos[0].renderizar(renderer,650,60,170,170,tamx,tamy);
obstaculos[1].renderizar(renderer,430,440,170,170,tamx,tamy);
obstaculos[2].renderizar(renderer,430,650,170,170,tamx,tamy);
obstaculos[3].renderizar(renderer,650,440,170,170,tamx,tamy);
obstaculos[4].renderizar(renderer,650,650,170,170,tamx,tamy);
obstaculos[5].renderizar(renderer,870,440,170,170,tamx,tamy);
obstaculos[6].renderizar(renderer,1090,440,170,170,tamx,tamy);
obstaculos[7].renderizar(renderer,1090,250,170,170,tamx,tamy);
mano.renderizar_cola(renderer,tamx,tamy);
mano.renderizar(renderer,tamx,tamy);
Sprite brazoExtra("assets/brazoArriba.png");
brazoExtra.renderizar(renderer,870,830,170,170,tamx,tamy);
atras.renderizar(renderer,tamx,tamy);
reiniciar.renderizar(renderer,tamx,tamy);
}
#pragma once
#include "GestorPantallas.h"
#include <vector>
#include "Objeto.h"
#include "Sprite.h"
#include "Texto.h"
#include "Fuente.h"
#include "Sonido.h"
#include "Mano.h"
class PantallaCama : public Pantalla {
vector<Sprite> obstaculos;
Sprite cartera;
Hitbox hitCartera;
vector<Hitbox> hitObs;
vector<Hitbox> colisionesParedes;
Objeto atras;
Objeto reiniciar;
Fuente fuente1;
Sprite Fondo1;
Sonido cancion;
Sonido sonidoBoton;
Mano mano;
bool carteraTocada=false;
bool movimiento=true;
public:
PantallaCama();
void manejarEntrada(Handle &) override;
void renderizar(SDL_Renderer *, int tamx, int tamy) override;
bool transparente() override {
return false;
};
void comprobarColisionesPasivas(Handle &handle);
void comprobarColisionesActivas();
};
#include "PantallaFecha.h"
#include "ColeccionPantallas.h"
#include "Historia.h"
#include <iostream>
PantallaFecha::PantallaFecha() :
fuente1("assets/OpenSans-Italic.ttf", 100),
Fondo1("assets/pantallaPantalla.png"),
Carne("assets/carneNombre.png"),
atras(Sprite("assets/volver.png"),Hitbox(1800,1600,300,200),1600,200,100,100,nullptr),
botonesArriba{
Objeto(Sprite("assets/flechaArriba.jpg"),Hitbox(500,300,300,200),300,200,200,100,nullptr),
Objeto(Sprite("assets/flechaArriba.jpg"),Hitbox(800,600,300,200),600,200,200,100,nullptr),
Objeto(Sprite("assets/flechaArriba.jpg"),Hitbox(1250,1050,300,200),1050,200,200,100,nullptr),
Objeto(Sprite("assets/flechaArriba.jpg"),Hitbox(1525,1325,300,200),1325,200,200,100,nullptr)
},
botonesAbajo{
Objeto(Sprite("assets/flechaAbajo.jpg"),Hitbox(500,300,700,600),300,600,200,100,nullptr),
Objeto(Sprite("assets/flechaAbajo.jpg"),Hitbox(800,600,700,600),600,600,200,100,nullptr),
Objeto(Sprite("assets/flechaAbajo.jpg"),Hitbox(1250,1050,700,600),1050,600,200,100,nullptr),
Objeto(Sprite("assets/flechaAbajo.jpg"),Hitbox(1525,1325,700,600),1325,600,200,100,nullptr)
},
combinacionBuena{1,3,0,3},
combinacionActual{0,0,0,0},
sonidoBoton("assets/SonidoClicar.wav",false),
cancion("assets/LonesomeJourneyByKeysOfMoonMusic.wav",true)
{
}
void PantallaFecha::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case 13:
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
{
int xRaton=0;
int zRaton=0;
SDL_GetMouseState(&xRaton, &zRaton);
xRaton*=(1920.0/handle.getTamX());
zRaton*=(1080.0/handle.getTamY());
int contadorCorrectos=0;
if(atras.colisionaObjeto(xRaton,zRaton)){
sonidoBoton.play();
cancion.pausar();
handle.removeme();
}
for(int i=0;i<4;i++){
if(botonesArriba[i].colisionaObjeto(xRaton, zRaton)){
combinacionActual[i]=(combinacionActual[i]+1)%10;
}
if(botonesAbajo[i].colisionaObjeto(xRaton, zRaton)){
if(combinacionActual[i]==0){
combinacionActual[i]=9;
}else{
combinacionActual[i]=combinacionActual[i]-1;
}
}
if(combinacionActual[i]==combinacionBuena[i]) contadorCorrectos++;
}
if(contadorCorrectos==4){
cancion.pausar();
historiaPrincipal.pasarDeEstadoA(Historia::CalendarioQuitado,Historia::PuzlePantallaResuelto);
handle.removeme();
}
}
break;
case SDL_QUIT:
handle.removeAll();
}
}
}
void PantallaFecha::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
if(!cancion.getTocada() && sonidoBoton.acabado()){
cancion.play();
}
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
atras.renderizar(renderer,tamx,tamy);
for(int i=0;i<4;i++){
botonesAbajo[i].renderizar(renderer, tamx, tamy);
botonesArriba[i].renderizar(renderer,tamx,tamy);
}
if(AgapitoTieneCarne){
Carne.renderizar(renderer, 1248, 800, 400, 300, tamx,tamy);
}
Texto num1(fuente1,std::to_string(combinacionActual[0]).c_str(),{0,0,0});
Texto num2(fuente1,std::to_string(combinacionActual[1]).c_str(),{0,0,0});
Texto num3(fuente1,std::to_string(combinacionActual[2]).c_str(),{0,0,0});
Texto num4(fuente1,std::to_string(combinacionActual[3]).c_str(),{0,0,0});
num1.renderizar(renderer,375,300,tamx,tamy);
num2.renderizar(renderer,675,300,tamx,tamy);
num3.renderizar(renderer,1125,300,tamx,tamy);
num4.renderizar(renderer,1400,300,tamx,tamy);
}
#pragma once
#include "GestorPantallas.h"
#include <vector>
#include "Objeto.h"
#include "Sprite.h"
#include "Texto.h"
#include "Fuente.h"
#include "Sonido.h"
class PantallaFecha : public Pantalla {
Objeto botonesArriba[4];
Objeto botonesAbajo[4];
vector<Hitbox> colisionesBotones;
Objeto atras;
Fuente fuente1;
Sprite Fondo1;
Sprite Carne;
int combinacionActual[4];
int combinacionBuena[4];
bool AgapitoTieneCarne = false;
Sonido sonidoBoton;
Sonido cancion;
public:
PantallaFecha();
void manejarEntrada(Handle &) override;
void renderizar(SDL_Renderer *, int tamx, int tamy) override;
bool transparente() override {
return false;
};
void setTieneCarne(bool tieneCarne) {
AgapitoTieneCarne = tieneCarne;
}
bool tieneCarne() {
return AgapitoTieneCarne;
}
};
#include "ColeccionPantallas.h"
#include "PantallaGracias.h"
#include "Video.h"
#include "Historia.h"
PantallaGracias::PantallaGracias() :
Fondo1("assets/gracias.jpeg")
{}
void PantallaGracias::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
handle.removeAll();
}
}
}
void PantallaGracias::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
}
#pragma once
#include "GestorPantallas.h"
#include <vector>
#include "Objeto.h"
#include "Sprite.h"
#include "Texto.h"
#include "Fuente.h"
#include "Sonido.h"
class PantallaGracias : public Pantalla {
Sprite Fondo1;
void iniciar(Handle &);
public:
PantallaGracias();
void manejarEntrada(Handle &) override;
void renderizar(SDL_Renderer *, int tamx, int tamy) override;
bool transparente() override {
return false;
};
};
#include "ColeccionPantallas.h"
#include "PantallaInicio.h"
#include "Video.h"
#include "Historia.h"
PantallaInicio::PantallaInicio() :
fuente1("assets/OpenSans-Italic.ttf", 100),
Fondo1("assets/PantallaInicio.jpg"),
colisionCambioPantalla(1500,-1500,2000,1300),
AnuncioTitulo("assets/AgapitoTitulo.wav",false),
Cancion("assets/Spring In My Step - Silent Partner.wav",true),
sonidoBoton("assets/SonidoClicar.wav",false)
{
Sprite sprIniciarPartida("assets/iniciarPartida.png");
Hitbox hitIniciarPartida(1247,649,699,501);
Objeto IniciarPartida(sprIniciarPartida,hitIniciarPartida,650,500,600,200,nullptr);
objetos.push_back(IniciarPartida);
colisionesInterfaz.push_back(hitIniciarPartida);
}
void PantallaInicio::iniciar(Handle &handle) {
Cancion.pausar();
handle.reemplazamePor(colPantallas[5]);
}
void PantallaInicio::manejarEntrada(Handle &handle) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case 13:
sonidoBoton.play();
iniciar(handle);
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
{
int xRaton=0;
int zRaton=0;
SDL_GetMouseState(&xRaton, &zRaton);
xRaton*=(1920.0/handle.getTamX());
zRaton*=(1080.0/handle.getTamY());
if(colisionesInterfaz[0].colisiona(xRaton, zRaton) ){
sonidoBoton.play();
iniciar(handle);
}
}
break;
case SDL_QUIT:
handle.removeAll();
}
}
}
void PantallaInicio::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
if(!AnuncioTitulo.getTocada()){
AnuncioTitulo.play();
}
if(AnuncioTitulo.acabado() && !Cancion.getTocada()){
Cancion.play();
}
Fondo1.renderizar(renderer, 0, 0,1920,1080, tamx, tamy);
for(int i=0;i<objetos.size();i++){
objetos[i].renderizar(renderer, tamx, tamy);
}
}
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment