Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
José Pardo Madera
/
ProjectoMultimeda2025
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e77b8a5e
authored
Apr 10, 2025
by
José Pardo Madera
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Interacción con los objetos del inventario
parent
f86bfd35
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
7 deletions
Executable
Historia.cpp
Objeto.cpp
PantallaFecha.h
PantallaMundo.cpp
Executable
View file @
e77b8a5e
No preview for this file type
Historia.cpp
View file @
e77b8a5e
...
...
@@ -34,11 +34,11 @@ static Objeto generarObjetoCalendario() {
return
Calendario
;
}
static
Objeto
generarObje
ctoCartera
(
bool
(
*
funct
ion
)(
Objeto
*
,
Handle
&
))
{
static
Objeto
generarObje
toCartera
(
bool
(
*
func
ion
)(
Objeto
*
,
Handle
&
))
{
Sprite
sprCartera
(
"assets/cartera.png"
);
Hitbox
hitCartera
(
0
,
0
,
0
,
0
);
// Trivial, solo esta en el inventario
Objeto
Cartera
(
sprCartera
,
sprCartera
,
sprCartera
,
hitCartera
,
400
,
150
,
150
,
250
,
normal
,
nullptr
);
Objeto
Cartera
(
sprCartera
,
sprCartera
,
sprCartera
,
hitCartera
,
400
,
150
,
150
,
250
,
normal
,
funcion
);
return
Cartera
;
}
...
...
@@ -54,6 +54,16 @@ static Objeto generarObjetoPuerta() {
return
Puerta
;
}
static
Objeto
generarObjetoCarne
()
{
Sprite
sprCarne
(
"assets/carne.png"
);
Hitbox
hitCarne
(
0
,
0
,
0
,
0
);
// Trivial, solo esta en el inventario
Objeto
Carne
(
sprCarne
,
sprCarne
,
sprCarne
,
hitCarne
,
400
,
150
,
150
,
250
,
normal
,
nullptr
);
return
Carne
;
}
static
void
iniciarInicio
()
{
play_video
(
"assets/Encerrado"
,
"es"
);
auto
funcionPantalla
=
[](
Objeto
*
Pantalla
,
Handle
&
handle
)
->
bool
{
...
...
@@ -73,6 +83,9 @@ static void iniciarInicio() {
getPantalla1
()
->
anadirObjeto
(
Pantalla
);
getPantalla1
()
->
anadirObjeto
(
Calendario
);
getPantalla2
()
->
anadirObjeto
(
Puerta
);
Agapito
.
inventario
[
0
]
=
generarObjetoCartera
(
nullptr
);
Agapito
.
numObjetos
=
1
;
}
...
...
@@ -105,6 +118,8 @@ static void iniciarCalendarioVisto(){
getPantalla1
()
->
anadirHook
(
funcionComprobarPantallaMinimizada
);
Agapito
.
inventario
[
0
]
=
generarObjetoCartera
(
nullptr
);
Agapito
.
numObjetos
=
1
;
}
...
...
@@ -124,6 +139,14 @@ static void iniciarCalendarioQuitado(){
getPantalla2
()
->
anadirObjeto
(
Puerta
);
auto
funcionCartera
=
[](
Objeto
*
Pantalla
,
Handle
&
handle
)
->
bool
{
getPantallaFecha
()
->
setTieneCarne
(
true
);
Agapito
.
inventario
[
0
]
=
generarObjetoCarne
();
return
false
;
};
Agapito
.
inventario
[
0
]
=
generarObjetoCartera
(
funcionCartera
);
Agapito
.
numObjetos
=
1
;
}
static
void
iniciarPuzlePantallaResuelto
(){
...
...
Objeto.cpp
View file @
e77b8a5e
...
...
@@ -20,7 +20,10 @@ void Objeto::renderizar(SDL_Renderer *renderer, int tamx, int tamy){
}
bool
Objeto
::
interactuar
(
Handle
&
handle
){
if
(
funcionInteraccion
!=
nullptr
)
{
return
funcionInteraccion
(
this
,
handle
);
}
return
false
;
}
...
...
PantallaFecha.h
View file @
e77b8a5e
...
...
@@ -19,7 +19,7 @@ class PantallaFecha : public Pantalla {
Sprite
Fondo1
;
int
combinacionActual
[
4
];
int
combinacionBuena
[
4
];
bool
AgapitoTieneCarne
;
bool
AgapitoTieneCarne
=
false
;
...
...
@@ -33,4 +33,8 @@ public:
bool
transparente
()
override
{
return
false
;
};
void
setTieneCarne
(
bool
tieneCarne
)
{
AgapitoTieneCarne
=
tieneCarne
;
}
};
PantallaMundo.cpp
View file @
e77b8a5e
...
...
@@ -16,10 +16,10 @@ PantallaMundo::PantallaMundo(const char *fondo, Hitbox colisionCambioPantalla, s
Sprite
(
"assets/ojoCerrado.png"
)
}),
colisionesInterfaz
({
Hitbox
(
1630
,
1248
,
997
,
839
),
Hitbox
(
1630
,
1248
,
997
,
839
),
Hitbox
(
1630
,
1248
,
997
,
839
),
Hitbox
(
1
630
,
1248
,
997
,
839
)
Hitbox
(
1630
,
1248
,
997
,
839
),
Hitbox
(
320
,
80
,
1050
,
900
),
Hitbox
(
666
,
415
,
1050
,
900
),
Hitbox
(
1
015
,
780
,
1050
,
900
)
}),
posicion_inicio_personaje
(
posicionInicioPersonaje
)
{};
...
...
@@ -79,11 +79,22 @@ void PantallaMundo::manejarEntrada(Handle &handle) {
xRaton
*=
(
1920.0
/
handle
.
getTamX
());
zRaton
*=
(
1080.0
/
handle
.
getTamY
());
cout
<<
"Raton x "
<<
xRaton
<<
" Raton z "
<<
zRaton
<<
endl
;
// Activar el ojo si esta abierto
if
(
colisionesInterfaz
[
0
].
colisiona
(
xRaton
,
zRaton
)
&&
ojo_abierto
){
// Se llama a la funcion de interacion del objeto
if
(
objetos
[
indiceColision
].
interactuar
(
handle
)){
// Si devuelve true se elimina
objetos
.
erase
(
objetos
.
begin
()
+
indiceColision
);
}
}
// Colisiones con los objetos del inventario
for
(
int
i
=
0
;
i
<
Agapito
.
numObjetos
;
i
++
)
{
if
(
colisionesInterfaz
[
i
+
1
].
colisiona
(
xRaton
,
zRaton
))
{
Agapito
.
inventario
[
i
]
->
interactuar
(
handle
);
}
}
}
break
;
case
SDL_QUIT
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment