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
831be9e1
authored
Mar 13, 2025
by
Jaime de la Chica Bergillos
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
El raton funciona
parent
8ccfc2d4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
7 deletions
Executable
GestorPantallas.cpp
GestorPantallas.h
PantallaPrincipal.cpp
PantallaPrincipal.h
Personaje.h
Executable
View file @
831be9e1
No preview for this file type
GestorPantallas.cpp
View file @
831be9e1
...
@@ -32,7 +32,7 @@ void GestorPantallas::mainLoop(){
...
@@ -32,7 +32,7 @@ void GestorPantallas::mainLoop(){
int
tamy
=
0
;
int
tamy
=
0
;
SDL_GetWindowSize
(
window
,
&
tamx
,
&
tamy
);
SDL_GetWindowSize
(
window
,
&
tamx
,
&
tamy
);
Handle
hand
(
*
this
,
pantallas
.
size
()
-
1
);
Handle
hand
(
*
this
,
pantallas
.
size
()
-
1
,
tamx
,
tamy
);
pantallas
.
back
()
->
manejarEntrada
(
hand
);
pantallas
.
back
()
->
manejarEntrada
(
hand
);
int
indice
=
pantallas
.
size
()
-
1
;
int
indice
=
pantallas
.
size
()
-
1
;
...
...
GestorPantallas.h
View file @
831be9e1
...
@@ -15,13 +15,17 @@ using namespace std;
...
@@ -15,13 +15,17 @@ using namespace std;
class
Handle
{
class
Handle
{
int
idPantalla
;
int
idPantalla
;
GestorPantallas
&
gestor
;
GestorPantallas
&
gestor
;
int
tamx
;
int
tamy
;
friend
GestorPantallas
;
friend
GestorPantallas
;
Handle
(
GestorPantallas
&
gest
,
int
id
)
:
gestor
(
gest
),
idPantalla
(
id
){};
Handle
(
GestorPantallas
&
gest
,
int
id
,
int
tamx_
,
int
tamy_
)
:
gestor
(
gest
),
idPantalla
(
id
),
tamx
(
tamx_
),
tamy
(
tamy_
){};
public
:
public
:
void
reemplazamePor
(
shared_ptr
<
Pantalla
>
);
void
reemplazamePor
(
shared_ptr
<
Pantalla
>
);
void
addPantalla
(
shared_ptr
<
Pantalla
>
);
void
addPantalla
(
shared_ptr
<
Pantalla
>
);
void
removeme
();
void
removeme
();
void
removeAll
();
void
removeAll
();
int
getTamX
(){
return
tamx
;}
int
getTamY
(){
return
tamy
;}
};
};
...
...
PantallaPrincipal.cpp
View file @
831be9e1
...
@@ -8,11 +8,11 @@ PantallaPrincipal::PantallaPrincipal() :
...
@@ -8,11 +8,11 @@ PantallaPrincipal::PantallaPrincipal() :
Sprite
sprInterfaz
(
"assets/InterfazPrincipal.png"
);
Sprite
sprInterfaz
(
"assets/InterfazPrincipal.png"
);
Sprite
sprOjoAbierto
(
"assets/ojoAbierto.png"
);
Sprite
sprOjoAbierto
(
"assets/ojoAbierto.png"
);
Sprite
sprOjoCerrado
(
"assets/ojoCerrado.png"
);
Sprite
sprOjoCerrado
(
"assets/ojoCerrado.png"
);
Hitbox
hitPlanta
(
350
,
80
,
450
,
12
0
);
Hitbox
hitPlanta
(
0
,
-
10
,
1200
,
-
100000000
0
);
Hitbox
hitInterfaz
(
1920
,
0
,
900
,
700
);
Hitbox
hitInterfaz
(
1920
,
0
,
900
,
700
);
Hitbox
hitCama
(
10
,
50
,
300
,
300
);
Hitbox
hitCama
(
10
,
50
,
300
,
300
);
Hitbox
hitFondo
(
1000000
,
-
10000000
,
50
,
0
);
Hitbox
hitFondo
(
1000000
,
-
10000000
,
50
,
0
);
Hitbox
hitOjo
(
1
000000
,
-
10000000
,
70
,
0
);
Hitbox
hitOjo
(
1
630
,
1248
,
997
,
839
);
Objeto
Ojo
(
sprOjoCerrado
,
sprOjoAbierto
,
sprOjoAbierto
,
hitOjo
,
1300
,
890
,
400
,
170
,
normal
);
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
);
...
@@ -20,11 +20,11 @@ PantallaPrincipal::PantallaPrincipal() :
...
@@ -20,11 +20,11 @@ PantallaPrincipal::PantallaPrincipal() :
objetos
.
push_back
(
Interfaz
);
objetos
.
push_back
(
Interfaz
);
objetos
.
push_back
(
Ojo
);
objetos
.
push_back
(
Ojo
);
objetos
.
push_back
(
Planta
);
objetos
.
push_back
(
Planta
);
colisiones
Act
ivas
.
push_back
(
hitPlanta
);
colisiones
Pas
ivas
.
push_back
(
hitPlanta
);
colisionesActivas
.
push_back
(
hitCama
);
colisionesActivas
.
push_back
(
hitCama
);
colisionesActivas
.
push_back
(
hitFondo
);
colisionesActivas
.
push_back
(
hitFondo
);
colisionesActivas
.
push_back
(
hitInterfaz
);
colisionesActivas
.
push_back
(
hitInterfaz
);
colisiones
Pasivas
.
push_back
(
hitOjo
);
colisiones
Interfaz
.
push_back
(
hitOjo
);
}
}
...
@@ -62,6 +62,20 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
...
@@ -62,6 +62,20 @@ void PantallaPrincipal::manejarEntrada(Handle &handle) {
}
else
objetos
[
1
].
setEstado
(
normal
);
}
else
objetos
[
1
].
setEstado
(
normal
);
}
}
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
());
cout
<<
"Raton x "
<<
xRaton
<<
" Raton z "
<<
zRaton
<<
endl
;
if
(
colisionesInterfaz
[
0
].
colisiona
(
xRaton
,
zRaton
)){
Agapito
.
inventario
[
Agapito
.
numObjetos
]
=
objetos
[
2
];
objetos
.
pop_back
();
}
}
break
;
case
SDL_QUIT
:
case
SDL_QUIT
:
handle
.
removeAll
();
handle
.
removeAll
();
}
}
...
...
PantallaPrincipal.h
View file @
831be9e1
...
@@ -12,6 +12,7 @@ class PantallaPrincipal : public Pantalla {
...
@@ -12,6 +12,7 @@ class PantallaPrincipal : public Pantalla {
vector
<
Objeto
>
objetos
;
vector
<
Objeto
>
objetos
;
vector
<
Hitbox
>
colisionesActivas
;
vector
<
Hitbox
>
colisionesActivas
;
vector
<
Hitbox
>
colisionesPasivas
;
vector
<
Hitbox
>
colisionesPasivas
;
vector
<
Hitbox
>
colisionesInterfaz
;
Fuente
fuente1
;
Fuente
fuente1
;
Sprite
Fondo1
;
Sprite
Fondo1
;
Personaje
Agapito
;
Personaje
Agapito
;
...
...
Personaje.h
View file @
831be9e1
...
@@ -20,17 +20,20 @@ enum Facing {
...
@@ -20,17 +20,20 @@ enum Facing {
typedef
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
Instant
;
typedef
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
Instant
;
class
Personaje
{
class
Personaje
{
array
<
optional
<
Objeto
>
,
3
>
inventario
;
array
<
array
<
Sprite
,
2
>
,
4
>
movimientos
;
array
<
array
<
Sprite
,
2
>
,
4
>
movimientos
;
Instant
momento_ultimo_movimiento
=
std
::
chrono
::
system_clock
::
now
();
Instant
momento_ultimo_movimiento
=
std
::
chrono
::
system_clock
::
now
();
Facing
estado
=
Frente
;
Facing
estado
=
Frente
;
int
indice_movimiento
=
0
;
int
indice_movimiento
=
0
;
public
:
public
:
array
<
optional
<
Objeto
>
,
3
>
inventario
;
int
numObjetos
=
0
;
int
x
=
-
100
;
int
x
=
-
100
;
int
profundidades
=
600
;
int
profundidades
=
600
;
Personaje
();
Personaje
();
...
...
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