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
3b2ddebe
authored
Mar 13, 2025
by
José Pardo Madera
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Posicionado Hitboxes.
parent
8ccfc2d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
Executable
PantallaPrincipal.cpp
PantallaPrincipal.h
Executable
View file @
3b2ddebe
No preview for this file type
PantallaPrincipal.cpp
View file @
3b2ddebe
...
@@ -10,20 +10,31 @@ PantallaPrincipal::PantallaPrincipal() :
...
@@ -10,20 +10,31 @@ PantallaPrincipal::PantallaPrincipal() :
Sprite
sprOjoCerrado
(
"assets/ojoCerrado.png"
);
Sprite
sprOjoCerrado
(
"assets/ojoCerrado.png"
);
Hitbox
hitPlanta
(
350
,
80
,
450
,
120
);
Hitbox
hitPlanta
(
350
,
80
,
450
,
120
);
Hitbox
hitInterfaz
(
1920
,
0
,
900
,
700
);
Hitbox
hitInterfaz
(
1920
,
0
,
900
,
700
);
Hitbox
hit
Cama
(
10
,
50
,
300
,
3
00
);
Hitbox
hit
Ojo
(
0
,
-
10
,
1200
,
-
100000
00
);
Hitbox
hitFondo
(
1000000
,
-
10000000
,
50
,
0
);
Hitbox
hitOjo
(
1000000
,
-
10000000
,
70
,
0
);
Objeto
Ojo
(
sprOjoCerrado
,
sprOjoAbierto
,
sprOjoAbierto
,
hitOjo
,
1300
,
890
,
400
,
170
,
normal
);
Objeto
Planta
(
sprPlanta
,
sprPlanta
,
sprPlanta
,
hitPlanta
,
1200
,
400
,
300
,
400
,
normal
);
Objeto
Planta
(
sprPlanta
,
sprPlanta
,
sprPlanta
,
hitPlanta
,
1200
,
400
,
300
,
400
,
normal
);
Objeto
Interfaz
(
sprInterfaz
,
sprInterfaz
,
sprInterfaz
,
hitInterfaz
,
0
,
870
,
1920
,
216
,
normal
);
Objeto
Interfaz
(
sprInterfaz
,
sprInterfaz
,
sprInterfaz
,
hitInterfaz
,
0
,
870
,
1920
,
216
,
normal
);
Objeto
Ojo
(
sprOjoCerrado
,
sprOjoAbierto
,
sprOjoAbierto
,
hitOjo
,
1300
,
890
,
400
,
170
,
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
);
objetos
.
push_back
(
Interfaz
);
indice_ojo
=
objetos
.
size
();
objetos
.
push_back
(
Ojo
);
objetos
.
push_back
(
Ojo
);
objetos
.
push_back
(
Planta
);
objetos
.
push_back
(
Planta
);
colisionesActivas
.
push_back
(
hitPlanta
);
colisionesActivas
.
push_back
(
hitCama
);
colisionesActivas
.
push_back
(
hitFondo
);
colisionesActivas
.
push_back
(
hitFondo
);
colisionesActivas
.
push_back
(
hitInterfaz
);
colisionesActivas
.
push_back
(
hitCama
);
colisionesActivas
.
push_back
(
hitDer
);
colisionesActivas
.
push_back
(
hitIzq
);
colisionesPasivas
.
push_back
(
hitOjo
);
colisionesPasivas
.
push_back
(
hitOjo
);
}
}
...
@@ -54,12 +65,12 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
...
@@ -54,12 +65,12 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
bool
checkColision
=
false
;
bool
checkColision
=
false
;
int
i
=
0
;
int
i
=
0
;
while
(
!
checkColision
&&
i
<
colisionesPasivas
.
size
()){
while
(
!
checkColision
&&
i
<
colisionesPasivas
.
size
()){
checkColision
=
Agapito
.
comprobarColisionPasiva
(
colisionesPasivas
[
i
]);
checkColision
|=
Agapito
.
comprobarColisionPasiva
(
colisionesPasivas
[
i
]);
i
++
;
i
++
;
}
}
if
(
checkColision
){
if
(
checkColision
){
objetos
[
1
].
setEstado
(
overworld
);
objetos
[
indice_ojo
].
setEstado
(
overworld
);
}
else
objetos
[
1
].
setEstado
(
normal
);
}
else
objetos
[
indice_ojo
].
setEstado
(
normal
);
}
}
break
;
break
;
case
SDL_QUIT
:
case
SDL_QUIT
:
...
@@ -73,11 +84,12 @@ void PantallaPrincipal::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
...
@@ -73,11 +84,12 @@ void PantallaPrincipal::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
Fondo1
.
renderizar
(
renderer
,
0
,
0
,
1920
,
1080
,
tamx
,
tamy
);
Fondo1
.
renderizar
(
renderer
,
0
,
0
,
1920
,
1080
,
tamx
,
tamy
);
Agapito
.
renderizar
(
renderer
,
tamx
,
tamy
);
for
(
int
i
=
0
;
i
<
objetos
.
size
();
i
++
){
for
(
int
i
=
0
;
i
<
objetos
.
size
();
i
++
){
objetos
[
i
].
renderizar
(
renderer
,
tamx
,
tamy
);
objetos
[
i
].
renderizar
(
renderer
,
tamx
,
tamy
);
}
}
Agapito
.
renderizar
(
renderer
,
tamx
,
tamy
);
texto
.
renderizar
(
renderer
,
50
,
50
,
tamx
,
tamy
);
texto
.
renderizar
(
renderer
,
50
,
50
,
tamx
,
tamy
);
}
}
PantallaPrincipal.h
View file @
3b2ddebe
...
@@ -16,6 +16,8 @@ class PantallaPrincipal : public Pantalla {
...
@@ -16,6 +16,8 @@ class PantallaPrincipal : public Pantalla {
Sprite
Fondo1
;
Sprite
Fondo1
;
Personaje
Agapito
;
Personaje
Agapito
;
int
indice_ojo
=
0
;
public
:
public
:
PantallaPrincipal
();
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