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
60acdada
authored
Mar 13, 2025
by
José Pardo Madera
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Los objetos del inventario se renderizan.
parent
aee9c1da
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
6 deletions
Executable
Objeto.h
PantallaPrincipal.cpp
Personaje.cpp
Personaje.h
Sprite.cpp
Sprite.h
Executable
View file @
60acdada
No preview for this file type
Objeto.h
View file @
60acdada
...
...
@@ -32,4 +32,12 @@ public:
void
setEstado
(
State
estado_
){
estado
=
estado_
;}
State
getEstado
(){
return
estado
;}
void
setX
(
int
x
)
{
this
->
x
=
x
;
}
void
setY
(
int
y
)
{
this
->
y
=
y
;
}
};
PantallaPrincipal.cpp
View file @
60acdada
...
...
@@ -89,6 +89,7 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
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
();
}
}
...
...
@@ -110,6 +111,8 @@ void PantallaPrincipal::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
objetos
[
i
].
renderizar
(
renderer
,
tamx
,
tamy
);
}
Agapito
.
renderizar_inventario
(
renderer
,
tamx
,
tamy
);
texto
.
renderizar
(
renderer
,
50
,
50
,
tamx
,
tamy
);
}
Personaje.cpp
View file @
60acdada
...
...
@@ -55,6 +55,16 @@ void Personaje::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
movimientos
[
estado
][
indice_movimiento
].
renderizar
(
renderer
,
x
,
100
,
profundidades
,
profundidades
,
tamx
,
tamy
,
true
);
}
void
Personaje
::
renderizar_inventario
(
SDL_Renderer
*
renderer
,
int
tamx
,
int
tamy
)
{
for
(
int
i
=
0
;
i
<
numObjetos
;
i
++
)
{
inventario
[
i
]
->
setX
(
50
+
i
*
325
);
inventario
[
i
]
->
setY
(
800
);
inventario
[
i
]
->
renderizar
(
renderer
,
tamx
,
tamy
);
}
}
void
Personaje
::
comprobarColision
(
Hitbox
&
hitbox
){
if
(
hitbox
.
colisiona
(
x
,
profundidades
)){
switch
(
estado
)
{
...
...
Personaje.h
View file @
60acdada
...
...
@@ -29,18 +29,20 @@ class Personaje {
int
indice_movimiento
=
0
;
int
x
=
-
100
;
int
profundidades
=
600
;
public
:
array
<
optional
<
Objeto
>
,
3
>
inventario
;
int
numObjetos
=
0
;
int
x
=
-
100
;
int
profundidades
=
600
;
array
<
optional
<
Objeto
>
,
3
>
inventario
;
int
numObjetos
=
0
;
Personaje
();
void
move
(
Facing
direcion
);
void
renderizar
(
SDL_Renderer
*
renderer
,
int
tamx
,
int
tamy
);
void
renderizar_inventario
(
SDL_Renderer
*
renderer
,
int
tamx
,
int
tamy
);
void
comprobarColision
(
Hitbox
&
hitbox
);
...
...
Sprite.cpp
View file @
60acdada
...
...
@@ -6,6 +6,11 @@ Sprite::Sprite(std::string camino) : camino(camino) {
}
Sprite
::
Sprite
(
const
Sprite
&
other
)
:
camino
(
other
.
camino
)
{
}
SDL_Texture
*
Sprite
::
get_textura
(
SDL_Renderer
*
Renderer
)
{
if
(
this
->
texture
==
nullptr
)
{
this
->
texture
=
IMG_LoadTexture
(
Renderer
,
camino
.
c_str
());
...
...
Sprite.h
View file @
60acdada
...
...
@@ -14,9 +14,11 @@ class Sprite {
public
:
Sprite
(
std
::
string
camino
);
Sprite
(
const
Sprite
&
other
);
void
renderizar
(
SDL_Renderer
*
Renderer
,
int
x
,
int
y
,
int
w
,
int
h
,
int
tamx
,
int
tamy
,
bool
centrar
=
false
);
~
Sprite
();
};
#endif // SPRITE_H
\ No newline at end of file
#endif // SPRITE_H
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