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
aee9c1da
authored
Mar 13, 2025
by
Jaime de la Chica Bergillos
Browse files
Options
_('Browse Files')
Download
Plain Diff
Trabajo unificado de hitboxes
parents
831be9e1
3b2ddebe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
10 deletions
Executable
Objeto.h
PantallaPrincipal.cpp
PantallaPrincipal.h
Executable
View file @
aee9c1da
No preview for this file type
Objeto.h
View file @
aee9c1da
...
...
@@ -31,4 +31,5 @@ public:
void
renderizar
(
SDL_Renderer
*
renderer
,
int
tamx
,
int
tamy
);
void
setEstado
(
State
estado_
){
estado
=
estado_
;}
State
getEstado
(){
return
estado
;}
};
PantallaPrincipal.cpp
View file @
aee9c1da
...
...
@@ -10,22 +10,39 @@ PantallaPrincipal::PantallaPrincipal() :
Sprite
sprOjoCerrado
(
"assets/ojoCerrado.png"
);
Hitbox
hitPlanta
(
0
,
-
10
,
1200
,
-
1000000000
);
Hitbox
hitInterfaz
(
1920
,
0
,
900
,
700
);
Hitbox
hitCama
(
10
,
50
,
300
,
300
);
Hitbox
hitFondo
(
1000000
,
-
10000000
,
50
,
0
);
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
);
colisionesActivas
.
push_back
(
hitCama
);
colisionesActivas
.
push_back
(
hitFondo
);
colisionesActivas
.
push_back
(
hitInterfaz
);
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
)
{
...
...
@@ -54,12 +71,12 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
bool
checkColision
=
false
;
int
i
=
0
;
while
(
!
checkColision
&&
i
<
colisionesPasivas
.
size
()){
checkColision
=
Agapito
.
comprobarColisionPasiva
(
colisionesPasivas
[
i
]);
checkColision
|=
Agapito
.
comprobarColisionPasiva
(
colisionesPasivas
[
i
]);
i
++
;
}
if
(
checkColision
){
objetos
[
1
].
setEstado
(
overworld
);
}
else
objetos
[
1
].
setEstado
(
normal
);
objetos
[
indice_ojo
].
setEstado
(
overworld
);
}
else
objetos
[
indice_ojo
].
setEstado
(
normal
);
}
break
;
case
SDL_MOUSEBUTTONDOWN
:
...
...
@@ -70,7 +87,7 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
xRaton
*=
(
1920.0
/
handle
.
getTamX
());
zRaton
*=
(
1080.0
/
handle
.
getTamY
());
cout
<<
"Raton x "
<<
xRaton
<<
" Raton z "
<<
zRaton
<<
endl
;
if
(
colisionesInterfaz
[
0
].
colisiona
(
xRaton
,
zRaton
)){
if
(
colisionesInterfaz
[
0
].
colisiona
(
xRaton
,
zRaton
)
&&
objetos
[
indice_ojo
].
getEstado
()
==
overworld
){
Agapito
.
inventario
[
Agapito
.
numObjetos
]
=
objetos
[
2
];
objetos
.
pop_back
();
}
...
...
@@ -87,11 +104,12 @@ void PantallaPrincipal::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
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
(
renderer
,
tamx
,
tamy
);
texto
.
renderizar
(
renderer
,
50
,
50
,
tamx
,
tamy
);
}
PantallaPrincipal.h
View file @
aee9c1da
...
...
@@ -17,6 +17,8 @@ class PantallaPrincipal : public Pantalla {
Sprite
Fondo1
;
Personaje
Agapito
;
int
indice_ojo
=
0
;
public
:
PantallaPrincipal
();
...
...
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