Compare commits
48 Commits
v1.06.2
...
adab0b420c
| Author | SHA1 | Date | |
|---|---|---|---|
| adab0b420c | |||
| 4f9d8bec42 | |||
| 31e657d138 | |||
| 8b3d257baf | |||
| d1143b9dfe | |||
| 68ebff722e | |||
| 3be9d4459c | |||
| 76e928e21d | |||
| 9c6924d7bb | |||
| 5007bea835 | |||
| 5e7be1c2fb | |||
| faf2e69b63 | |||
| 4c3c844ccf | |||
| 48b8ae049a | |||
| c0d4eddde7 | |||
| f590101047 | |||
| c7fcbd0258 | |||
| b2061c86d2 | |||
| 510a6ca718 | |||
| ec8209265a | |||
| e963251fd9 | |||
| a2f1efd2a6 | |||
| 8959b7bcce | |||
| 4d8bb46a52 | |||
| 2abde36a5e | |||
| 0a083af712 | |||
| f322b1b81b | |||
| 13fe98edb3 | |||
| c90b49c8be | |||
| d3a5c0e54f | |||
| 254ff50ef3 | |||
| e551206351 | |||
| b22e830dac | |||
| a81d42cb25 | |||
| 3ea0025fb4 | |||
| d7c49a0578 | |||
| 4cbe55c2d4 | |||
| 564f316586 | |||
| 522ab8e726 | |||
| 4911282777 | |||
| 06ecabc676 | |||
| 5d89a3057e | |||
| 75228cc451 | |||
| 357eec20b1 | |||
| 62c1e2715e | |||
| 34fc2b6b06 | |||
| 6557dea2bb | |||
| 2caea7ba6e |
2
Makefile
@@ -2,7 +2,7 @@ executable = jaildoctors_dilemma
|
|||||||
source = source/*.cpp source/common/*.cpp
|
source = source/*.cpp source/common/*.cpp
|
||||||
appName = JailDoctor's Dilemma
|
appName = JailDoctor's Dilemma
|
||||||
releaseFolder = jdd_release
|
releaseFolder = jdd_release
|
||||||
version = v1.06.2
|
version = v1.08
|
||||||
|
|
||||||
# Release names
|
# Release names
|
||||||
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# JailDoctor's Dilemma (v1.06.2)
|
# JailDoctor's Dilemma (v1.08)
|
||||||
|
|
||||||
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
@@ -3,7 +3,7 @@ frameHeight=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=8
|
speed=4
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3
|
frames=0,1,2,3,4,5,6,7
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 357 B |
BIN
data/notifications/notify.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
@@ -3,9 +3,9 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,
|
168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,43,43,43,43,43,43,43,43,43,43,43,43,43,43,166,
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
211,181,211,213,211,181,211,212,213,211,181,211,211,212,211,213,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=ROAD TO THE JAIL
|
name=ROAD TO THE JAIL
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=cyan
|
border=blue
|
||||||
tileMapFile=02.tmx
|
tileMapFile=02.tmx
|
||||||
tileSetFile=standard.png
|
tileSetFile=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
|
|||||||
@@ -3,22 +3,22 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,43,43,43,43,43,
|
||||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
43,166,166,167,168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,166,185,167,166,166,166,185,25,25,25,25,
|
||||||
43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
43,43,211,212,212,211,181,211,213,211,181,211,212,213,211,181,211,211,211,211,212,213,211,181,211,213,181,211,135,0,0,0,
|
||||||
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
||||||
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
||||||
34,34,304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
|
34,34,304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,0,413,413,413,413,0,0,0,0,413,413,413,413,413,0,0,0,0,413,413,413,413,413,413,413,0,0,0,25,25,
|
34,34,0,413,413,413,413,0,0,0,0,413,304,413,413,413,0,0,0,0,413,304,413,413,413,413,304,0,0,0,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,389,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
|
34,34,413,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,513,189,190,537,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,524,189,191,548,0,0,0,0,
|
||||||
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,190,25,25
|
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,191,25,25
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
</map>
|
</map>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=bright_green
|
|||||||
itemColor2=green
|
itemColor2=green
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=15
|
x=15
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
|
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
|
||||||
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,387,25,
|
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,25,
|
||||||
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
|
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
|
||||||
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
|
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=red
|
|||||||
itemColor2=magenta
|
itemColor2=magenta
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=9
|
x=9
|
||||||
@@ -27,8 +27,8 @@ color=green
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=1
|
x=1
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=yellow
|
|||||||
itemColor2=red
|
itemColor2=red
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=5
|
x=5
|
||||||
@@ -27,8 +27,8 @@ color=green
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=12
|
x=12
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
5,5,5,5,5,5,5,5,5,5,5,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
5,5,5,5,5,5,5,5,0,0,0,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||||
5,5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
5,5,5,5,5,5,5,0,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,173,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
557,557,557,557,557,557,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
|
5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
|
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,0,
|
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
|
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
|
||||||
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
|
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
|
||||||
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,
|
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ roomLeft=26.room
|
|||||||
roomRight=0
|
roomRight=0
|
||||||
|
|
||||||
#[enemy]
|
#[enemy]
|
||||||
#tileSetFile=diskette.png
|
#tileSetFile=floppy.png
|
||||||
#animation=diskette.ani
|
#animation=floppy.ani
|
||||||
#width=16
|
#width=16
|
||||||
#height=16
|
#height=16
|
||||||
#x=2
|
#x=2
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,41,235,235,0,0,235,235,41,89,90,89,
|
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,94,41,235,235,0,0,235,235,41,89,90,89,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,
|
89,94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,215,0,0,0,0,0,0,0,0,214,89,90,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,
|
214,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,89,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,214,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
|
||||||
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
|
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
|
||||||
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=green
|
|||||||
itemColor2=red
|
itemColor2=red
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=20
|
x=20
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name=STATIC
|
name=BE CAREFUL WITH THE FUSE
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=bright_cyan
|
border=bright_cyan
|
||||||
tileMapFile=36.tmx
|
tileMapFile=36.tmx
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=P.A.C.O. ON THE GO
|
name=P.A.C.O. ON THE GO
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=black
|
border=blue
|
||||||
tileMapFile=42.tmx
|
tileMapFile=42.tmx
|
||||||
tileSetFile=standard.png
|
tileSetFile=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
@@ -23,7 +23,7 @@ x1=10
|
|||||||
y1=2
|
y1=2
|
||||||
x2=10
|
x2=10
|
||||||
y2=11
|
y2=11
|
||||||
color=green
|
color=magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,421,62,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,421,62,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,305,0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,306,0,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ itemColor1=red
|
|||||||
itemColor2=magenta
|
itemColor2=magenta
|
||||||
autoSurface=left
|
autoSurface=left
|
||||||
|
|
||||||
|
[enemy]
|
||||||
|
tileSetFile=batman_fire.png
|
||||||
|
animation=batman_fire.ani
|
||||||
|
width=16
|
||||||
|
height=16
|
||||||
|
x=10
|
||||||
|
y=13
|
||||||
|
vx=1.3
|
||||||
|
vy=0
|
||||||
|
x1=0
|
||||||
|
y1=13
|
||||||
|
x2=29
|
||||||
|
y2=13
|
||||||
|
color=cyan
|
||||||
|
flip=true
|
||||||
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=heavy.png
|
tileSetFile=heavy.png
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ roomLeft=0
|
|||||||
roomRight=49.room
|
roomRight=49.room
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=7
|
x=7
|
||||||
@@ -25,8 +25,8 @@ color=magenta
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=20
|
x=20
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
|
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name=P.A.C.O WORKSHOP
|
name=P.A.C.O. WORKSHOP
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=yellow
|
border=yellow
|
||||||
tileMapFile=53.tmx
|
tileMapFile=53.tmx
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 6.5 KiB |
@@ -23,11 +23,11 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.6.2</string>
|
<string>1.0.8</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0.6.2</string>
|
<string>1.0.8</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -1,13 +1,242 @@
|
|||||||
#include "cheevos.h"
|
#include "cheevos.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos::Cheevos(options_t *options)
|
Cheevos::Cheevos(Screen *screen, options_t *options, std::string file)
|
||||||
{
|
{
|
||||||
|
// Copia la dirección de los objetos
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->screen = screen;
|
||||||
|
this->file = file;
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
init();
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
enabled = true;
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
loadFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Cheevos::~Cheevos()
|
Cheevos::~Cheevos()
|
||||||
{
|
{
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
saveToFile();
|
||||||
|
|
||||||
|
cheevos.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void Cheevos::init()
|
||||||
|
{
|
||||||
|
cheevos_t c;
|
||||||
|
c.completed = false;
|
||||||
|
c.valid = true;
|
||||||
|
c.icon = 2;
|
||||||
|
|
||||||
|
c.id = 1;
|
||||||
|
c.caption = "SHINY THINGS";
|
||||||
|
c.description = "Get 25\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 2;
|
||||||
|
c.caption = "HALF THE WORK";
|
||||||
|
c.description = "Get 50\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 3;
|
||||||
|
c.caption = "GETTING THERE";
|
||||||
|
c.description = "Get 75\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 4;
|
||||||
|
c.caption = "THE COLLECTOR";
|
||||||
|
c.description = "Get 100\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 5;
|
||||||
|
c.caption = "WANDERING AROUND";
|
||||||
|
c.description = "Visit 20 rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 6;
|
||||||
|
c.caption = "I GOT LOST";
|
||||||
|
c.description = "Visit 40 rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 7;
|
||||||
|
c.caption = "I LIKE TO EXPLORE";
|
||||||
|
c.description = "Visit all rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 8;
|
||||||
|
c.caption = "FINISH THE GAME";
|
||||||
|
c.description = "Complete the game";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 9;
|
||||||
|
c.caption = "I WAS SUCKED BY A HOLE";
|
||||||
|
c.description = "Complete the game without entering the jail";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 10;
|
||||||
|
c.caption = "MY LITTLE PROJECTS";
|
||||||
|
c.description = "Complete the game with all items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 11;
|
||||||
|
c.caption = "I LIKE MY MULTICOLOURED FRIENDS";
|
||||||
|
c.description = "Complete the game without dying";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 12;
|
||||||
|
c.caption = "SHIT PROJECTS DONE FAST";
|
||||||
|
c.description = "Complete the game in under 30 minutes";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el indice
|
||||||
|
int Cheevos::find(int id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
if (cheevos[i].id == id)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void Cheevos::unlock(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cheevos[index].valid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cheevos[index].completed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheevos[index].completed = true;
|
||||||
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void Cheevos::invalidate(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cheevos[index].valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Habilita o deshabilita los logros
|
||||||
|
void Cheevos::enable(bool value)
|
||||||
|
{
|
||||||
|
enabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void Cheevos::loadFromFile()
|
||||||
|
{
|
||||||
|
// Open file for reading in binary
|
||||||
|
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "r+b");
|
||||||
|
|
||||||
|
// El fichero no existe
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "Warning: Unable to open file! SDL Error: " << SDL_GetError() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea el fichero en modo escritura
|
||||||
|
file = SDL_RWFromFile(this->file.c_str(), "w+b");
|
||||||
|
|
||||||
|
if (file != NULL)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "New file created!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda la información
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "Error: Unable to create file! SDL Error: " << SDL_GetError() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// El fichero existe
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Carga los datos
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "Reading file...!" << std::endl;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWread(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
void Cheevos::saveToFile()
|
||||||
|
{
|
||||||
|
// Abre el fichero en modo escritura
|
||||||
|
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "w+b");
|
||||||
|
if (file != NULL)
|
||||||
|
{
|
||||||
|
// Guarda la información
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "Error: Unable to save file! " << SDL_GetError() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include "common/screen.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -7,21 +8,55 @@
|
|||||||
#ifndef CHEEVOS_H
|
#ifndef CHEEVOS_H
|
||||||
#define CHEEVOS_H
|
#define CHEEVOS_H
|
||||||
|
|
||||||
|
struct cheevos_t
|
||||||
|
{
|
||||||
|
int id; // Identificador del logro
|
||||||
|
std::string caption; // Texto con el nombre del logro
|
||||||
|
std::string description; // Texto que describe el logro
|
||||||
|
int icon; // Indice del icono a utilizar en la notificación
|
||||||
|
bool completed; // Indica si se ha obtenido el logro
|
||||||
|
bool valid; // Indica si se puede obtener el logro
|
||||||
|
};
|
||||||
|
|
||||||
class Cheevos
|
class Cheevos
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Punteros y objetos
|
// Punteros y objetos
|
||||||
options_t *options;
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
std::vector<cheevos_t> cheevos; // Listado de logros
|
||||||
|
bool enabled; // Indica si los logros se pueden obtener
|
||||||
|
std::string file; // Fichero done leer/almacenar el estado de los logros
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void init();
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el indice
|
||||||
|
int find(int id);
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void loadFromFile();
|
||||||
|
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
void saveToFile();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos(options_t *options);
|
Cheevos(Screen *screen, options_t *options, std::string file);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Cheevos();
|
~Cheevos();
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void unlock(int id);
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void invalidate(int id);
|
||||||
|
|
||||||
|
// Habilita o deshabilita los logros
|
||||||
|
void enable(bool value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -222,121 +222,121 @@ int AnimatedSprite::getIndex(std::string name)
|
|||||||
// Calcula el frame correspondiente a la animación
|
// Calcula el frame correspondiente a la animación
|
||||||
void AnimatedSprite::animate()
|
void AnimatedSprite::animate()
|
||||||
{
|
{
|
||||||
if (!enabled || animation.at(currentAnimation).speed == 0)
|
if (!enabled || animation[currentAnimation].speed == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador
|
// Calcula el frame actual a partir del contador
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
// en función de la variable loop y coloca el nuevo frame
|
||||||
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size())
|
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
if (animation.at(currentAnimation).loop == -1)
|
if (animation[currentAnimation].loop == -1)
|
||||||
{ // Si no hay loop, deja el último frame
|
{ // Si no hay loop, deja el último frame
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size();
|
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
|
||||||
animation.at(currentAnimation).completed = true;
|
animation[currentAnimation].completed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Si hay loop, vuelve al frame indicado
|
{ // Si hay loop, vuelve al frame indicado
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// En caso contrario
|
// En caso contrario
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
// Incrementa el contador de la animacion
|
||||||
animation.at(currentAnimation).counter++;
|
animation[currentAnimation].counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el numero de frames de la animación actual
|
// Obtiene el numero de frames de la animación actual
|
||||||
int AnimatedSprite::getNumFrames()
|
int AnimatedSprite::getNumFrames()
|
||||||
{
|
{
|
||||||
return (int)animation.at(currentAnimation).frames.size();
|
return (int)animation[currentAnimation].frames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
// Establece el frame actual de la animación
|
||||||
void AnimatedSprite::setCurrentFrame(int num)
|
void AnimatedSprite::setCurrentFrame(int num)
|
||||||
{
|
{
|
||||||
// Descarta valores fuera de rango
|
// Descarta valores fuera de rango
|
||||||
if (num >= (int)animation.at(currentAnimation).frames.size())
|
if (num >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
// Cambia el valor de la variable
|
||||||
animation.at(currentAnimation).currentFrame = num;
|
animation[currentAnimation].currentFrame = num;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
|
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor del contador
|
// Establece el valor del contador
|
||||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = num;
|
animation[getIndex(name)].counter = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = speed;
|
animation[getIndex(name)].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||||
{
|
{
|
||||||
animation.at(index).counter = speed;
|
animation[index].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).loop = loop;
|
animation[getIndex(name)].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||||
{
|
{
|
||||||
animation.at(index).loop = loop;
|
animation[index].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).completed = value;
|
animation[getIndex(name)].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el valor de la variable
|
// OLD - Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||||
{
|
{
|
||||||
animation.at(index).completed = value;
|
animation[index].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
bool AnimatedSprite::animationIsCompleted()
|
bool AnimatedSprite::animationIsCompleted()
|
||||||
{
|
{
|
||||||
return animation.at(currentAnimation).completed;
|
return animation[currentAnimation].completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
||||||
{
|
{
|
||||||
return animation.at(getIndex(name)).frames.at(index);
|
return animation[getIndex(name)].frames[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
||||||
{
|
{
|
||||||
return animation.at(indexA).frames.at(indexF);
|
return animation[indexA].frames[indexF];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga la animación desde un vector
|
// Carga la animación desde un vector
|
||||||
@@ -484,9 +484,9 @@ void AnimatedSprite::setCurrentAnimation(std::string name)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +497,9 @@ void AnimatedSprite::setCurrentAnimation(int index)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ void AnimatedSprite::update()
|
|||||||
// Establece el rectangulo para un frame de una animación
|
// Establece el rectangulo para un frame de una animación
|
||||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
animation.at(index_animation).frames.push_back({x, y, w, h});
|
animation[index_animation].frames.push_back({x, y, w, h});
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el contador para todas las animaciones
|
// OLD - Establece el contador para todas las animaciones
|
||||||
@@ -528,7 +528,7 @@ void AnimatedSprite::setAnimationCounter(int value)
|
|||||||
// Reinicia la animación
|
// Reinicia la animación
|
||||||
void AnimatedSprite::resetAnimation()
|
void AnimatedSprite::resetAnimation()
|
||||||
{
|
{
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
@@ -11,12 +11,12 @@ Input::Input(std::string file)
|
|||||||
keyBindings_t kb;
|
keyBindings_t kb;
|
||||||
kb.scancode = 0;
|
kb.scancode = 0;
|
||||||
kb.active = false;
|
kb.active = false;
|
||||||
keyBindings.resize(17, kb);
|
keyBindings.resize(input_number_of_inputs, kb);
|
||||||
|
|
||||||
GameControllerBindings_t gcb;
|
GameControllerBindings_t gcb;
|
||||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
gcb.active = false;
|
gcb.active = false;
|
||||||
gameControllerBindings.resize(17, gcb);
|
gameControllerBindings.resize(input_number_of_inputs, gcb);
|
||||||
|
|
||||||
verbose = true;
|
verbose = true;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
@@ -34,13 +34,13 @@ void Input::update()
|
|||||||
// Asigna inputs a teclas
|
// Asigna inputs a teclas
|
||||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).scancode = code;
|
keyBindings[input].scancode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).button = button;
|
gameControllerBindings[input].button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
@@ -65,7 +65,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
if (keyStates[keyBindings[input].scancode] != 0)
|
||||||
{
|
{
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
@@ -76,11 +76,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!keyBindings.at(input).active)
|
if (!keyBindings[input].active)
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
if (keyStates[keyBindings[input].scancode] != 0)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).active = true;
|
keyBindings[input].active = true;
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -90,9 +90,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] == 0)
|
if (keyStates[keyBindings[input].scancode] == 0)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).active = false;
|
keyBindings[input].active = false;
|
||||||
successKeyboard = false;
|
successKeyboard = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -108,7 +108,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
|
||||||
{
|
{
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
@@ -119,11 +119,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!gameControllerBindings.at(input).active)
|
if (!gameControllerBindings[input].active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).active = true;
|
gameControllerBindings[input].active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -133,9 +133,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).active = false;
|
gameControllerBindings[input].active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -163,7 +163,7 @@ bool Input::checkAnyInput(int device, int index)
|
|||||||
|
|
||||||
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
||||||
{
|
{
|
||||||
if (mKeystates[keyBindings.at(i).scancode] != 0)
|
if (mKeystates[keyBindings[i].scancode] != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ bool Input::checkAnyInput(int device, int index)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ std::string Input::getControllerName(int index)
|
|||||||
{
|
{
|
||||||
if (numGamepads > 0)
|
if (numGamepads > 0)
|
||||||
{
|
{
|
||||||
return controllerNames.at(index);
|
return controllerNames[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,23 +7,31 @@
|
|||||||
#ifndef INPUT_H
|
#ifndef INPUT_H
|
||||||
#define INPUT_H
|
#define INPUT_H
|
||||||
|
|
||||||
#define INPUT_NULL 0
|
enum inputs_e
|
||||||
#define INPUT_UP 1
|
{
|
||||||
#define INPUT_DOWN 2
|
// Inputs obligatorios
|
||||||
#define INPUT_LEFT 3
|
input_null,
|
||||||
#define INPUT_RIGHT 4
|
input_up,
|
||||||
#define INPUT_ACCEPT 5
|
input_down,
|
||||||
#define INPUT_CANCEL 6
|
input_left,
|
||||||
#define INPUT_BUTTON_1 7
|
input_right,
|
||||||
#define INPUT_BUTTON_2 8
|
input_pause,
|
||||||
#define INPUT_BUTTON_3 9
|
input_exit,
|
||||||
#define INPUT_BUTTON_4 10
|
input_accept,
|
||||||
#define INPUT_BUTTON_5 11
|
input_cancel,
|
||||||
#define INPUT_BUTTON_6 12
|
|
||||||
#define INPUT_BUTTON_7 13
|
// Inputs personalizados
|
||||||
#define INPUT_BUTTON_8 14
|
input_jump,
|
||||||
#define INPUT_BUTTON_PAUSE 15
|
input_window_fullscreen,
|
||||||
#define INPUT_BUTTON_ESCAPE 16
|
input_window_inc_size,
|
||||||
|
input_window_dec_size,
|
||||||
|
input_toggle_border,
|
||||||
|
input_switch_music,
|
||||||
|
input_swap_palette,
|
||||||
|
|
||||||
|
// Input obligatorio
|
||||||
|
input_number_of_inputs
|
||||||
|
};
|
||||||
|
|
||||||
#define REPEAT_TRUE true
|
#define REPEAT_TRUE true
|
||||||
#define REPEAT_FALSE false
|
#define REPEAT_FALSE false
|
||||||
@@ -81,7 +89,7 @@ public:
|
|||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|
||||||
// Comprueba si hay almenos un input activo
|
// Comprueba si hay almenos un input activo
|
||||||
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifndef JA_USESDLMIXER
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include "stb_vorbis.c"
|
#include "stb_vorbis.c"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
@@ -11,7 +12,7 @@ struct JA_Sound_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct JA_Channel_t {
|
struct JA_Channel_t {
|
||||||
JA_Sound sound;
|
JA_Sound_t *sound;
|
||||||
int pos {0};
|
int pos {0};
|
||||||
int times {0};
|
int times {0};
|
||||||
JA_Channel_state state { JA_CHANNEL_FREE };
|
JA_Channel_state state { JA_CHANNEL_FREE };
|
||||||
@@ -25,7 +26,7 @@ struct JA_Music_t {
|
|||||||
JA_Music_state state {JA_MUSIC_INVALID};
|
JA_Music_state state {JA_MUSIC_INVALID};
|
||||||
};
|
};
|
||||||
|
|
||||||
JA_Music current_music{NULL};
|
JA_Music_t *current_music{NULL};
|
||||||
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
|
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
|
||||||
|
|
||||||
int JA_freq {48000};
|
int JA_freq {48000};
|
||||||
@@ -86,7 +87,7 @@ void JA_Quit() {
|
|||||||
sdlAudioDevice = 0;
|
sdlAudioDevice = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_Music JA_LoadMusic(const char* filename) {
|
JA_Music_t *JA_LoadMusic(const char* filename) {
|
||||||
int chan, samplerate;
|
int chan, samplerate;
|
||||||
|
|
||||||
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
|
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
|
||||||
@@ -98,7 +99,7 @@ JA_Music JA_LoadMusic(const char* filename) {
|
|||||||
if (fread(buffer, fsize, 1, f)!=1) return NULL;
|
if (fread(buffer, fsize, 1, f)!=1) return NULL;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
JA_Music music = new JA_Music_t();
|
JA_Music_t *music = new JA_Music_t();
|
||||||
|
|
||||||
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
|
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -121,7 +122,7 @@ JA_Music JA_LoadMusic(const char* filename) {
|
|||||||
return music;
|
return music;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JA_PlayMusic(JA_Music music, const int loop) {
|
void JA_PlayMusic(JA_Music_t *music, const int loop) {
|
||||||
if (current_music != NULL) {
|
if (current_music != NULL) {
|
||||||
current_music->pos = 0;
|
current_music->pos = 0;
|
||||||
current_music->state = JA_MUSIC_STOPPED;
|
current_music->state = JA_MUSIC_STOPPED;
|
||||||
@@ -153,21 +154,21 @@ JA_Music_state JA_GetMusicState() {
|
|||||||
return current_music->state;
|
return current_music->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JA_DeleteMusic(JA_Music music) {
|
void JA_DeleteMusic(JA_Music_t *music) {
|
||||||
if (current_music == music) current_music = NULL;
|
if (current_music == music) current_music = NULL;
|
||||||
free(music->output);
|
free(music->output);
|
||||||
delete music;
|
delete music;
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length) {
|
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
|
||||||
JA_Sound sound = new JA_Sound_t();
|
JA_Sound_t *sound = new JA_Sound_t();
|
||||||
sound->buffer = buffer;
|
sound->buffer = buffer;
|
||||||
sound->length = length;
|
sound->length = length;
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_Sound JA_LoadSound(const char* filename) {
|
JA_Sound_t *JA_LoadSound(const char* filename) {
|
||||||
JA_Sound sound = new JA_Sound_t();
|
JA_Sound_t *sound = new JA_Sound_t();
|
||||||
SDL_AudioSpec wavSpec;
|
SDL_AudioSpec wavSpec;
|
||||||
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
|
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ JA_Sound JA_LoadSound(const char* filename) {
|
|||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int JA_PlaySound(JA_Sound sound, const int loop) {
|
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
|
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
|
||||||
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
|
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
|
||||||
@@ -196,7 +197,7 @@ int JA_PlaySound(JA_Sound sound, const int loop) {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JA_DeleteSound(JA_Sound sound) {
|
void JA_DeleteSound(JA_Sound_t *sound) {
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||||
if (channels[i].sound == sound) JA_StopChannel(i);
|
if (channels[i].sound == sound) JA_StopChannel(i);
|
||||||
}
|
}
|
||||||
@@ -246,4 +247,5 @@ JA_Channel_state JA_GetChannelState(const int channel) {
|
|||||||
int JA_SetVolume(int volume) {
|
int JA_SetVolume(int volume) {
|
||||||
JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
|
JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
|
||||||
return JA_volume;
|
return JA_volume;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -4,27 +4,27 @@
|
|||||||
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED };
|
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED };
|
||||||
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED };
|
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED };
|
||||||
|
|
||||||
typedef struct JA_Sound_t *JA_Sound;
|
struct JA_Sound_t;
|
||||||
typedef struct JA_Music_t *JA_Music;
|
struct JA_Music_t;
|
||||||
|
|
||||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
|
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
|
||||||
void JA_Quit();
|
void JA_Quit();
|
||||||
|
|
||||||
JA_Music JA_LoadMusic(const char* filename);
|
JA_Music_t *JA_LoadMusic(const char* filename);
|
||||||
void JA_PlayMusic(JA_Music music, const int loop = -1);
|
void JA_PlayMusic(JA_Music_t *music, const int loop = -1);
|
||||||
void JA_PauseMusic();
|
void JA_PauseMusic();
|
||||||
void JA_ResumeMusic();
|
void JA_ResumeMusic();
|
||||||
void JA_StopMusic();
|
void JA_StopMusic();
|
||||||
JA_Music_state JA_GetMusicState();
|
JA_Music_state JA_GetMusicState();
|
||||||
void JA_DeleteMusic(JA_Music music);
|
void JA_DeleteMusic(JA_Music_t *music);
|
||||||
|
|
||||||
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length);
|
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
|
||||||
JA_Sound JA_LoadSound(const char* filename);
|
JA_Sound_t *JA_LoadSound(const char* filename);
|
||||||
int JA_PlaySound(JA_Sound sound, const int loop = 0);
|
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
|
||||||
void JA_PauseChannel(const int channel);
|
void JA_PauseChannel(const int channel);
|
||||||
void JA_ResumeChannel(const int channel);
|
void JA_ResumeChannel(const int channel);
|
||||||
void JA_StopChannel(const int channel);
|
void JA_StopChannel(const int channel);
|
||||||
JA_Channel_state JA_GetChannelState(const int channel);
|
JA_Channel_state JA_GetChannelState(const int channel);
|
||||||
void JA_DeleteSound(JA_Sound sound);
|
void JA_DeleteSound(JA_Sound_t *sound);
|
||||||
|
|
||||||
int JA_SetVolume(int volume);
|
int JA_SetVolume(int volume);
|
||||||
101
source/common/jail_audio_sdlmixer.cpp
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
#ifdef JA_USESDLMIXER
|
||||||
|
#include "jail_audio.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_mixer.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct JA_Sound_t {}; // Dummy structs
|
||||||
|
struct JA_Music_t {};
|
||||||
|
|
||||||
|
int JA_freq {48000};
|
||||||
|
SDL_AudioFormat JA_format {AUDIO_S16};
|
||||||
|
Uint8 JA_channels {2};
|
||||||
|
|
||||||
|
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
||||||
|
JA_freq = freq;
|
||||||
|
JA_format = format;
|
||||||
|
JA_channels = channels;
|
||||||
|
Mix_OpenAudio(JA_freq, JA_format, JA_channels, 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_Quit() {
|
||||||
|
Mix_CloseAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Music_t *JA_LoadMusic(const char* filename) {
|
||||||
|
return (JA_Music_t*)Mix_LoadMUS(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PlayMusic(JA_Music_t *music, const int loop) {
|
||||||
|
Mix_PlayMusic((Mix_Music*)music, loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PauseMusic() {
|
||||||
|
Mix_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_ResumeMusic() {
|
||||||
|
Mix_ResumeMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_StopMusic() {
|
||||||
|
Mix_HaltMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Music_state JA_GetMusicState() {
|
||||||
|
if (Mix_PausedMusic()) {
|
||||||
|
return JA_MUSIC_PAUSED;
|
||||||
|
} else if (Mix_PlayingMusic()) {
|
||||||
|
return JA_MUSIC_PLAYING;
|
||||||
|
} else {
|
||||||
|
return JA_MUSIC_STOPPED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_DeleteMusic(JA_Music_t *music) {
|
||||||
|
Mix_FreeMusic((Mix_Music*)music);
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Sound_t *JA_LoadSound(const char* filename) {
|
||||||
|
JA_Sound_t *sound = (JA_Sound_t*)Mix_LoadWAV(filename);
|
||||||
|
return sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
|
||||||
|
return Mix_PlayChannel(-1, (Mix_Chunk*)sound, loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_DeleteSound(JA_Sound_t *sound) {
|
||||||
|
Mix_FreeChunk((Mix_Chunk*)sound);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PauseChannel(const int channel) {
|
||||||
|
Mix_Pause(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_ResumeChannel(const int channel) {
|
||||||
|
Mix_Resume(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_StopChannel(const int channel) {
|
||||||
|
Mix_HaltChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Channel_state JA_GetChannelState(const int channel) {
|
||||||
|
if (Mix_Paused(channel)) {
|
||||||
|
return JA_CHANNEL_PAUSED;
|
||||||
|
} else if (Mix_Playing(channel)) {
|
||||||
|
return JA_CHANNEL_PLAYING;
|
||||||
|
} else {
|
||||||
|
return JA_CHANNEL_FREE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int JA_SetVolume(int volume) {
|
||||||
|
return Mix_Volume(-1, volume);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -458,7 +458,7 @@ void Menu::setSelectorPos(int index)
|
|||||||
if (index < (int)item.size())
|
if (index < (int)item.size())
|
||||||
{
|
{
|
||||||
selector.index = index;
|
selector.index = index;
|
||||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y;
|
selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
|
||||||
selector.rect.w = rectBG.rect.w;
|
selector.rect.w = rectBG.rect.w;
|
||||||
selector.rect.x = rectBG.rect.x;
|
selector.rect.x = rectBG.rect.x;
|
||||||
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
||||||
@@ -486,13 +486,13 @@ void Menu::reset()
|
|||||||
{
|
{
|
||||||
itemSelected = MENU_NO_OPTION;
|
itemSelected = MENU_NO_OPTION;
|
||||||
selector.index = 0;
|
selector.index = 0;
|
||||||
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
||||||
selector.originH = selector.targetH = item.at(0).rect.h;
|
selector.originH = selector.targetH = item[0].rect.h;
|
||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
selector.resizing = false;
|
selector.resizing = false;
|
||||||
|
|
||||||
// Si el primer elemento no es seleccionable, incrementa el selector
|
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||||
if (!item.at(selector.index).selectable)
|
if (!item[selector.index].selectable)
|
||||||
{
|
{
|
||||||
increaseSelectorIndex();
|
increaseSelectorIndex();
|
||||||
setSelectorPos(selector.index);
|
setSelectorPos(selector.index);
|
||||||
@@ -524,18 +524,18 @@ void Menu::reorganize()
|
|||||||
bool Menu::increaseSelectorIndex()
|
bool Menu::increaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
selector.y = selector.originY = item[selector.index].rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
while (!item.at(selector.index).selectable)
|
while (!item[selector.index].selectable)
|
||||||
{
|
{
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item.at(selector.index).rect.y;
|
selector.targetY = item[selector.index].rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -554,7 +554,7 @@ bool Menu::increaseSelectorIndex()
|
|||||||
bool Menu::decreaseSelectorIndex()
|
bool Menu::decreaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
selector.y = selector.originY = item[selector.index].rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
@@ -567,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
selector.index--;
|
selector.index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!item.at(selector.index).selectable)
|
while (!item[selector.index].selectable)
|
||||||
{
|
{
|
||||||
if (selector.index == 0)
|
if (selector.index == 0)
|
||||||
{
|
{
|
||||||
@@ -580,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item.at(selector.index).rect.y;
|
selector.targetY = item[selector.index].rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -630,29 +630,29 @@ void Menu::render()
|
|||||||
if (i == selector.index)
|
if (i == selector.index)
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item.at(i).selectable)
|
else if (item[i].selectable)
|
||||||
{
|
{
|
||||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item.at(i).greyed)
|
else if (item[i].greyed)
|
||||||
{
|
{
|
||||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
|
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{ // No seleccionable
|
{ // No seleccionable
|
||||||
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
if ((item[i].linkedUp) && (i == selector.index + 1))
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||||
}
|
}
|
||||||
else // No enlazado con el de arriba
|
else // No enlazado con el de arriba
|
||||||
{
|
{
|
||||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,7 +822,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
|||||||
|
|
||||||
if (item.size() > 1)
|
if (item.size() > 1)
|
||||||
{
|
{
|
||||||
if (item.at(item.size() - 2).linkedDown)
|
if (item[item.size() - 2].linkedDown)
|
||||||
{
|
{
|
||||||
item.back().linkedUp = true;
|
item.back().linkedUp = true;
|
||||||
}
|
}
|
||||||
@@ -835,9 +835,9 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
|||||||
// Cambia el texto de un item
|
// Cambia el texto de un item
|
||||||
void Menu::setItemCaption(int index, std::string text)
|
void Menu::setItemCaption(int index, std::string text)
|
||||||
{
|
{
|
||||||
item.at(index).label = text;
|
item[index].label = text;
|
||||||
item.at(index).rect.w = this->text->lenght(item.at(index).label);
|
item[index].rect.w = this->text->lenght(item[index].label);
|
||||||
item.at(index).rect.h = this->text->getCharacterSize();
|
item[index].rect.h = this->text->getCharacterSize();
|
||||||
reorganize();
|
reorganize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +850,7 @@ void Menu::setDefaultActionWhenCancel(int item)
|
|||||||
// Gestiona la entrada de teclado y mando durante el menu
|
// Gestiona la entrada de teclado y mando durante el menu
|
||||||
void Menu::checkInput()
|
void Menu::checkInput()
|
||||||
{
|
{
|
||||||
if (input->checkInput(INPUT_UP, REPEAT_FALSE))
|
if (input->checkInput(input_up, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (decreaseSelectorIndex())
|
if (decreaseSelectorIndex())
|
||||||
{
|
{
|
||||||
@@ -861,7 +861,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_DOWN, REPEAT_FALSE))
|
if (input->checkInput(input_down, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (increaseSelectorIndex())
|
if (increaseSelectorIndex())
|
||||||
{
|
{
|
||||||
@@ -872,7 +872,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE))
|
if (input->checkInput(input_accept, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
itemSelected = selector.index;
|
itemSelected = selector.index;
|
||||||
if (soundAccept)
|
if (soundAccept)
|
||||||
@@ -881,7 +881,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE))
|
if (input->checkInput(input_cancel, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
itemSelected = defaultActionWhenCancel;
|
itemSelected = defaultActionWhenCancel;
|
||||||
if (soundCancel)
|
if (soundCancel)
|
||||||
@@ -914,42 +914,42 @@ int Menu::findHeight()
|
|||||||
// Recoloca los elementos del menu en el eje Y
|
// Recoloca los elementos del menu en el eje Y
|
||||||
void Menu::replaceElementsOnY()
|
void Menu::replaceElementsOnY()
|
||||||
{
|
{
|
||||||
item.at(0).rect.y = y;
|
item[0].rect.y = y;
|
||||||
|
|
||||||
for (int i = 1; i < (int)item.size(); i++)
|
for (int i = 1; i < (int)item.size(); i++)
|
||||||
{
|
{
|
||||||
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
|
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado seleccionable de un item
|
// Establece el estado seleccionable de un item
|
||||||
void Menu::setSelectable(int index, bool value)
|
void Menu::setSelectable(int index, bool value)
|
||||||
{
|
{
|
||||||
item.at(index).selectable = value;
|
item[index].selectable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado agrisado de un item
|
// Establece el estado agrisado de un item
|
||||||
void Menu::setGreyed(int index, bool value)
|
void Menu::setGreyed(int index, bool value)
|
||||||
{
|
{
|
||||||
item.at(index).greyed = value;
|
item[index].greyed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado de enlace de un item
|
// Establece el estado de enlace de un item
|
||||||
void Menu::setLinkedDown(int index, bool value)
|
void Menu::setLinkedDown(int index, bool value)
|
||||||
{
|
{
|
||||||
item.at(index).linkedDown = value;
|
item[index].linkedDown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula la altura del selector
|
// Calcula la altura del selector
|
||||||
int Menu::getSelectorHeight(int value)
|
int Menu::getSelectorHeight(int value)
|
||||||
{
|
{
|
||||||
if (item.at(value).linkedDown)
|
if (item[value].linkedDown)
|
||||||
{
|
{
|
||||||
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
|
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return item.at(value).rect.h;
|
return item[value].rect.h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ private:
|
|||||||
bool isCenteredOnY; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y
|
bool isCenteredOnY; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y
|
||||||
bool areElementsCenteredOnX; // Variable para saber si los elementos van centrados en el eje X
|
bool areElementsCenteredOnX; // Variable para saber si los elementos van centrados en el eje X
|
||||||
int widestItem; // Anchura del elemento más ancho
|
int widestItem; // Anchura del elemento más ancho
|
||||||
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu
|
JA_Sound_t* soundAccept; // Sonido al aceptar o elegir una opción del menu
|
||||||
JA_Sound soundCancel; // Sonido al cancelar el menu
|
JA_Sound_t* soundCancel; // Sonido al cancelar el menu
|
||||||
JA_Sound soundMove; // Sonido al mover el selector
|
JA_Sound_t* soundMove; // Sonido al mover el selector
|
||||||
color_t colorGreyed; // Color para los elementos agrisados
|
color_t colorGreyed; // Color para los elementos agrisados
|
||||||
rectangle_t rectBG; // Rectangulo de fondo del menu
|
rectangle_t rectBG; // Rectangulo de fondo del menu
|
||||||
std::vector<item_t> item; // Estructura para cada elemento del menu
|
std::vector<item_t> item; // Estructura para cada elemento del menu
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -13,8 +13,9 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF
|
|||||||
waitTime = 300;
|
waitTime = 300;
|
||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
texture = new Texture(renderer, bitmapFile);
|
iconTexture = new Texture(renderer, iconFile);
|
||||||
text = new Text(textFile, texture, renderer);
|
textTexture = new Texture(renderer, bitmapFile);
|
||||||
|
text = new Text(textFile, textTexture, renderer);
|
||||||
sound = JA_LoadSound(soundFile.c_str());
|
sound = JA_LoadSound(soundFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +23,8 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF
|
|||||||
Notify::~Notify()
|
Notify::~Notify()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete texture;
|
delete textTexture;
|
||||||
|
delete iconTexture;
|
||||||
delete text;
|
delete text;
|
||||||
JA_DeleteSound(sound);
|
JA_DeleteSound(sound);
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ void Notify::render()
|
|||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
notifications.at(i).sprite->render();
|
notifications[i].sprite->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,63 +49,63 @@ void Notify::update()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)notifications.size(); ++i)
|
for (int i = 0; i < (int)notifications.size(); ++i)
|
||||||
{
|
{
|
||||||
notifications.at(i).counter++;
|
notifications[i].counter++;
|
||||||
|
|
||||||
// Comprueba los estados
|
// Comprueba los estados
|
||||||
if (notifications.at(i).state == ns_rising)
|
if (notifications[i].state == ns_rising)
|
||||||
{
|
{
|
||||||
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
|
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
|
||||||
const int alpha = 255 * step;
|
const int alpha = 255 * step;
|
||||||
|
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y++;
|
notifications[i].rect.y++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y--;
|
notifications[i].rect.y--;
|
||||||
}
|
}
|
||||||
notifications.at(i).texture->setAlpha(alpha);
|
notifications[i].texture->setAlpha(alpha);
|
||||||
|
|
||||||
if (notifications.at(i).rect.y == notifications.at(i).y)
|
if (notifications[i].rect.y == notifications[i].y)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_stay;
|
notifications[i].state = ns_stay;
|
||||||
notifications.at(i).texture->setAlpha(255);
|
notifications[i].texture->setAlpha(255);
|
||||||
notifications.at(i).counter = 0;
|
notifications[i].counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (notifications.at(i).state == ns_stay)
|
else if (notifications[i].state == ns_stay)
|
||||||
{
|
{
|
||||||
if (notifications.at(i).counter == waitTime)
|
if (notifications[i].counter == waitTime)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_vanishing;
|
notifications[i].state = ns_vanishing;
|
||||||
notifications.at(i).counter = 0;
|
notifications[i].counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (notifications.at(i).state == ns_vanishing)
|
else if (notifications[i].state == ns_vanishing)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
|
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
|
||||||
const int alpha = 255 * (1 - step);
|
const int alpha = 255 * (1 - step);
|
||||||
|
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y--;
|
notifications[i].rect.y--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y++;
|
notifications[i].rect.y++;
|
||||||
}
|
}
|
||||||
notifications.at(i).texture->setAlpha(alpha);
|
notifications[i].texture->setAlpha(alpha);
|
||||||
|
|
||||||
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
|
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_finished;
|
notifications[i].state = ns_finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.at(i).sprite->setRect(notifications.at(i).rect);
|
notifications[i].sprite->setRect(notifications[i].rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFinishedNotifications();
|
clearFinishedNotifications();
|
||||||
@@ -114,22 +116,25 @@ void Notify::clearFinishedNotifications()
|
|||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (notifications.at(i).state == ns_finished)
|
if (notifications[i].state == ns_finished)
|
||||||
{
|
{
|
||||||
delete notifications.at(i).sprite;
|
delete notifications[i].sprite;
|
||||||
delete notifications.at(i).texture;
|
delete notifications[i].texture;
|
||||||
notifications.erase(notifications.begin() + i);
|
notifications.erase(notifications.begin() + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Notify::showText(std::string text)
|
void Notify::showText(std::string text1, std::string text2, int icon)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
|
const int iconSize = 16;
|
||||||
const int height = this->text->getCharacterSize() * 2;
|
const int padding = text->getCharacterSize();
|
||||||
const int padding = (this->text->getCharacterSize() / 2);
|
const int iconSpace = icon >= 0 ? iconSize + padding : 0;
|
||||||
|
const std::string txt = text1.length() > text2.length() ? text1 : text2;
|
||||||
|
const int width = text->lenght(txt) + (padding * 2) + iconSpace;
|
||||||
|
const int height = (text->getCharacterSize() * 2) + (padding * 2);
|
||||||
|
|
||||||
// Posición horizontal
|
// Posición horizontal
|
||||||
int despH = 0;
|
int despH = 0;
|
||||||
@@ -178,7 +183,8 @@ void Notify::showText(std::string text)
|
|||||||
n.travelDist = travelDist;
|
n.travelDist = travelDist;
|
||||||
n.counter = 0;
|
n.counter = 0;
|
||||||
n.state = ns_rising;
|
n.state = ns_rising;
|
||||||
n.text = text;
|
n.text1 = text1;
|
||||||
|
n.text2 = text2;
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
n.rect = {despH, offset - travelDist, width, height};
|
n.rect = {despH, offset - travelDist, width, height};
|
||||||
@@ -191,14 +197,52 @@ void Notify::showText(std::string text)
|
|||||||
// Crea la textura
|
// Crea la textura
|
||||||
n.texture = new Texture(renderer);
|
n.texture = new Texture(renderer);
|
||||||
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
|
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
|
||||||
n.texture->setAsRenderTarget(renderer);
|
|
||||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, padding, text, 1, {255, 255, 255}, 1, {0, 0, 0});
|
|
||||||
|
// Prepara para dibujar en la textura
|
||||||
|
n.texture->setAsRenderTarget(renderer);
|
||||||
|
|
||||||
|
// Dibuja el fondo de la notificación
|
||||||
|
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||||
|
SDL_Rect rect;
|
||||||
|
rect = {4, 0, width - (4 * 2), height};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
rect = {4 / 2, 1, width - 4, height - 2};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
rect = {1, 4 / 2, width - 2, height - 4};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
rect = {0, 4, width, height - (4 * 2)};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
// Dibuja el icono de la notificación
|
||||||
|
if (icon >= 0)
|
||||||
|
{
|
||||||
|
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
|
||||||
|
sp->setPos({padding, padding, iconSize, iconSize});
|
||||||
|
sp->setSpriteClip({iconSize * (icon % 10), iconSize * (icon / 10), iconSize, iconSize});
|
||||||
|
sp->render();
|
||||||
|
delete sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escribe el texto de la notificación
|
||||||
|
color_t color = {255, 255, 255};
|
||||||
|
if (text2 != "")
|
||||||
|
{ // Dos lineas de texto
|
||||||
|
text->writeColored(padding + iconSpace, padding, text1, color);
|
||||||
|
text->writeColored(padding + iconSpace, padding + text->getCharacterSize() + 1, text2, color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Una linea de texto
|
||||||
|
text->writeColored(padding + iconSpace, (height / 2) - (text->getCharacterSize() / 2), text1, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deja de dibujar en la textura
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite de la notificación
|
||||||
n.sprite = new Sprite(n.rect, n.texture, renderer);
|
n.sprite = new Sprite(n.rect, n.texture, renderer);
|
||||||
|
|
||||||
// Añade la notificación a la lista
|
// Añade la notificación a la lista
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ private:
|
|||||||
|
|
||||||
struct notification_t
|
struct notification_t
|
||||||
{
|
{
|
||||||
std::string text;
|
std::string text1;
|
||||||
|
std::string text2;
|
||||||
int counter;
|
int counter;
|
||||||
notification_state_e state;
|
notification_state_e state;
|
||||||
notification_position_e position;
|
notification_position_e position;
|
||||||
@@ -49,7 +50,8 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Texture *texture; // Textura para la fuente de las notificaciones
|
Texture *textTexture; // Textura para la fuente de las notificaciones
|
||||||
|
Texture *iconTexture; // Textura para los iconos de las notificaciones
|
||||||
Text *text; // Objeto para dibujar texto
|
Text *text; // Objeto para dibujar texto
|
||||||
options_t *options; // Variable con todas las opciones del programa
|
options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ private:
|
|||||||
color_t bgColor; // Color de fondo de las notificaciones
|
color_t bgColor; // Color de fondo de las notificaciones
|
||||||
int waitTime; // Tiempo que se ve la notificación
|
int waitTime; // Tiempo que se ve la notificación
|
||||||
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
||||||
JA_Sound sound; // Sonido a reproducir cuando suena la notificación
|
JA_Sound_t *sound; // Sonido a reproducir cuando suena la notificación
|
||||||
|
|
||||||
// Elimina las notificaciones finalizadas
|
// Elimina las notificaciones finalizadas
|
||||||
void clearFinishedNotifications();
|
void clearFinishedNotifications();
|
||||||
@@ -70,13 +72,13 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Notify();
|
~Notify();
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showText(std::string text);
|
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool active();
|
bool active();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
|||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
|
notify = new Notify(renderer, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
|
||||||
|
|
||||||
gameCanvasWidth = options->gameWidth;
|
gameCanvasWidth = options->gameWidth;
|
||||||
gameCanvasHeight = options->gameHeight;
|
gameCanvasHeight = options->gameHeight;
|
||||||
@@ -48,6 +48,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
|||||||
Screen::~Screen()
|
Screen::~Screen()
|
||||||
{
|
{
|
||||||
delete notify;
|
delete notify;
|
||||||
|
SDL_DestroyTexture(gameCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
@@ -86,15 +87,18 @@ void Screen::blit()
|
|||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
void Screen::setVideoMode(int videoMode)
|
void Screen::setVideoMode(int videoMode)
|
||||||
{
|
{
|
||||||
// Muestra el puntero
|
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
|
||||||
|
|
||||||
// Aplica el modo de video
|
// Aplica el modo de video
|
||||||
SDL_SetWindowFullscreen(window, videoMode);
|
SDL_SetWindowFullscreen(window, videoMode);
|
||||||
|
|
||||||
// Si está activo el modo ventana quita el borde
|
// Si está activo el modo ventana quita el borde
|
||||||
if (videoMode == 0)
|
if (videoMode == 0)
|
||||||
{
|
{
|
||||||
|
// Muestra el puntero
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
|
||||||
|
// Esconde la ventana
|
||||||
|
//SDL_HideWindow(window);
|
||||||
|
|
||||||
if (options->borderEnabled)
|
if (options->borderEnabled)
|
||||||
{
|
{
|
||||||
windowWidth = gameCanvasWidth + borderWidth;
|
windowWidth = gameCanvasWidth + borderWidth;
|
||||||
@@ -109,9 +113,12 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica el tamaño del renderizador y de la ventana
|
// Modifica el tamaño de la ventana
|
||||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
|
||||||
SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize);
|
SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize);
|
||||||
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
|
|
||||||
|
// Muestra la ventana
|
||||||
|
//SDL_ShowWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si está activo el modo de pantalla completa añade el borde
|
// Si está activo el modo de pantalla completa añade el borde
|
||||||
@@ -162,11 +169,11 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
dest.h = windowHeight;
|
dest.h = windowHeight;
|
||||||
dest.x = dest.y = 0;
|
dest.x = dest.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica el tamaño del renderizador
|
|
||||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modifica el tamaño del renderizador
|
||||||
|
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||||
|
|
||||||
// Actualiza las opciones
|
// Actualiza las opciones
|
||||||
options->videoMode = videoMode;
|
options->videoMode = videoMode;
|
||||||
options->screen.windowWidth = windowWidth;
|
options->screen.windowWidth = windowWidth;
|
||||||
@@ -190,6 +197,22 @@ void Screen::setWindowSize(int size)
|
|||||||
setVideoMode(0);
|
setVideoMode(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce el tamaño de la ventana
|
||||||
|
void Screen::decWindowSize()
|
||||||
|
{
|
||||||
|
--options->windowSize;
|
||||||
|
options->windowSize = std::max(options->windowSize, 1);
|
||||||
|
setVideoMode(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aumenta el tamaño de la ventana
|
||||||
|
void Screen::incWindowSize()
|
||||||
|
{
|
||||||
|
++options->windowSize;
|
||||||
|
options->windowSize = std::min(options->windowSize, 4);
|
||||||
|
setVideoMode(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
void Screen::setBorderColor(color_t color)
|
void Screen::setBorderColor(color_t color)
|
||||||
{
|
{
|
||||||
@@ -344,7 +367,7 @@ void Screen::renderSpectrumFade()
|
|||||||
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
||||||
const int max = spectrumColor.size() - 1;
|
const int max = spectrumColor.size() - 1;
|
||||||
const int index = max + (0 - max) * step;
|
const int index = max + (0 - max) * step;
|
||||||
const color_t c = spectrumColor.at(index);
|
const color_t c = spectrumColor[index];
|
||||||
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,9 +393,9 @@ void Screen::updateNotifier()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Screen::showNotification(std::string text)
|
void Screen::showNotification(std::string text1, std::string text2, int icon)
|
||||||
{
|
{
|
||||||
notify->showText(text);
|
notify->showText(text1, text2, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "../const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
#ifndef SCREEN_H
|
||||||
@@ -94,6 +95,12 @@ public:
|
|||||||
// Cambia el tamaño de la ventana
|
// Cambia el tamaño de la ventana
|
||||||
void setWindowSize(int size);
|
void setWindowSize(int size);
|
||||||
|
|
||||||
|
// Reduce el tamaño de la ventana
|
||||||
|
void decWindowSize();
|
||||||
|
|
||||||
|
// Aumenta el tamaño de la ventana
|
||||||
|
void incWindowSize();
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
void setBorderColor(color_t color);
|
void setBorderColor(color_t color);
|
||||||
|
|
||||||
@@ -132,7 +139,7 @@ public:
|
|||||||
void updateNotifier();
|
void updateNotifier();
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showNotification(std::string text);
|
void showNotification(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *rende
|
|||||||
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
x = rect.x;
|
this->x = rect.x;
|
||||||
y = rect.y;
|
this->y = rect.y;
|
||||||
|
|
||||||
// Establece el alto y el ancho del sprite
|
// Establece el alto y el ancho del sprite
|
||||||
w = rect.w;
|
this->w = rect.w;
|
||||||
h = rect.h;
|
this->h = rect.h;
|
||||||
|
|
||||||
// Establece el puntero al renderizador de la ventana
|
// Establece el puntero al renderizador de la ventana
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbos
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return success
|
// Return success
|
||||||
|
stbi_image_free(data);
|
||||||
texture = newTexture;
|
texture = newTexture;
|
||||||
return texture != nullptr;
|
return texture != nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ struct cheat_t
|
|||||||
struct online_t
|
struct online_t
|
||||||
{
|
{
|
||||||
bool enabled; // Indica si se quiere usar el modo online o no
|
bool enabled; // Indica si se quiere usar el modo online o no
|
||||||
|
bool sessionEnabled; // Indica ya se ha hecho login
|
||||||
std::string server; // Servidor para los servicios online
|
std::string server; // Servidor para los servicios online
|
||||||
int port; // Puerto del servidor
|
int port; // Puerto del servidor
|
||||||
std::string gameID; // Identificador del juego para los servicios online
|
std::string gameID; // Identificador del juego para los servicios online
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,8 +22,8 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
counterEnabled = true;
|
counterEnabled = true;
|
||||||
subCounter = 0;
|
subCounter = 0;
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section->name = SECTION_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
sprite->setRect({194, 174, 8, 8});
|
sprite->setRect({194, 174, 8, 8});
|
||||||
@@ -74,59 +76,50 @@ void Credits::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Credits::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
switchPalette();
|
{
|
||||||
break;
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +140,7 @@ void Credits::iniTexts()
|
|||||||
keys = "A,D AND W";
|
keys = "A,D AND W";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GAME_CONSOLE
|
||||||
texts.clear();
|
texts.clear();
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||||
@@ -160,11 +154,11 @@ void Credits::iniTexts()
|
|||||||
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({keys + " TO MOVE AND JUMP", stringToColor(options->palette, "white")});
|
texts.push_back({keys + " TO MOVE AND JUMP", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
|
texts.push_back({"M TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"H TO HOLD/PAUSE THE GAME", stringToColor(options->palette, "white")});
|
texts.push_back({"H TO PAUSE THE GAME", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
texts.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
texts.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"B TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
texts.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
@@ -175,6 +169,36 @@ void Credits::iniTexts()
|
|||||||
|
|
||||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
#else
|
||||||
|
texts.clear();
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"B TO JUMP", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"START TO PAUSE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"SELECT TO EXIT", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
@@ -200,7 +224,7 @@ void Credits::fillTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el corazón
|
// Escribe el corazón
|
||||||
const int textLenght = text->lenght(texts.at(22).label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
const int textLenght = text->lenght(texts[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||||
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
||||||
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
||||||
|
|
||||||
@@ -259,21 +283,24 @@ void Credits::updateCounter()
|
|||||||
// Comprueba si ha terminado la sección
|
// Comprueba si ha terminado la sección
|
||||||
if (counter > 1200)
|
if (counter > 1200)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_DEMO;
|
section->name = SECTION_PROG_DEMO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Credits::update()
|
void Credits::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
updateCounter();
|
updateCounter();
|
||||||
@@ -318,15 +345,13 @@ void Credits::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Credits::run()
|
void Credits::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_CREDITS)
|
while (section->name == SECTION_PROG_CREDITS)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -30,18 +31,19 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
bool counterEnabled; // Indica si esta activo el contador
|
bool counterEnabled; // Indica si esta activo el contador
|
||||||
int subCounter; // Contador secundario
|
int subCounter; // Contador secundario
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<captions_t> texts; // Vector con los textos
|
std::vector<captions_t> texts; // Vector con los textos
|
||||||
@@ -55,6 +57,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
void updateCounter();
|
void updateCounter();
|
||||||
|
|
||||||
@@ -69,13 +74,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Credits();
|
~Credits();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
138
source/demo.cpp
@@ -1,7 +1,7 @@
|
|||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug)
|
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -15,15 +15,17 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
rooms.push_back("44.room");
|
rooms.push_back("44.room");
|
||||||
|
|
||||||
roomIndex = 0;
|
roomIndex = 0;
|
||||||
currentRoom = rooms.at(roomIndex);
|
currentRoom = rooms[roomIndex];
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->debug = debug;
|
this->resource = resource;
|
||||||
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
this->debug = debug;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
@@ -40,12 +42,12 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
board.lives = 9;
|
board.lives = 9;
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.jailEnabled = options->cheat.jailEnabled;
|
board.jailEnabled = false;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
section.name = SECTION_PROG_DEMO;
|
section->name = SECTION_PROG_DEMO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Demo::~Demo()
|
Demo::~Demo()
|
||||||
@@ -67,86 +69,82 @@ void Demo::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Comprueba las entradas
|
||||||
section_t Demo::run()
|
void Demo::checkInput()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_DEMO)
|
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle para el juego
|
||||||
|
void Demo::run()
|
||||||
|
{
|
||||||
|
while (section->name == SECTION_PROG_DEMO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void Demo::update()
|
void Demo::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba los eventos de la cola
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza los objetos
|
// Actualiza los objetos
|
||||||
room->update();
|
room->update();
|
||||||
@@ -164,8 +162,8 @@ void Demo::render()
|
|||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen->start();
|
||||||
screen->clean(room->getBGColor());
|
|
||||||
|
|
||||||
|
// Dibuja los elementos del juego en orden
|
||||||
room->renderMap();
|
room->renderMap();
|
||||||
room->renderEnemies();
|
room->renderEnemies();
|
||||||
room->renderItems();
|
room->renderItems();
|
||||||
@@ -255,12 +253,12 @@ void Demo::checkRoomChange()
|
|||||||
roomIndex++;
|
roomIndex++;
|
||||||
if (roomIndex == (int)rooms.size())
|
if (roomIndex == (int)rooms.size())
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changeRoom(rooms.at(roomIndex));
|
changeRoom(rooms[roomIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/input.h"
|
#include "common/input.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
@@ -29,16 +30,17 @@ private:
|
|||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string currentRoom; // Fichero de la habitación actual
|
||||||
board_t board; // Estructura con los datos del marcador
|
board_t board; // Estructura con los datos del marcador
|
||||||
int counter; // Contador para el modo demo
|
int counter; // Contador para el modo demo
|
||||||
@@ -55,6 +57,9 @@ private:
|
|||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void renderRoomName();
|
void renderRoomName();
|
||||||
|
|
||||||
@@ -75,13 +80,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug);
|
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Demo();
|
~Demo();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,11 +14,12 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Director::Director(int argc, char *argv[])
|
Director::Director(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section = new section_t();
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
@@ -28,7 +29,12 @@ Director::Director(int argc, char *argv[])
|
|||||||
checkProgramArguments(argc, argv);
|
checkProgramArguments(argc, argv);
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
createSystemFolder();
|
createSystemFolder("jailgames");
|
||||||
|
#ifndef DEBUG
|
||||||
|
createSystemFolder("jailgames/jaildoctors_dilemma");
|
||||||
|
#else
|
||||||
|
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
asset = new Asset(executablePath);
|
asset = new Asset(executablePath);
|
||||||
@@ -65,6 +71,7 @@ Director::~Director()
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
// Libera la memoria
|
// Libera la memoria
|
||||||
|
delete section;
|
||||||
delete options;
|
delete options;
|
||||||
delete asset;
|
delete asset;
|
||||||
delete input;
|
delete input;
|
||||||
@@ -129,6 +136,10 @@ void Director::initOptions()
|
|||||||
options->borderHeight = 24;
|
options->borderHeight = 24;
|
||||||
options->palette = p_zxspectrum;
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
|
#ifdef GAME_CONSOLE
|
||||||
|
options->windowSize = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Estos valores no se guardan en el fichero de configuraci´ón
|
// Estos valores no se guardan en el fichero de configuraci´ón
|
||||||
options->console = false;
|
options->console = false;
|
||||||
options->cheat.infiniteLives = false;
|
options->cheat.infiniteLives = false;
|
||||||
@@ -140,6 +151,7 @@ void Director::initOptions()
|
|||||||
|
|
||||||
// Opciones online
|
// Opciones online
|
||||||
options->online.enabled = true;
|
options->online.enabled = true;
|
||||||
|
options->online.sessionEnabled = false;
|
||||||
options->online.server = "jaildoctor.duckdns.org";
|
options->online.server = "jaildoctor.duckdns.org";
|
||||||
options->online.port = 9911;
|
options->online.port = 9911;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -153,7 +165,7 @@ void Director::initOptions()
|
|||||||
options->notifications.posV = pos_top;
|
options->notifications.posV = pos_top;
|
||||||
options->notifications.posH = pos_left;
|
options->notifications.posH = pos_left;
|
||||||
options->notifications.sound = true;
|
options->notifications.sound = true;
|
||||||
options->notifications.color = {64, 64, 64};
|
options->notifications.color = {48, 48, 48};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
@@ -403,24 +415,18 @@ bool Director::saveConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void Director::createSystemFolder()
|
void Director::createSystemFolder(std::string folder)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
const std::string folderName = "jaildoctors_dilemma_debug";
|
|
||||||
#else
|
|
||||||
const std::string folderName = "jaildoctors_dilemma";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
systemFolder = std::string(getenv("APPDATA")) + "/" + folderName;
|
systemFolder = std::string(getenv("APPDATA")) + "/" + folder;
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/Library/Application Support/" + folderName;
|
systemFolder = std::string(homedir) + "/Library/Application Support" + "/" + folder;
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/." + folderName;
|
systemFolder = std::string(homedir) + "/." + folder;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct stat st = {0};
|
struct stat st = {0};
|
||||||
@@ -458,14 +464,14 @@ void Director::createSystemFolder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void Director::loadResources(section_t section)
|
void Director::loadResources(section_t *section)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "** LOAD RESOURCES" << std::endl;
|
std::cout << "** LOAD RESOURCES" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section.name == SECTION_PROG_LOGO)
|
if (section->name == SECTION_PROG_LOGO)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("jailgames.png");
|
textureList.push_back("jailgames.png");
|
||||||
@@ -474,7 +480,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_INTRO)
|
else if (section->name == SECTION_PROG_INTRO)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("loading_screen_bn.png");
|
textureList.push_back("loading_screen_bn.png");
|
||||||
@@ -485,7 +491,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_TITLE)
|
else if (section->name == SECTION_PROG_TITLE)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("loading_screen_color.png");
|
textureList.push_back("loading_screen_color.png");
|
||||||
@@ -501,7 +507,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadOffsets(offsetsList);
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_CREDITS)
|
else if (section->name == SECTION_PROG_CREDITS)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -523,7 +529,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadOffsets(offsetsList);
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_ENDING)
|
else if (section->name == SECTION_PROG_ENDING)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -548,7 +554,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadOffsets(offsetsList);
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_ENDING2)
|
else if (section->name == SECTION_PROG_ENDING2)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -581,7 +587,7 @@ void Director::loadResources(section_t section)
|
|||||||
textureList.push_back("demon.png");
|
textureList.push_back("demon.png");
|
||||||
textureList.push_back("heavy.png");
|
textureList.push_back("heavy.png");
|
||||||
textureList.push_back("dimallas.png");
|
textureList.push_back("dimallas.png");
|
||||||
textureList.push_back("diskette.png");
|
textureList.push_back("floppy.png");
|
||||||
textureList.push_back("dong.png");
|
textureList.push_back("dong.png");
|
||||||
textureList.push_back("guitar.png");
|
textureList.push_back("guitar.png");
|
||||||
textureList.push_back("jailbattle_alien.png");
|
textureList.push_back("jailbattle_alien.png");
|
||||||
@@ -644,7 +650,7 @@ void Director::loadResources(section_t section)
|
|||||||
animationList.push_back("demon.ani");
|
animationList.push_back("demon.ani");
|
||||||
animationList.push_back("heavy.ani");
|
animationList.push_back("heavy.ani");
|
||||||
animationList.push_back("dimallas.ani");
|
animationList.push_back("dimallas.ani");
|
||||||
animationList.push_back("diskette.ani");
|
animationList.push_back("floppy.ani");
|
||||||
animationList.push_back("dong.ani");
|
animationList.push_back("dong.ani");
|
||||||
animationList.push_back("guitar.ani");
|
animationList.push_back("guitar.ani");
|
||||||
animationList.push_back("jailbattle_alien.ani");
|
animationList.push_back("jailbattle_alien.ani");
|
||||||
@@ -686,7 +692,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadOffsets(offsetsList);
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_GAME_OVER)
|
else if (section->name == SECTION_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -710,7 +716,7 @@ void Director::loadResources(section_t section)
|
|||||||
resource->loadOffsets(offsetsList);
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
|
else if (section->name == SECTION_PROG_GAME || section->name == SECTION_PROG_DEMO)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -755,7 +761,7 @@ void Director::loadResources(section_t section)
|
|||||||
textureList.push_back("crosshair.png");
|
textureList.push_back("crosshair.png");
|
||||||
textureList.push_back("demon.png");
|
textureList.push_back("demon.png");
|
||||||
textureList.push_back("dimallas.png");
|
textureList.push_back("dimallas.png");
|
||||||
textureList.push_back("diskette.png");
|
textureList.push_back("floppy.png");
|
||||||
textureList.push_back("dong.png");
|
textureList.push_back("dong.png");
|
||||||
textureList.push_back("guitar.png");
|
textureList.push_back("guitar.png");
|
||||||
textureList.push_back("heavy.png");
|
textureList.push_back("heavy.png");
|
||||||
@@ -836,7 +842,7 @@ void Director::loadResources(section_t section)
|
|||||||
animationList.push_back("crosshair.ani");
|
animationList.push_back("crosshair.ani");
|
||||||
animationList.push_back("demon.ani");
|
animationList.push_back("demon.ani");
|
||||||
animationList.push_back("dimallas.ani");
|
animationList.push_back("dimallas.ani");
|
||||||
animationList.push_back("diskette.ani");
|
animationList.push_back("floppy.ani");
|
||||||
animationList.push_back("dong.ani");
|
animationList.push_back("dong.ani");
|
||||||
animationList.push_back("guitar.ani");
|
animationList.push_back("guitar.ani");
|
||||||
animationList.push_back("heavy.ani");
|
animationList.push_back("heavy.ani");
|
||||||
@@ -1202,43 +1208,56 @@ void Director::initInput()
|
|||||||
// Busca si hay un mando conectado
|
// Busca si hay un mando conectado
|
||||||
input->discoverGameController();
|
input->discoverGameController();
|
||||||
|
|
||||||
// Asigna inputs a teclas
|
// Teclado - Movimiento
|
||||||
if (options->keys == ctrl_cursor)
|
if (options->keys == ctrl_cursor)
|
||||||
{
|
{
|
||||||
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
input->bindKey(input_jump, SDL_SCANCODE_UP);
|
||||||
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
|
input->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||||
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
|
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||||
}
|
}
|
||||||
else if (options->keys == ctrl_opqa)
|
else if (options->keys == ctrl_opqa)
|
||||||
{
|
{
|
||||||
input->bindKey(INPUT_UP, SDL_SCANCODE_Q);
|
input->bindKey(input_jump, SDL_SCANCODE_Q);
|
||||||
input->bindKey(INPUT_LEFT, SDL_SCANCODE_O);
|
input->bindKey(input_left, SDL_SCANCODE_O);
|
||||||
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_P);
|
input->bindKey(input_right, SDL_SCANCODE_P);
|
||||||
}
|
}
|
||||||
else if (options->keys == ctrl_wasd)
|
else if (options->keys == ctrl_wasd)
|
||||||
{
|
{
|
||||||
input->bindKey(INPUT_UP, SDL_SCANCODE_W);
|
input->bindKey(input_jump, SDL_SCANCODE_W);
|
||||||
input->bindKey(INPUT_LEFT, SDL_SCANCODE_A);
|
input->bindKey(input_left, SDL_SCANCODE_A);
|
||||||
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_D);
|
input->bindKey(input_right, SDL_SCANCODE_D);
|
||||||
}
|
}
|
||||||
|
|
||||||
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
// Teclado - Otros
|
||||||
input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN);
|
input->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||||||
input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE);
|
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||||||
input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE);
|
input->bindKey(input_pause, SDL_SCANCODE_H);
|
||||||
input->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_D);
|
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||||
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
|
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||||||
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
|
input->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
||||||
|
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
||||||
|
input->bindKey(input_swap_palette, SDL_SCANCODE_F5);
|
||||||
|
input->bindKey(input_switch_music, SDL_SCANCODE_M);
|
||||||
|
input->bindKey(input_toggle_border, SDL_SCANCODE_B);
|
||||||
|
|
||||||
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
// Mando - Movimiento
|
||||||
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
input->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
|
||||||
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
|
||||||
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
|
// Mando - Otros
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
|
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE);
|
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
|
#ifdef GAME_CONSOLE
|
||||||
|
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
|
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
||||||
|
#else
|
||||||
|
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
||||||
|
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
|
#endif
|
||||||
|
input->bindGameControllerButton(input_swap_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
|
input->bindGameControllerButton(input_switch_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
|
input->bindGameControllerButton(input_toggle_border, SDL_CONTROLLER_BUTTON_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
@@ -1357,6 +1376,10 @@ bool Director::setFileList()
|
|||||||
asset->add(systemFolder + "/config.txt", t_data, false, true);
|
asset->add(systemFolder + "/config.txt", t_data, false, true);
|
||||||
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
|
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
|
||||||
asset->add(systemFolder + "/stats.csv", t_data, false, true);
|
asset->add(systemFolder + "/stats.csv", t_data, false, true);
|
||||||
|
asset->add(systemFolder + "/cheevos.bin", t_data, false, true);
|
||||||
|
|
||||||
|
// Notificaciones
|
||||||
|
asset->add(prefix + "/data/notifications/notify.png", t_bitmap);
|
||||||
|
|
||||||
// Habitaciones
|
// Habitaciones
|
||||||
asset->add(prefix + "/data/room/01.room", t_room);
|
asset->add(prefix + "/data/room/01.room", t_room);
|
||||||
@@ -1533,8 +1556,8 @@ bool Director::setFileList()
|
|||||||
asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
|
asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
|
asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
|
||||||
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
|
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/enemies/diskette.ani", t_data);
|
asset->add(prefix + "/data/enemies/floppy.ani", t_data);
|
||||||
asset->add(prefix + "/data/enemies/diskette.png", t_bitmap);
|
asset->add(prefix + "/data/enemies/floppy.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/enemies/dong.ani", t_data);
|
asset->add(prefix + "/data/enemies/dong.ani", t_data);
|
||||||
asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
|
asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/enemies/guitar.ani", t_data);
|
asset->add(prefix + "/data/enemies/guitar.ani", t_data);
|
||||||
@@ -1681,24 +1704,6 @@ bool Director::setFileList()
|
|||||||
return asset->check();
|
return asset->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 Director::getSubsection()
|
|
||||||
{
|
|
||||||
return section.subsection;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 Director::getSection()
|
|
||||||
{
|
|
||||||
return section.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Director::setSection(section_t section)
|
|
||||||
{
|
|
||||||
this->section = section;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
@@ -1707,8 +1712,8 @@ void Director::runLogo()
|
|||||||
std::cout << "\n* SECTION: LOGO" << std::endl;
|
std::cout << "\n* SECTION: LOGO" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
|
logo = new Logo(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(logo->run());
|
logo->run();
|
||||||
delete logo;
|
delete logo;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1721,8 +1726,8 @@ void Director::runIntro()
|
|||||||
std::cout << "\n* SECTION: INTRO" << std::endl;
|
std::cout << "\n* SECTION: INTRO" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
intro = new Intro(renderer, screen, resource, asset, options);
|
intro = new Intro(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(intro->run());
|
intro->run();
|
||||||
delete intro;
|
delete intro;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1739,8 +1744,8 @@ void Director::runTitle()
|
|||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
title = new Title(renderer, screen, resource, asset, options);
|
title = new Title(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(title->run());
|
title->run();
|
||||||
delete title;
|
delete title;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1753,8 +1758,8 @@ void Director::runCredits()
|
|||||||
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
credits = new Credits(renderer, screen, resource, asset, options);
|
credits = new Credits(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(credits->run());
|
credits->run();
|
||||||
delete credits;
|
delete credits;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1767,8 +1772,8 @@ void Director::runDemo()
|
|||||||
std::cout << "\n* SECTION: DEMO" << std::endl;
|
std::cout << "\n* SECTION: DEMO" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
demo = new Demo(renderer, screen, resource, asset, options, debug);
|
demo = new Demo(renderer, screen, resource, asset, input, options, section, debug);
|
||||||
setSection(demo->run());
|
demo->run();
|
||||||
delete demo;
|
delete demo;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1782,7 +1787,7 @@ void Director::runEnterID()
|
|||||||
}
|
}
|
||||||
// loadResources(section);
|
// loadResources(section);
|
||||||
enterID = new EnterID(renderer, screen, asset, options, section);
|
enterID = new EnterID(renderer, screen, asset, options, section);
|
||||||
setSection(enterID->run());
|
enterID->run();
|
||||||
delete enterID;
|
delete enterID;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1795,8 +1800,8 @@ void Director::runEnding()
|
|||||||
std::cout << "\n* SECTION: ENDING" << std::endl;
|
std::cout << "\n* SECTION: ENDING" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
ending = new Ending(renderer, screen, resource, asset, options);
|
ending = new Ending(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(ending->run());
|
ending->run();
|
||||||
delete ending;
|
delete ending;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1809,8 +1814,8 @@ void Director::runEnding2()
|
|||||||
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
ending2 = new Ending2(renderer, screen, resource, asset, options);
|
ending2 = new Ending2(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(ending2->run());
|
ending2->run();
|
||||||
delete ending2;
|
delete ending2;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1823,8 +1828,8 @@ void Director::runGameOver()
|
|||||||
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
gameOver = new GameOver(renderer, screen, resource, asset, options);
|
gameOver = new GameOver(renderer, screen, resource, asset, input, options, section);
|
||||||
setSection(gameOver->run());
|
gameOver->run();
|
||||||
delete gameOver;
|
delete gameOver;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1838,8 +1843,8 @@ void Director::runGame()
|
|||||||
}
|
}
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
game = new Game(renderer, screen, resource, asset, options, input, debug);
|
game = new Game(renderer, screen, resource, asset, options, input, section, debug);
|
||||||
setSection(game->run());
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1847,9 +1852,9 @@ void Director::runGame()
|
|||||||
void Director::run()
|
void Director::run()
|
||||||
{
|
{
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
while (getSection() != SECTION_PROG_QUIT)
|
while (section->name != SECTION_PROG_QUIT)
|
||||||
{
|
{
|
||||||
switch (getSection())
|
switch (section->name)
|
||||||
{
|
{
|
||||||
case SECTION_PROG_LOGO:
|
case SECTION_PROG_LOGO:
|
||||||
runLogo();
|
runLogo();
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ private:
|
|||||||
GameOver *gameOver; // Objeto para gestionar el final de la partida
|
GameOver *gameOver; // Objeto para gestionar el final de la partida
|
||||||
Debug *debug; // Objeto para getsionar la información de debug
|
Debug *debug; // Objeto para getsionar la información de debug
|
||||||
struct options_t *options; // Variable con todas las opciones del programa
|
struct options_t *options; // Variable con todas las opciones del programa
|
||||||
|
section_t *section; // Sección y subsección actual del programa;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
section_t section; // Sección y subsección actual del programa;
|
JA_Music_t *music; // Musica del titulo
|
||||||
JA_Music music; // Musica del titulo
|
|
||||||
std::string executablePath; // Path del ejecutable
|
std::string executablePath; // Path del ejecutable
|
||||||
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ private:
|
|||||||
bool saveConfig();
|
bool saveConfig();
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void createSystemFolder();
|
void createSystemFolder(std::string folder);
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void loadResources(section_t section);
|
void loadResources(section_t *section);
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setOptions(options_t *options, std::string var, std::string value);
|
bool setOptions(options_t *options, std::string var, std::string value);
|
||||||
@@ -89,15 +89,6 @@ private:
|
|||||||
// Crea el indice de ficheros
|
// Crea el indice de ficheros
|
||||||
bool setFileList();
|
bool setFileList();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSubsection();
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSection();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setSection(section_t section);
|
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void runLogo();
|
void runLogo();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include "ending.h"
|
#include "ending.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -19,8 +21,8 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
|||||||
counter = -1;
|
counter = -1;
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
coverCounter = 0;
|
coverCounter = 0;
|
||||||
section.name = SECTION_PROG_ENDING;
|
section->name = SECTION_PROG_ENDING;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
scene = 0;
|
scene = 0;
|
||||||
@@ -83,14 +85,17 @@ Ending::~Ending()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Ending::update()
|
void Ending::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
updateCounters();
|
updateCounters();
|
||||||
@@ -119,16 +124,16 @@ void Ending::render()
|
|||||||
screen->clean(stringToColor(options->palette, "black"));
|
screen->clean(stringToColor(options->palette, "black"));
|
||||||
|
|
||||||
// Dibuja las imagenes de la escena
|
// Dibuja las imagenes de la escena
|
||||||
spritePics.at(scene).sprite->render();
|
spritePics[scene].sprite->render();
|
||||||
spritePics.at(scene).coverSprite->render();
|
spritePics[scene].coverSprite->render();
|
||||||
|
|
||||||
// Dibuja los textos de la escena
|
// Dibuja los textos de la escena
|
||||||
for (auto ti : scenes.at(scene).textIndex)
|
for (auto ti : scenes[scene].textIndex)
|
||||||
{
|
{
|
||||||
if (counter > ti.trigger)
|
if (counter > ti.trigger)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).sprite->render();
|
spriteTexts[ti.index].sprite->render();
|
||||||
spriteTexts.at(ti.index).coverSprite->render();
|
spriteTexts[ti.index].coverSprite->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,57 +155,45 @@ void Ending::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Ending::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_LOGO;
|
||||||
break;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,11 +475,11 @@ void Ending::iniScenes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending::run()
|
void Ending::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING)
|
while (section->name == SECTION_PROG_ENDING)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -494,8 +487,6 @@ section_t Ending::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -511,7 +502,7 @@ void Ending::updateCounters()
|
|||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter > scenes.at(scene).counterEnd - 100)
|
if (counter > scenes[scene].counterEnd - 100)
|
||||||
{
|
{
|
||||||
coverCounter++;
|
coverCounter++;
|
||||||
}
|
}
|
||||||
@@ -522,20 +513,20 @@ void Ending::updateSpriteCovers()
|
|||||||
{ // Actualiza la cortinilla de los textos
|
{ // Actualiza la cortinilla de los textos
|
||||||
if (counter % 4 == 0)
|
if (counter % 4 == 0)
|
||||||
{
|
{
|
||||||
for (auto ti : scenes.at(scene).textIndex)
|
for (auto ti : scenes[scene].textIndex)
|
||||||
{
|
{
|
||||||
if (counter > ti.trigger)
|
if (counter > ti.trigger)
|
||||||
{
|
{
|
||||||
if (spriteTexts.at(ti.index).clipDesp > 0)
|
if (spriteTexts[ti.index].clipDesp > 0)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).clipDesp -= 2;
|
spriteTexts[ti.index].clipDesp -= 2;
|
||||||
}
|
}
|
||||||
else if (spriteTexts.at(ti.index).clipHeight > 0)
|
else if (spriteTexts[ti.index].clipHeight > 0)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).clipHeight -= 2;
|
spriteTexts[ti.index].clipHeight -= 2;
|
||||||
spriteTexts.at(ti.index).coverSprite->setPosY(spriteTexts.at(ti.index).coverSprite->getPosY() + 2);
|
spriteTexts[ti.index].coverSprite->setPosY(spriteTexts[ti.index].coverSprite->getPosY() + 2);
|
||||||
}
|
}
|
||||||
spriteTexts.at(ti.index).coverSprite->setSpriteClip(0, spriteTexts.at(ti.index).clipDesp, spriteTexts.at(ti.index).coverSprite->getWidth(), spriteTexts.at(ti.index).clipHeight);
|
spriteTexts[ti.index].coverSprite->setSpriteClip(0, spriteTexts[ti.index].clipDesp, spriteTexts[ti.index].coverSprite->getWidth(), spriteTexts[ti.index].clipHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,27 +534,27 @@ void Ending::updateSpriteCovers()
|
|||||||
// Actualiza la cortinilla de las imagenes
|
// Actualiza la cortinilla de las imagenes
|
||||||
if (counter % 2 == 0)
|
if (counter % 2 == 0)
|
||||||
{
|
{
|
||||||
if (spritePics.at(scene).clipDesp > 0)
|
if (spritePics[scene].clipDesp > 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipDesp -= 2;
|
spritePics[scene].clipDesp -= 2;
|
||||||
}
|
}
|
||||||
else if (spritePics.at(scene).clipHeight > 0)
|
else if (spritePics[scene].clipHeight > 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipHeight -= 2;
|
spritePics[scene].clipHeight -= 2;
|
||||||
if (spritePics.at(scene).clipHeight < 0)
|
if (spritePics[scene].clipHeight < 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipHeight = 0;
|
spritePics[scene].clipHeight = 0;
|
||||||
}
|
}
|
||||||
spritePics.at(scene).coverSprite->setPosY(spritePics.at(scene).coverSprite->getPosY() + 2);
|
spritePics[scene].coverSprite->setPosY(spritePics[scene].coverSprite->getPosY() + 2);
|
||||||
}
|
}
|
||||||
spritePics.at(scene).coverSprite->setSpriteClip(0, spritePics.at(scene).clipDesp, spritePics.at(scene).coverSprite->getWidth(), spritePics.at(scene).clipHeight);
|
spritePics[scene].coverSprite->setSpriteClip(0, spritePics[scene].clipDesp, spritePics[scene].coverSprite->getWidth(), spritePics[scene].clipHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se ha de cambiar de escena
|
// Comprueba si se ha de cambiar de escena
|
||||||
void Ending::checkChangeScene()
|
void Ending::checkChangeScene()
|
||||||
{
|
{
|
||||||
if (counter > scenes.at(scene).counterEnd)
|
if (counter > scenes[scene].counterEnd)
|
||||||
{
|
{
|
||||||
scene++;
|
scene++;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -571,7 +562,7 @@ void Ending::checkChangeScene()
|
|||||||
if (scene == 5)
|
if (scene == 5)
|
||||||
{
|
{
|
||||||
// Termina el bucle
|
// Termina el bucle
|
||||||
section.name = SECTION_PROG_ENDING2;
|
section->name = SECTION_PROG_ENDING2;
|
||||||
|
|
||||||
// Mantiene los valores anteriores
|
// Mantiene los valores anteriores
|
||||||
scene = 4;
|
scene = 4;
|
||||||
@@ -639,20 +630,20 @@ void Ending::switchPalette()
|
|||||||
{
|
{
|
||||||
options->palette = p_zxarne;
|
options->palette = p_zxarne;
|
||||||
|
|
||||||
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
||||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
||||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
spritePics[2].sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
||||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
spritePics[3].sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
||||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
spritePics[4].sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options->palette = p_zxspectrum;
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1.png"));
|
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
|
||||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2.png"));
|
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
|
||||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3.png"));
|
spritePics[2].sprite->setTexture(resource->getTexture("ending3.png"));
|
||||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4.png"));
|
spritePics[3].sprite->setTexture(resource->getTexture("ending4.png"));
|
||||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5.png"));
|
spritePics[4].sprite->setTexture(resource->getTexture("ending5.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -54,23 +55,24 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int coverCounter; // Contador para la cortinilla
|
int coverCounter; // Contador para la cortinilla
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
||||||
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
||||||
int scene; // Escena actual
|
int scene; // Escena actual
|
||||||
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
||||||
JA_Music music; // Musica que suena durante el final
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -81,6 +83,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
void iniTexts();
|
void iniTexts();
|
||||||
|
|
||||||
@@ -113,13 +118,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending();
|
~Ending();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -21,8 +23,8 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
postCounter = 0;
|
postCounter = 0;
|
||||||
postCounterEnabled = false;
|
postCounterEnabled = false;
|
||||||
section.name = SECTION_PROG_ENDING2;
|
section->name = SECTION_PROG_ENDING2;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
distSpriteText = 8;
|
distSpriteText = 8;
|
||||||
@@ -73,14 +75,17 @@ Ending2::~Ending2()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Ending2::update()
|
void Ending2::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
updateCounters();
|
updateCounters();
|
||||||
@@ -184,66 +189,54 @@ void Ending2::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Comprueba las teclas que se han pulsado
|
}
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
// Comprueba las entradas
|
||||||
switch (eventHandler->key.keysym.scancode)
|
void Ending2::checkInput()
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
break;
|
{
|
||||||
|
section->name = SECTION_PROG_LOGO;
|
||||||
case SDL_SCANCODE_B:
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
screen->switchBorder();
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F:
|
screen->switchBorder();
|
||||||
screen->switchVideoMode();
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F1:
|
screen->switchVideoMode();
|
||||||
screen->setWindowSize(1);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F2:
|
screen->decWindowSize();
|
||||||
screen->setWindowSize(2);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F3:
|
screen->incWindowSize();
|
||||||
screen->setWindowSize(3);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F4:
|
switchPalette();
|
||||||
screen->setWindowSize(4);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending2::run()
|
void Ending2::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING2)
|
while (section->name == SECTION_PROG_ENDING2)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -251,8 +244,6 @@ section_t Ending2::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -275,8 +266,8 @@ void Ending2::updateCounters()
|
|||||||
|
|
||||||
if (postCounter > 600)
|
if (postCounter > 600)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +279,7 @@ void Ending2::iniSpriteList()
|
|||||||
|
|
||||||
// Añade los valores
|
// Añade los valores
|
||||||
spriteList.push_back("bin");
|
spriteList.push_back("bin");
|
||||||
spriteList.push_back("diskette");
|
spriteList.push_back("floppy");
|
||||||
spriteList.push_back("bird");
|
spriteList.push_back("bird");
|
||||||
spriteList.push_back("chip");
|
spriteList.push_back("chip");
|
||||||
spriteList.push_back("jeannine");
|
spriteList.push_back("jeannine");
|
||||||
@@ -469,13 +460,13 @@ void Ending2::placeSprites()
|
|||||||
{
|
{
|
||||||
const int x = i % 2 == 0 ? firstCol : secondCol;
|
const int x = i % 2 == 0 ? firstCol : secondCol;
|
||||||
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
|
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
|
||||||
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
|
const int w = sprites[i]->getAnimationClip(0, 0).w;
|
||||||
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
|
const int h = sprites[i]->getAnimationClip(0, 0).h;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
|
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
|
||||||
|
|
||||||
sprites.at(i)->setRect({x + dx, y + dy, w, h});
|
sprites[i]->setRect({x + dx, y + dy, w, h});
|
||||||
sprites.at(i)->setVelY(despSpeed);
|
sprites[i]->setVelY(despSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recoloca el último sprite, que es el del jugador
|
// Recoloca el último sprite, que es el del jugador
|
||||||
@@ -497,14 +488,14 @@ void Ending2::createSpriteTexts()
|
|||||||
for (int i = 0; i < (int)spriteList.size(); ++i)
|
for (int i = 0; i < (int)spriteList.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
std::string txt = spriteList.at(i);
|
std::string txt = spriteList[i];
|
||||||
std::replace(txt.begin(), txt.end(), '_', ' ');
|
std::replace(txt.begin(), txt.end(), '_', ' ');
|
||||||
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
|
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
|
||||||
const int w = text->lenght(txt, 1);
|
const int w = text->lenght(txt, 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = i % 2 == 0 ? firstCol : secondCol;
|
const int x = i % 2 == 0 ? firstCol : secondCol;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
const int y = sprites.at(i)->getPosY() + sprites.at(i)->getHeight() + distSpriteText;
|
const int y = sprites[i]->getPosY() + sprites[i]->getHeight() + distSpriteText;
|
||||||
|
|
||||||
// Cambia la posición del último sprite
|
// Cambia la posición del último sprite
|
||||||
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
|
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
|
||||||
@@ -536,7 +527,7 @@ void Ending2::createTexts()
|
|||||||
for (int i = 0; i < (int)list.size(); ++i)
|
for (int i = 0; i < (int)list.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
const int w = text->lenght(list.at(i), 1);
|
const int w = text->lenght(list[i], 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = GAMECANVAS_CENTER_X;
|
const int x = GAMECANVAS_CENTER_X;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
@@ -547,7 +538,7 @@ void Ending2::createTexts()
|
|||||||
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
text->write(0, 0, list.at(i));
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
||||||
@@ -565,7 +556,7 @@ void Ending2::createTexts()
|
|||||||
for (int i = 0; i < (int)list.size(); ++i)
|
for (int i = 0; i < (int)list.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
const int w = text->lenght(list.at(i), 1);
|
const int w = text->lenght(list[i], 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = GAMECANVAS_CENTER_X;
|
const int x = GAMECANVAS_CENTER_X;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
@@ -576,7 +567,7 @@ void Ending2::createTexts()
|
|||||||
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
text->write(0, 0, list.at(i));
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
||||||
@@ -624,7 +615,7 @@ void Ending2::updateFinalFade()
|
|||||||
|
|
||||||
for (auto t : texts)
|
for (auto t : texts)
|
||||||
{
|
{
|
||||||
t->getTexture()->setColor(colors.at(index).r, colors.at(index).g, colors.at(index).b);
|
t->getTexture()->setColor(colors[index].r, colors[index].g, colors[index].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -25,21 +26,22 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
||||||
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
||||||
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
|
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
bool counterEnabled; // Indica si está el contador habilitado
|
bool counterEnabled; // Indica si está el contador habilitado
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int postCounter; // Contador posterior
|
int postCounter; // Contador posterior
|
||||||
bool postCounterEnabled; // Indica si está habilitado el contador
|
bool postCounterEnabled; // Indica si está habilitado el contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
JA_Music music; // Musica que suena durante el final
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
std::vector<color_t> colors; // Vector con los colores para el fade
|
||||||
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
||||||
@@ -59,6 +61,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
void updateCounters();
|
void updateCounters();
|
||||||
|
|
||||||
@@ -115,13 +120,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending2();
|
~Ending2();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section)
|
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -36,11 +37,10 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
name[pos] = 0;
|
name[pos] = 0;
|
||||||
maxLenght = 15;
|
maxLenght = 15;
|
||||||
this->section.subsection = section.subsection;
|
|
||||||
|
|
||||||
if (options->online.enabled && options->online.jailerID == "")
|
if (options->online.enabled && options->online.jailerID == "")
|
||||||
{
|
{
|
||||||
this->section.name = SECTION_PROG_ENTER_ID;
|
this->section->name = SECTION_PROG_ENTER_ID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,16 @@ EnterID::~EnterID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t EnterID::run()
|
void EnterID::run()
|
||||||
{
|
{
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENTER_ID)
|
while (section->name == SECTION_PROG_ENTER_ID)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
@@ -83,7 +81,7 @@ void EnterID::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ void EnterID::checkEventHandler()
|
|||||||
|
|
||||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +279,11 @@ void EnterID::switchPalette()
|
|||||||
// Inicializa los servicios online
|
// Inicializa los servicios online
|
||||||
void EnterID::initOnline()
|
void EnterID::initOnline()
|
||||||
{
|
{
|
||||||
|
if (options->online.sessionEnabled)
|
||||||
|
{ // Si ya ha iniciado la sesión, que no continue
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (options->online.jailerID == "")
|
if (options->online.jailerID == "")
|
||||||
{ // Jailer ID no definido
|
{ // Jailer ID no definido
|
||||||
|
|
||||||
@@ -289,11 +292,15 @@ void EnterID::initOnline()
|
|||||||
else
|
else
|
||||||
{ // Jailer ID iniciado
|
{ // Jailer ID iniciado
|
||||||
|
|
||||||
options->online.enabled = true;
|
options->online.enabled = options->online.sessionEnabled = true;
|
||||||
jscore::init(options->online.server, options->online.port);
|
jscore::init(options->online.server, options->online.port);
|
||||||
|
|
||||||
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
#ifdef DEBUG
|
||||||
screen->showNotification(caption);
|
const std::string caption = "IS LOGGED IN (DEBUG)";
|
||||||
|
#else
|
||||||
|
const std::string caption = "IS LOGGED IN";
|
||||||
|
#endif
|
||||||
|
screen->showNotification(options->online.jailerID, caption, 12);
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << caption << std::endl;
|
std::cout << caption << std::endl;
|
||||||
@@ -305,6 +312,6 @@ void EnterID::initOnline()
|
|||||||
void EnterID::endSection()
|
void EnterID::endSection()
|
||||||
{
|
{
|
||||||
initOnline();
|
initOnline();
|
||||||
section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
|
section->name = (section->subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,10 @@ private:
|
|||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
Texture *texture; // Textura para la fuente para el texto
|
Texture *texture; // Textura para la fuente para el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<captions_t> texts; // Vector con los textos
|
std::vector<captions_t> texts; // Vector con los textos
|
||||||
@@ -68,13 +68,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section);
|
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~EnterID();
|
~EnterID();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
322
source/game.cpp
@@ -2,15 +2,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug)
|
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
|
||||||
board.iniClock = SDL_GetTicks();
|
|
||||||
currentRoom = "03.room";
|
|
||||||
const int x = 25;
|
|
||||||
const int y = 13;
|
|
||||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -19,15 +12,25 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->input = input;
|
this->input = input;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
|
// Inicia algunas variables
|
||||||
|
board.iniClock = SDL_GetTicks();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
currentRoom = "01.room";
|
currentRoom = "03.room";
|
||||||
const int x1 = 25;
|
const int x = 25;
|
||||||
const int y1 = 13;
|
const int y = 13;
|
||||||
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
|
debug->setEnabled(false);
|
||||||
|
#else
|
||||||
|
currentRoom = "03.room";
|
||||||
|
const int x = 25;
|
||||||
|
const int y = 13;
|
||||||
|
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
|
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"));
|
||||||
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
roomTracker = new RoomTracker();
|
roomTracker = new RoomTracker();
|
||||||
@@ -42,6 +45,25 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
||||||
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
||||||
|
|
||||||
|
// Crea la textura para poner el nombre de la habitación
|
||||||
|
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
|
||||||
|
if (roomNameTexture == nullptr)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
std::cout << "Error: roomNameTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el blend mode de la textura
|
||||||
|
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
|
// Establece el destino de la textura
|
||||||
|
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
fillRoomNameTexture();
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
@@ -61,14 +83,17 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
totalItems = getTotalItems();
|
totalItems = getTotalItems();
|
||||||
initStats();
|
initStats();
|
||||||
stats->addVisit(room->getName());
|
stats->addVisit(room->getName());
|
||||||
|
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
|
||||||
|
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
|
||||||
|
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game()
|
Game::~Game()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
|
delete cheevos;
|
||||||
delete scoreboard;
|
delete scoreboard;
|
||||||
delete itemTracker;
|
delete itemTracker;
|
||||||
delete roomTracker;
|
delete roomTracker;
|
||||||
@@ -78,6 +103,8 @@ Game::~Game()
|
|||||||
delete text;
|
delete text;
|
||||||
delete stats;
|
delete stats;
|
||||||
|
|
||||||
|
SDL_DestroyTexture(roomNameTexture);
|
||||||
|
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
JA_DeleteSound(deathSound);
|
JA_DeleteSound(deathSound);
|
||||||
}
|
}
|
||||||
@@ -91,7 +118,7 @@ void Game::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -101,13 +128,10 @@ void Game::checkEventHandler()
|
|||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
break;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
debug->switchEnabled();
|
debug->switchEnabled();
|
||||||
@@ -137,53 +161,21 @@ void Game::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F6:
|
case SDL_SCANCODE_F6:
|
||||||
screen->showNotification("MAMA MIRA! SIN MANOS!");
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F7:
|
||||||
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F8:
|
||||||
|
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F9:
|
||||||
|
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 5);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case SDL_SCANCODE_M:
|
|
||||||
board.music = !board.music;
|
|
||||||
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_H:
|
|
||||||
switchPause();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -191,8 +183,57 @@ void Game::checkEventHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba el teclado
|
||||||
|
void Game::checkInput()
|
||||||
|
{
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_switch_music, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
board.music = !board.music;
|
||||||
|
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
if (!board.music)
|
if (!board.music)
|
||||||
@@ -200,28 +241,29 @@ section_t Game::run()
|
|||||||
JA_PauseMusic();
|
JA_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_GAME)
|
while (section->name == SECTION_PROG_GAME)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void Game::update()
|
void Game::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba los eventos de la cola
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba el teclado
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug->clear();
|
debug->clear();
|
||||||
@@ -237,6 +279,7 @@ void Game::update()
|
|||||||
checkGameOver();
|
checkGameOver();
|
||||||
checkEndGame();
|
checkEndGame();
|
||||||
checkRestoringJail();
|
checkRestoringJail();
|
||||||
|
checkSomeCheevos();
|
||||||
scoreboard->update();
|
scoreboard->update();
|
||||||
input->update();
|
input->update();
|
||||||
|
|
||||||
@@ -256,8 +299,8 @@ void Game::render()
|
|||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen->start();
|
||||||
screen->clean(room->getBGColor());
|
|
||||||
|
|
||||||
|
// Dibuja los elementos del juego en orden
|
||||||
room->renderMap();
|
room->renderMap();
|
||||||
room->renderEnemies();
|
room->renderEnemies();
|
||||||
room->renderItems();
|
room->renderItems();
|
||||||
@@ -317,13 +360,8 @@ void Game::renderDebugInfo()
|
|||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void Game::renderRoomName()
|
void Game::renderRoomName()
|
||||||
{
|
{
|
||||||
// Texto en el centro de la pantalla
|
// Dibuja la textura con el nombre de la habitación
|
||||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
|
||||||
color_t color = stringToColor(options->palette, "white");
|
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
|
||||||
|
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
@@ -345,6 +383,9 @@ bool Game::changeRoom(std::string file)
|
|||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
fillRoomNameTexture();
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
@@ -413,7 +454,7 @@ void Game::checkGameOver()
|
|||||||
{
|
{
|
||||||
if (board.lives < 0 && blackScreenCounter > 17)
|
if (board.lives < 0 && blackScreenCounter > 17)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_GAME_OVER;
|
section->name = SECTION_PROG_GAME_OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,6 +475,9 @@ void Game::killPlayer()
|
|||||||
// Actualiza las estadisticas
|
// Actualiza las estadisticas
|
||||||
stats->addDeath(room->getName());
|
stats->addDeath(room->getName());
|
||||||
|
|
||||||
|
// Invalida el logro de pasarse el juego sin morir
|
||||||
|
cheevos->invalidate(11);
|
||||||
|
|
||||||
// Destruye la habitacion y el jugador
|
// Destruye la habitacion y el jugador
|
||||||
delete room;
|
delete room;
|
||||||
delete this->player;
|
delete this->player;
|
||||||
@@ -539,24 +583,21 @@ void Game::setScoreBoardColor()
|
|||||||
// Comprueba si ha finalizado el juego
|
// Comprueba si ha finalizado el juego
|
||||||
bool Game::checkEndGame()
|
bool Game::checkEndGame()
|
||||||
{
|
{
|
||||||
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
||||||
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
|
|
||||||
if (haveTheItems)
|
if (haveTheItems)
|
||||||
{
|
{
|
||||||
board.jailEnabled = true;
|
board.jailEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnTheRoom && haveTheItems && isOnTheDoor)
|
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENDING;
|
// Comprueba los logros de completar el juego
|
||||||
return true;
|
checkEndGameCheevos();
|
||||||
}
|
|
||||||
|
|
||||||
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor)
|
section->name = SECTION_PROG_ENDING;
|
||||||
{
|
|
||||||
section.name = SECTION_PROG_ENDING;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,12 +657,25 @@ void Game::checkRestoringJail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
counter++;
|
|
||||||
|
if (!paused)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Incrementa el numero de vidas
|
||||||
if (counter == 100)
|
if (counter == 100)
|
||||||
{
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
board.lives++;
|
board.lives++;
|
||||||
JA_PlaySound(deathSound);
|
JA_PlaySound(deathSound);
|
||||||
|
|
||||||
|
// Invalida el logro de completar el juego sin entrar a la jail
|
||||||
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f);
|
||||||
|
if (!haveTheItems)
|
||||||
|
{
|
||||||
|
cheevos->invalidate(9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,4 +691,92 @@ void Game::initStats()
|
|||||||
}
|
}
|
||||||
|
|
||||||
stats->init();
|
stats->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea la textura con el nombre de la habitación
|
||||||
|
void Game::fillRoomNameTexture()
|
||||||
|
{
|
||||||
|
// Pone la textura como destino de renderizado
|
||||||
|
SDL_SetRenderTarget(renderer, roomNameTexture);
|
||||||
|
|
||||||
|
// Rellena la textura de color
|
||||||
|
const color_t color = stringToColor(options->palette, "white");
|
||||||
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
|
||||||
|
|
||||||
|
// Deja el renderizador por defecto
|
||||||
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba algunos logros
|
||||||
|
void Game::checkSomeCheevos()
|
||||||
|
{
|
||||||
|
// Logros sobre la cantidad de items
|
||||||
|
if (board.items == totalItems)
|
||||||
|
{
|
||||||
|
cheevos->unlock(4);
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.75f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.5f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.25f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logros sobre las habitaciones visitadas
|
||||||
|
if (board.rooms >= 60)
|
||||||
|
{
|
||||||
|
cheevos->unlock(7);
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 40)
|
||||||
|
{
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 20)
|
||||||
|
{
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void Game::checkEndGameCheevos()
|
||||||
|
{
|
||||||
|
// "Complete the game"
|
||||||
|
cheevos->unlock(8);
|
||||||
|
|
||||||
|
// "Complete the game without entering the jail"
|
||||||
|
cheevos->unlock(9);
|
||||||
|
|
||||||
|
// "Complete the game with all items"
|
||||||
|
if (board.items == totalItems)
|
||||||
|
{
|
||||||
|
cheevos->unlock(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Complete the game without dying"
|
||||||
|
cheevos->unlock(11);
|
||||||
|
|
||||||
|
// "Complete the game in under 30 minutes"
|
||||||
|
if (scoreboard->getMinutes() < 30)
|
||||||
|
{
|
||||||
|
cheevos->unlock(12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include "cheevos.h"
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@@ -26,35 +27,38 @@ class Game
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Screen *screen; // Objeto encargado de manejar el renderizador
|
Screen *screen; // Objeto encargado de manejar el renderizador
|
||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Player *player; // Objeto con el jugador
|
Player *player; // Objeto con el jugador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
|
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
Resource *resource; // Objeto con los recursos
|
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Resource *resource; // Objeto con los recursos
|
||||||
options_t *options; // Puntero a las opciones del juego
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
||||||
|
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music music; // Musica que suena durante el juego
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string currentRoom; // Fichero de la habitación actual
|
||||||
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
||||||
JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador
|
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
|
||||||
board_t board; // Estructura con los datos del marcador
|
board_t board; // Estructura con los datos del marcador
|
||||||
bool paused; // Indica si el juego se encuentra en pausa
|
bool paused; // Indica si el juego se encuentra en pausa
|
||||||
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
||||||
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
||||||
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
||||||
|
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void update();
|
void update();
|
||||||
@@ -79,6 +83,9 @@ private:
|
|||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
bool changeRoom(std::string file);
|
bool changeRoom(std::string file);
|
||||||
|
|
||||||
|
// Comprueba el teclado
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
||||||
void checkPlayerOnBorder();
|
void checkPlayerOnBorder();
|
||||||
|
|
||||||
@@ -133,15 +140,24 @@ private:
|
|||||||
// Inicializa el diccionario de las estadísticas
|
// Inicializa el diccionario de las estadísticas
|
||||||
void initStats();
|
void initStats();
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
void fillRoomNameTexture();
|
||||||
|
|
||||||
|
// Comprueba algunos logros
|
||||||
|
void checkSomeCheevos();
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void checkEndGameCheevos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include "game_over.h"
|
#include "game_over.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,8 +22,8 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_GAME_OVER;
|
section->name = SECTION_PROG_GAME_OVER;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
endSection = 400;
|
endSection = 400;
|
||||||
@@ -55,14 +57,17 @@ GameOver::~GameOver()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void GameOver::update()
|
void GameOver::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
updateColor();
|
updateColor();
|
||||||
@@ -83,7 +88,7 @@ void GameOver::update()
|
|||||||
void GameOver::render()
|
void GameOver::render()
|
||||||
{
|
{
|
||||||
const int y = 32;
|
const int y = 32;
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
@@ -121,71 +126,56 @@ void GameOver::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Comprueba las entradas
|
||||||
section_t GameOver::run()
|
void GameOver::checkInput()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_GAME_OVER)
|
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
void GameOver::run()
|
||||||
|
{
|
||||||
|
while (section->name == SECTION_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
@@ -195,16 +185,15 @@ void GameOver::updateColor()
|
|||||||
|
|
||||||
if (counter < half)
|
if (counter < half)
|
||||||
{
|
{
|
||||||
// const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
|
||||||
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
||||||
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
||||||
color = colors.at(index);
|
color = colors[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
||||||
const int index = (colors.size() - 1) * step;
|
const int index = (colors.size() - 1) * step;
|
||||||
color = colors.at(index);
|
color = colors[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,8 +229,8 @@ void GameOver::updateCounters()
|
|||||||
// Comprueba si ha terminado la sección
|
// Comprueba si ha terminado la sección
|
||||||
else if (counter == endSection)
|
else if (counter == endSection)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -23,16 +24,17 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
AnimatedSprite *playerSprite; // Sprite con el jugador
|
AnimatedSprite *playerSprite; // Sprite con el jugador
|
||||||
AnimatedSprite *tvSprite; // Sprite con el televisor
|
AnimatedSprite *tvSprite; // Sprite con el televisor
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
std::vector<color_t> colors; // Vector con los colores para el fade
|
||||||
@@ -40,7 +42,7 @@ private:
|
|||||||
int endSection; // Contador: cuando acaba la sección
|
int endSection; // Contador: cuando acaba la sección
|
||||||
int iniFade; // Contador: cuando emiepza el fade
|
int iniFade; // Contador: cuando emiepza el fade
|
||||||
int fadeLenght; // Contador: duración del fade
|
int fadeLenght; // Contador: duración del fade
|
||||||
JA_Music music; // Musica que suena durante el juego
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -51,6 +53,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
void updateColor();
|
void updateColor();
|
||||||
|
|
||||||
@@ -65,13 +70,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameOver();
|
~GameOver();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
235
source/intro.cpp
@@ -1,14 +1,16 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -31,21 +33,13 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_INTRO;
|
section->name = SECTION_PROG_INTRO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
loadCounter = 0;
|
loadCounter = 0;
|
||||||
lineCounter = 0;
|
|
||||||
loadingFirstPart = true;
|
loadingFirstPart = true;
|
||||||
|
loadRect = {0, 0, 51, 1};
|
||||||
// Ls lineas que tapan la primera textura
|
|
||||||
for (int i = 0; i < 192; ++i)
|
|
||||||
{
|
|
||||||
lines[i].x1 = 0;
|
|
||||||
lines[i].x2 = 257;
|
|
||||||
lines[i].y = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
||||||
for (int i = 0; i < 192; ++i)
|
for (int i = 0; i < 192; ++i)
|
||||||
@@ -90,89 +84,79 @@ void Intro::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Intro::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
switchPalette();
|
{
|
||||||
break;
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestiona el contador de carga
|
// Gestiona el contador de carga
|
||||||
void Intro::updateLoad()
|
void Intro::updateLoad()
|
||||||
{
|
{
|
||||||
// Primera parte de la carga, la parte en blanco ynegro
|
// Primera parte de la carga, la parte en blanco y negro
|
||||||
if (loadingFirstPart)
|
if (loadingFirstPart)
|
||||||
{
|
{
|
||||||
// Cada 5 pasos el loadCounter se incrementa en uno
|
// Cada 5 pasos el loadCounter se incrementa en uno
|
||||||
const int numSteps = 5;
|
const int numSteps = 5;
|
||||||
|
const int step = 51;
|
||||||
loadCounter = counter / numSteps;
|
loadCounter = counter / numSteps;
|
||||||
|
|
||||||
if (loadCounter < 192)
|
if (loadCounter < 192)
|
||||||
{
|
{
|
||||||
const int step = 256 / numSteps;
|
loadRect.x = step * (counter % numSteps);
|
||||||
lines[lineIndex[loadCounter]].x1 = step * (counter % numSteps);
|
loadRect.y = lineIndex[loadCounter];
|
||||||
|
sprite1->setSpriteClip(loadRect);
|
||||||
// Elimina por completo la linea anterior
|
sprite1->setRect(loadRect);
|
||||||
if (loadCounter > 0)
|
|
||||||
{
|
|
||||||
lines[lineIndex[loadCounter - 1]].x1 = 256;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
|
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
|
||||||
else if (loadCounter == 192)
|
else if (loadCounter == 192)
|
||||||
{
|
{
|
||||||
loadingFirstPart = false;
|
loadingFirstPart = false;
|
||||||
loadCounter = 0;
|
loadCounter = 0;
|
||||||
|
loadRect = {0, 0, 16, 8};
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
JA_PlayMusic(loadingSound3);
|
JA_PlayMusic(loadingSound3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,70 +164,52 @@ void Intro::updateLoad()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadCounter += 2;
|
loadCounter += 2;
|
||||||
loadCounter = std::min(loadCounter, 768);
|
loadRect.x = (loadCounter * 8) % 256;
|
||||||
|
loadRect.y = (loadCounter / 32) * 8;
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la intro
|
||||||
|
if (loadCounter >= 768)
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
|
JA_StopMusic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
void Intro::updateCounter()
|
void Intro::updateCounter()
|
||||||
{
|
{
|
||||||
if (preCounter >= 50)
|
(preCounter >= 50) ? counter++ : preCounter++;
|
||||||
{ // Si el contador previo ha llegado a 50, empieza a contar el contador normal
|
|
||||||
if (counter == 0)
|
if (counter == 1)
|
||||||
{
|
{
|
||||||
JA_PlayMusic(loadingSound2);
|
JA_PlayMusic(loadingSound2);
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Actualiza el precontador
|
|
||||||
preCounter++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
void Intro::renderLoad()
|
void Intro::renderLoad()
|
||||||
{
|
{
|
||||||
// Carga 1 - Blanco y negro
|
loadingFirstPart ? sprite1->render() : sprite2->render();
|
||||||
if (loadingFirstPart)
|
|
||||||
{
|
|
||||||
// Dibuja la textura de pantalla de carga en blanco y negro en pantalla
|
|
||||||
sprite1->render();
|
|
||||||
|
|
||||||
// Dibuja las 192 lineas negras sobre la textura
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
||||||
for (int i = 0; i < 192; ++i)
|
|
||||||
{
|
|
||||||
SDL_RenderDrawLine(renderer, lines[i].x1, lines[i].y, lines[i].x2, lines[i].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// Carga 2 - Color
|
|
||||||
{
|
|
||||||
sprite1->render();
|
|
||||||
SDL_Rect rect = {0, 0, 8, 8};
|
|
||||||
for (int i = 0; i < loadCounter; ++i)
|
|
||||||
{
|
|
||||||
rect.x = (i * 8) % 256;
|
|
||||||
rect.y = (i / 32) * 8;
|
|
||||||
sprite2->setRect(rect);
|
|
||||||
sprite2->setSpriteClip(rect);
|
|
||||||
sprite2->render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Intro::update()
|
void Intro::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
updateCounter();
|
updateCounter();
|
||||||
@@ -253,14 +219,6 @@ void Intro::update()
|
|||||||
|
|
||||||
// Actualiza las notificaciones
|
// Actualiza las notificaciones
|
||||||
screen->updateNotifier();
|
screen->updateNotifier();
|
||||||
|
|
||||||
// Comprueba si ha terminado la intro
|
|
||||||
if (loadCounter >= 768)
|
|
||||||
{
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
JA_StopMusic();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,9 +228,6 @@ void Intro::render()
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean();
|
|
||||||
|
|
||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
renderLoad();
|
renderLoad();
|
||||||
|
|
||||||
@@ -281,20 +236,19 @@ void Intro::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Intro::run()
|
void Intro::run()
|
||||||
{
|
{
|
||||||
// Inicia el sonido de carga
|
// Inicia el sonido de carga
|
||||||
JA_SetVolume(64);
|
JA_SetVolume(64);
|
||||||
JA_PlayMusic(loadingSound1);
|
JA_PlayMusic(loadingSound1);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_INTRO)
|
while (section->name == SECTION_PROG_INTRO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
@@ -312,4 +266,45 @@ void Intro::switchPalette()
|
|||||||
sprite1->setTexture(resource->getTexture("loading_screen_bn.png"));
|
sprite1->setTexture(resource->getTexture("loading_screen_bn.png"));
|
||||||
sprite2->setTexture(resource->getTexture("loading_screen_color.png"));
|
sprite2->setTexture(resource->getTexture("loading_screen_color.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recreateLoadingScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reconstruye la pantalla de carga
|
||||||
|
void Intro::recreateLoadingScreen()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Primera parte de la carga, la parte en blanco y negro
|
||||||
|
if (loadingFirstPart)
|
||||||
|
{
|
||||||
|
const int numSteps = 5;
|
||||||
|
const int step = 51;
|
||||||
|
|
||||||
|
for (int i = 0; i <= counter; i++)
|
||||||
|
{
|
||||||
|
loadCounter = i / numSteps;
|
||||||
|
loadRect.x = step * (i % numSteps);
|
||||||
|
loadRect.y = lineIndex[loadCounter];
|
||||||
|
sprite1->setSpriteClip(loadRect);
|
||||||
|
sprite1->setRect(loadRect);
|
||||||
|
sprite1->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Segunda parte de la carga, la parte de los bloques en color
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= loadCounter; i++)
|
||||||
|
{
|
||||||
|
loadRect.x = (i * 8) % 256;
|
||||||
|
loadRect.y = (i / 32) * 8;
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
sprite2->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -24,27 +25,27 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *loadingScreenTexture1; // Textura con la pantalla de carga en blanco y negro
|
Texture *loadingScreenTexture1; // Textura con la pantalla de carga en blanco y negro
|
||||||
Texture *loadingScreenTexture2; // Textura con la pantalla de carga en color
|
Texture *loadingScreenTexture2; // Textura con la pantalla de carga en color
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
||||||
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo para realizar una pausa inicial
|
int preCounter; // Contador previo para realizar una pausa inicial
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
int loadCounter; // Contador para controlar las cargas
|
||||||
int loadCounter; // Contador para controlar las cargas
|
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
|
||||||
int lineCounter; // Contador para dibujar las lineas de carga
|
JA_Music_t *loadingSound1; // Sonidos para imitar la carga tipo spectrum
|
||||||
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
|
JA_Music_t *loadingSound2; // Sonidos para imitar la carga tipo spectrum
|
||||||
JA_Music loadingSound1; // Sonidos para imitar la carga tipo spectrum
|
JA_Music_t *loadingSound3; // Sonidos para imitar la carga tipo spectrum
|
||||||
JA_Music loadingSound2; // Sonidos para imitar la carga tipo spectrum
|
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
|
||||||
JA_Music loadingSound3; // Sonidos para imitar la carga tipo spectrum
|
SDL_Rect loadRect; // Rectangulo para dibujar la pantalla de carga
|
||||||
h_line_t lines[192]; // Las 192 lineas que forman la pantalla de carga
|
|
||||||
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
|
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -55,6 +56,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
void updateCounter();
|
void updateCounter();
|
||||||
|
|
||||||
@@ -67,15 +71,18 @@ private:
|
|||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
void switchPalette();
|
void switchPalette();
|
||||||
|
|
||||||
|
// Reconstruye la pantalla de carga
|
||||||
|
void recreateLoadingScreen();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Item::~Item()
|
|||||||
void Item::render()
|
void Item::render()
|
||||||
{
|
{
|
||||||
const int index = (counter / colorChangeSpeed) % color.size();
|
const int index = (counter / colorChangeSpeed) % color.size();
|
||||||
sprite->getTexture()->setColor(color.at(index).r, color.at(index).g, color.at(index).b);
|
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
||||||
sprite->render();
|
sprite->render();
|
||||||
sprite->getTexture()->setColor(255, 255, 255);
|
sprite->getTexture()->setColor(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
171
source/logo.cpp
@@ -2,14 +2,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection)
|
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -26,19 +28,18 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
|
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(256 + (i * 3));
|
sprite[i]->setPosX(256 + (i * 3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(-181 - (i * 3));
|
sprite[i]->setPosX(-181 - (i * 3));
|
||||||
}
|
}
|
||||||
sprite.at(i)->setPosY(83 + i);
|
sprite[i]->setPosY(83 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = subsection;
|
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
initFade = 300;
|
initFade = 300;
|
||||||
@@ -77,59 +78,50 @@ void Logo::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
|
void Logo::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_TITLE;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
switchPalette();
|
{
|
||||||
break;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
|
endSection();
|
||||||
default:
|
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
|
||||||
endSection();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,22 +134,22 @@ void Logo::updateJAILGAMES()
|
|||||||
{
|
{
|
||||||
const int speed = 8;
|
const int speed = 8;
|
||||||
const int dest = 37;
|
const int dest = 37;
|
||||||
if (sprite.at(i)->getPosX() != 37)
|
if (sprite[i]->getPosX() != 37)
|
||||||
{
|
{
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite.at(i)->incPosX(-speed);
|
sprite[i]->incPosX(-speed);
|
||||||
if (sprite.at(i)->getPosX() < dest)
|
if (sprite[i]->getPosX() < dest)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(dest);
|
sprite[i]->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite.at(i)->incPosX(speed);
|
sprite[i]->incPosX(speed);
|
||||||
if (sprite.at(i)->getPosX() > dest)
|
if (sprite[i]->getPosX() > dest)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(dest);
|
sprite[i]->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,72 +165,84 @@ void Logo::updateTextureColors()
|
|||||||
|
|
||||||
if (counter == ini + inc * 0)
|
if (counter == ini + inc * 0)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 1)
|
else if (counter == ini + inc * 1)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 2)
|
else if (counter == ini + inc * 2)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 3)
|
else if (counter == ini + inc * 3)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 4)
|
else if (counter == ini + inc * 4)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 5)
|
else if (counter == ini + inc * 5)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 6)
|
else if (counter == ini + inc * 6)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 7)
|
else if (counter == ini + inc * 7)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(7).r, color.at(7).g, color.at(7).b);
|
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 0)
|
else if (counter == initFade + inc * 0)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 1)
|
else if (counter == initFade + inc * 1)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 2)
|
else if (counter == initFade + inc * 2)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 3)
|
else if (counter == initFade + inc * 3)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 4)
|
else if (counter == initFade + inc * 4)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 5)
|
else if (counter == initFade + inc * 5)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 6)
|
else if (counter == initFade + inc * 6)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +258,9 @@ void Logo::update()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
checkEventHandler();
|
checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
checkInput();
|
||||||
|
|
||||||
// Incrementa el contador
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
@@ -295,18 +302,16 @@ void Logo::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Logo::run()
|
void Logo::run()
|
||||||
{
|
{
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_LOGO)
|
while (section->name == SECTION_PROG_LOGO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
@@ -318,5 +323,5 @@ void Logo::switchPalette()
|
|||||||
// Termina la sección
|
// Termina la sección
|
||||||
void Logo::endSection()
|
void Logo::endSection()
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENTER_ID;
|
section->name = SECTION_PROG_ENTER_ID;
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -21,17 +22,18 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *texture; // Textura con los graficos "JAILGAMES"
|
Texture *texture; // Textura con los graficos "JAILGAMES"
|
||||||
Texture *texture2; // Textura con los graficos "Since 1998"
|
Texture *texture2; // Textura con los graficos "Since 1998"
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *sprite2; // Sprite para manejar la textura2
|
Sprite *sprite2; // Sprite para manejar la textura2
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<color_t> color; // Vector con los colores para el fade
|
std::vector<color_t> color; // Vector con los colores para el fade
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
||||||
@@ -47,6 +49,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Gestiona el logo de JAILGAME
|
// Gestiona el logo de JAILGAME
|
||||||
void updateJAILGAMES();
|
void updateJAILGAMES();
|
||||||
|
|
||||||
@@ -61,13 +66,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection);
|
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -181,13 +181,13 @@ void Player::checkInput()
|
|||||||
|
|
||||||
if (!autoMovement)
|
if (!autoMovement)
|
||||||
{ // Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
|
{ // Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
|
||||||
if (input->checkInput(INPUT_LEFT, REPEAT_TRUE))
|
if (input->checkInput(input_left))
|
||||||
{
|
{
|
||||||
vx = -0.6f;
|
vx = -0.6f;
|
||||||
sprite->setFlipH(true);
|
sprite->setFlipH(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(INPUT_RIGHT, REPEAT_TRUE))
|
else if (input->checkInput(input_right))
|
||||||
{
|
{
|
||||||
vx = 0.6f;
|
vx = 0.6f;
|
||||||
sprite->setFlipH(false);
|
sprite->setFlipH(false);
|
||||||
@@ -216,7 +216,7 @@ void Player::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_UP, REPEAT_TRUE))
|
if (input->checkInput(input_jump))
|
||||||
{
|
{
|
||||||
// Solo puede saltar si ademas de estar (state == s_standing)
|
// Solo puede saltar si ademas de estar (state == s_standing)
|
||||||
// Esta sobre el suelo, rampa o suelo que se mueve
|
// Esta sobre el suelo, rampa o suelo que se mueve
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ public:
|
|||||||
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
|
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
|
||||||
int jumpIni; // Valor del eje Y en el que se inicia el salto
|
int jumpIni; // Valor del eje Y en el que se inicia el salto
|
||||||
float maxVY; // Velocidad máxima que puede alcanzar al desplazarse en vertical
|
float maxVY; // Velocidad máxima que puede alcanzar al desplazarse en vertical
|
||||||
std::vector<JA_Sound> jumpSound; // Vecor con todos los sonidos del salto
|
std::vector<JA_Sound_t*> jumpSound; // Vecor con todos los sonidos del salto
|
||||||
std::vector<JA_Sound> fallSound; // Vecor con todos los sonidos de la caída
|
std::vector<JA_Sound_t*> fallSound; // Vecor con todos los sonidos de la caída
|
||||||
int jumpCounter; // Cuenta el tiempo de salto
|
int jumpCounter; // Cuenta el tiempo de salto
|
||||||
int fallCounter; // Cuenta el tiempo de caida
|
int fallCounter; // Cuenta el tiempo de caida
|
||||||
bool alive; // Indica si el jugador esta vivo o no
|
bool alive; // Indica si el jugador esta vivo o no
|
||||||
|
|||||||
113
source/room.cpp
@@ -473,7 +473,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o
|
|||||||
setAnimatedTiles();
|
setAnimatedTiles();
|
||||||
|
|
||||||
// Crea la textura para el mapa de tiles de la habitación
|
// Crea la textura para el mapa de tiles de la habitación
|
||||||
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
|
||||||
if (mapTexture == nullptr)
|
if (mapTexture == nullptr)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
@@ -534,8 +534,9 @@ color_t Room::getBorderColor()
|
|||||||
// Crea la textura con el mapeado de la habitación
|
// Crea la textura con el mapeado de la habitación
|
||||||
void Room::fillMapTexture()
|
void Room::fillMapTexture()
|
||||||
{
|
{
|
||||||
|
const color_t color = stringToColor(options->palette, bgColor);
|
||||||
SDL_SetRenderTarget(renderer, mapTexture);
|
SDL_SetRenderTarget(renderer, mapTexture);
|
||||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
||||||
@@ -548,13 +549,13 @@ void Room::fillMapTexture()
|
|||||||
// Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1
|
// Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1
|
||||||
// Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices)
|
// Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices)
|
||||||
const int index = (y * mapWidth) + x;
|
const int index = (y * mapWidth) + x;
|
||||||
const bool a = (tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 19 * tileSetWidth);
|
const bool a = (tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 19 * tileSetWidth);
|
||||||
const bool b = tileMap.at(index) > -1;
|
const bool b = tileMap[index] > -1;
|
||||||
|
|
||||||
if (b && !a)
|
if (b && !a)
|
||||||
{
|
{
|
||||||
clip.x = (tileMap.at(index) % tileSetWidth) * tileSize;
|
clip.x = (tileMap[index] % tileSetWidth) * tileSize;
|
||||||
clip.y = (tileMap.at(index) / tileSetWidth) * tileSize;
|
clip.y = (tileMap[index] / tileSetWidth) * tileSize;
|
||||||
texture->render(renderer, x * tileSize, y * tileSize, &clip);
|
texture->render(renderer, x * tileSize, y * tileSize, &clip);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -664,7 +665,8 @@ void Room::fillMapTexture()
|
|||||||
void Room::renderMap()
|
void Room::renderMap()
|
||||||
{
|
{
|
||||||
// Dibuja la textura con el mapa en pantalla
|
// Dibuja la textura con el mapa en pantalla
|
||||||
SDL_RenderCopy(renderer, mapTexture, nullptr, nullptr);
|
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
|
||||||
|
SDL_RenderCopy(renderer, mapTexture, nullptr, &dest);
|
||||||
|
|
||||||
// Dibuja los tiles animados
|
// Dibuja los tiles animados
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -763,37 +765,37 @@ tile_e Room::getTile(int index)
|
|||||||
if (onRange)
|
if (onRange)
|
||||||
{
|
{
|
||||||
// Las filas 0-8 son de tiles t_wall
|
// Las filas 0-8 son de tiles t_wall
|
||||||
if ((tileMap.at(index) >= 0) && (tileMap.at(index) < 9 * tileSetWidth))
|
if ((tileMap[index] >= 0) && (tileMap[index] < 9 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_wall;
|
return t_wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Las filas 9-17 son de tiles t_passable
|
// Las filas 9-17 son de tiles t_passable
|
||||||
else if ((tileMap.at(index) >= 9 * tileSetWidth) && (tileMap.at(index) < 18 * tileSetWidth))
|
else if ((tileMap[index] >= 9 * tileSetWidth) && (tileMap[index] < 18 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_passable;
|
return t_passable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Las filas 18-20 es de tiles t_animated
|
// Las filas 18-20 es de tiles t_animated
|
||||||
else if ((tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 21 * tileSetWidth))
|
else if ((tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 21 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_animated;
|
return t_animated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 21 es de tiles t_slope_r
|
// La fila 21 es de tiles t_slope_r
|
||||||
else if ((tileMap.at(index) >= 21 * tileSetWidth) && (tileMap.at(index) < 22 * tileSetWidth))
|
else if ((tileMap[index] >= 21 * tileSetWidth) && (tileMap[index] < 22 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_slope_r;
|
return t_slope_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 22 es de tiles t_slope_l
|
// La fila 22 es de tiles t_slope_l
|
||||||
else if ((tileMap.at(index) >= 22 * tileSetWidth) && (tileMap.at(index) < 23 * tileSetWidth))
|
else if ((tileMap[index] >= 22 * tileSetWidth) && (tileMap[index] < 23 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_slope_l;
|
return t_slope_l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 23 es de tiles t_kill
|
// La fila 23 es de tiles t_kill
|
||||||
else if ((tileMap.at(index) >= 23 * tileSetWidth) && (tileMap.at(index) < 24 * tileSetWidth))
|
else if ((tileMap[index] >= 23 * tileSetWidth) && (tileMap[index] < 24 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_kill;
|
return t_kill;
|
||||||
}
|
}
|
||||||
@@ -820,10 +822,10 @@ bool Room::itemCollision(SDL_Rect &rect)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)items.size(); ++i)
|
for (int i = 0; i < (int)items.size(); ++i)
|
||||||
{
|
{
|
||||||
if (checkCollision(rect, items.at(i)->getCollider()))
|
if (checkCollision(rect, items[i]->getCollider()))
|
||||||
{
|
{
|
||||||
itemTracker->addItem(name, items.at(i)->getPos());
|
itemTracker->addItem(name, items[i]->getPos());
|
||||||
delete items.at(i);
|
delete items[i];
|
||||||
items.erase(items.begin() + i);
|
items.erase(items.begin() + i);
|
||||||
JA_PlaySound(itemSound);
|
JA_PlaySound(itemSound);
|
||||||
*itemsPicked = *itemsPicked + 1;
|
*itemsPicked = *itemsPicked + 1;
|
||||||
@@ -955,14 +957,14 @@ void Room::setBottomSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -973,11 +975,11 @@ void Room::setBottomSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
bottomSurfaces.push_back(line);
|
bottomSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1018,14 +1020,14 @@ void Room::setTopSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = (tile.at(i) / mapWidth) * tileSize;
|
line.y = (tile[i] / mapWidth) * tileSize;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -1036,11 +1038,11 @@ void Room::setTopSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
topSurfaces.push_back(line);
|
topSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1080,9 +1082,9 @@ void Room::setLeftSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
v_line_t line;
|
v_line_t line;
|
||||||
line.x = (tile.at(i) % mapWidth) * tileSize;
|
line.x = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
|
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||||
while (tile.at(i) + mapWidth == tile.at(i + 1))
|
while (tile[i] + mapWidth == tile[i + 1])
|
||||||
{
|
{
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -1090,7 +1092,7 @@ void Room::setLeftSurfaces()
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
leftSurfaces.push_back(line);
|
leftSurfaces.push_back(line);
|
||||||
i++;
|
i++;
|
||||||
} while (i < (int)tile.size() - 1);
|
} while (i < (int)tile.size() - 1);
|
||||||
@@ -1128,9 +1130,9 @@ void Room::setRightSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
v_line_t line;
|
v_line_t line;
|
||||||
line.x = ((tile.at(i) % mapWidth) * tileSize) + tileSize - 1;
|
line.x = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
|
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||||
while (tile.at(i) + mapWidth == tile.at(i + 1))
|
while (tile[i] + mapWidth == tile[i + 1])
|
||||||
{
|
{
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -1138,7 +1140,7 @@ void Room::setRightSurfaces()
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
rightSurfaces.push_back(line);
|
rightSurfaces.push_back(line);
|
||||||
i++;
|
i++;
|
||||||
} while (i < (int)tile.size() - 1);
|
} while (i < (int)tile.size() - 1);
|
||||||
@@ -1165,14 +1167,14 @@ void Room::setLeftSlopes()
|
|||||||
while (found.size() > 0)
|
while (found.size() > 0)
|
||||||
{
|
{
|
||||||
d_line_t line;
|
d_line_t line;
|
||||||
line.x1 = (found.at(0) % mapWidth) * tileSize;
|
line.x1 = (found[0] % mapWidth) * tileSize;
|
||||||
line.y1 = (found.at(0) / mapWidth) * tileSize;
|
line.y1 = (found[0] / mapWidth) * tileSize;
|
||||||
int lookingFor = found.at(0) + mapWidth + 1;
|
int lookingFor = found[0] + mapWidth + 1;
|
||||||
int lastOneFound = found.at(0);
|
int lastOneFound = found[0];
|
||||||
found.erase(found.begin());
|
found.erase(found.begin());
|
||||||
for (int i = 0; i < (int)found.size(); ++i)
|
for (int i = 0; i < (int)found.size(); ++i)
|
||||||
{
|
{
|
||||||
if (found.at(i) == lookingFor)
|
if (found[i] == lookingFor)
|
||||||
{
|
{
|
||||||
lastOneFound = lookingFor;
|
lastOneFound = lookingFor;
|
||||||
lookingFor += mapWidth + 1;
|
lookingFor += mapWidth + 1;
|
||||||
@@ -1206,14 +1208,14 @@ void Room::setRightSlopes()
|
|||||||
while (found.size() > 0)
|
while (found.size() > 0)
|
||||||
{
|
{
|
||||||
d_line_t line;
|
d_line_t line;
|
||||||
line.x1 = ((found.at(0) % mapWidth) * tileSize) + tileSize - 1;
|
line.x1 = ((found[0] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
line.y1 = (found.at(0) / mapWidth) * tileSize;
|
line.y1 = (found[0] / mapWidth) * tileSize;
|
||||||
int lookingFor = found.at(0) + mapWidth - 1;
|
int lookingFor = found[0] + mapWidth - 1;
|
||||||
int lastOneFound = found.at(0);
|
int lastOneFound = found[0];
|
||||||
found.erase(found.begin());
|
found.erase(found.begin());
|
||||||
for (int i = 0; i < (int)found.size(); ++i)
|
for (int i = 0; i < (int)found.size(); ++i)
|
||||||
{
|
{
|
||||||
if (found.at(i) == lookingFor)
|
if (found[i] == lookingFor)
|
||||||
{
|
{
|
||||||
lastOneFound = lookingFor;
|
lastOneFound = lookingFor;
|
||||||
lookingFor += mapWidth - 1;
|
lookingFor += mapWidth - 1;
|
||||||
@@ -1256,14 +1258,14 @@ void Room::setAutoSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = (tile.at(i) / mapWidth) * tileSize;
|
line.y = (tile[i] / mapWidth) * tileSize;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -1274,11 +1276,11 @@ void Room::setAutoSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
autoSurfaces.push_back(line);
|
autoSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1299,9 +1301,9 @@ void Room::setAnimatedTiles()
|
|||||||
const int x = (i % mapWidth) * tileSize;
|
const int x = (i % mapWidth) * tileSize;
|
||||||
const int y = (i / mapWidth) * tileSize;
|
const int y = (i / mapWidth) * tileSize;
|
||||||
|
|
||||||
// TileMap.at(i) es el tile a poner
|
// TileMap[i] es el tile a poner
|
||||||
const int xc = (tileMap.at(i) % tileSetWidth) * tileSize;
|
const int xc = (tileMap[i] % tileSetWidth) * tileSize;
|
||||||
const int yc = (tileMap.at(i) / tileSetWidth) * tileSize;
|
const int yc = (tileMap[i] / tileSetWidth) * tileSize;
|
||||||
|
|
||||||
aTile_t at;
|
aTile_t at;
|
||||||
at.sprite = new Sprite(x, y, 8, 8, texture, renderer);
|
at.sprite = new Sprite(x, y, 8, 8, texture, renderer);
|
||||||
@@ -1522,9 +1524,6 @@ void Room::openTheJail()
|
|||||||
{
|
{
|
||||||
if (name == "THE JAIL")
|
if (name == "THE JAIL")
|
||||||
{
|
{
|
||||||
// Cambia el color de fondo
|
|
||||||
bgColor = "red";
|
|
||||||
|
|
||||||
// Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero)
|
// Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero)
|
||||||
delete enemies.back();
|
delete enemies.back();
|
||||||
enemies.pop_back();
|
enemies.pop_back();
|
||||||
@@ -1532,7 +1531,7 @@ void Room::openTheJail()
|
|||||||
// Abre las puertas
|
// Abre las puertas
|
||||||
const int tileA = 16 + (13 * 32);
|
const int tileA = 16 + (13 * 32);
|
||||||
const int tileB = 16 + (14 * 32);
|
const int tileB = 16 + (14 * 32);
|
||||||
tileMap.at(tileA) = -1;
|
tileMap[tileA] = -1;
|
||||||
tileMap.at(tileB) = -1;
|
tileMap[tileB] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ private:
|
|||||||
std::string tileMapFile; // Fichero con el mapa de indices de tile
|
std::string tileMapFile; // Fichero con el mapa de indices de tile
|
||||||
std::vector<int> tileMap; // Indice de los tiles a dibujar en la habitación
|
std::vector<int> tileMap; // Indice de los tiles a dibujar en la habitación
|
||||||
int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación
|
int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||||
JA_Sound itemSound; // Sonido producido al coger un objeto
|
JA_Sound_t *itemSound; // Sonido producido al coger un objeto
|
||||||
std::vector<h_line_t> bottomSurfaces; // Lista con las superficies inferiores de la habitación
|
std::vector<h_line_t> bottomSurfaces; // Lista con las superficies inferiores de la habitación
|
||||||
std::vector<h_line_t> topSurfaces; // Lista con las superficies superiores de la habitación
|
std::vector<h_line_t> topSurfaces; // Lista con las superficies superiores de la habitación
|
||||||
std::vector<v_line_t> leftSurfaces; // Lista con las superficies laterales de la parte izquierda de la habitación
|
std::vector<v_line_t> leftSurfaces; // Lista con las superficies laterales de la parte izquierda de la habitación
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Resource *resource, Asset *asset, options_t *options, board_t *board)
|
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Resource *resource, Asset *asset, options_t *options, board_t *board)
|
||||||
{
|
{
|
||||||
// Obten punteros a objetos
|
// Obten punteros a objetos
|
||||||
|
this->renderer = renderer;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->renderer = renderer;
|
|
||||||
this->board = board;
|
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->board = board;
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
itemTexture = resource->getTexture("items.png");
|
itemTexture = resource->getTexture("items.png");
|
||||||
@@ -169,4 +169,10 @@ void ScoreBoard::updateItemsColor()
|
|||||||
{
|
{
|
||||||
itemsColor = stringToColor(options->palette, "magenta");
|
itemsColor = stringToColor(options->palette, "magenta");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
int ScoreBoard::getMinutes()
|
||||||
|
{
|
||||||
|
return getTime().minutes;
|
||||||
}
|
}
|
||||||
@@ -84,6 +84,9 @@ public:
|
|||||||
|
|
||||||
// Quita el modo pausa del marcador
|
// Quita el modo pausa del marcador
|
||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
int getMinutes();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ void Stats::addDeath(std::string name)
|
|||||||
const int index = findByName(name, bufferList);
|
const int index = findByName(name, bufferList);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
bufferList.at(index).died++;
|
bufferList[index].died++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// En caso contrario crea la entrada
|
// En caso contrario crea la entrada
|
||||||
@@ -84,7 +84,7 @@ void Stats::addVisit(std::string name)
|
|||||||
const int index = findByName(name, bufferList);
|
const int index = findByName(name, bufferList);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
bufferList.at(index).visited++;
|
bufferList[index].visited++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// En caso contrario crea la entrada
|
// En caso contrario crea la entrada
|
||||||
@@ -304,8 +304,8 @@ void Stats::updateListFromBuffer()
|
|||||||
|
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{ // Encontrado. Aumenta sus estadisticas
|
{ // Encontrado. Aumenta sus estadisticas
|
||||||
list.at(index).visited += buffer.visited;
|
list[index].visited += buffer.visited;
|
||||||
list.at(index).died += buffer.died;
|
list[index].died += buffer.died;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // En caso contrario crea la entrada
|
{ // En caso contrario crea la entrada
|
||||||
|
|||||||
171
source/title.cpp
@@ -1,14 +1,16 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -25,12 +27,11 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||||
// longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
|
|
||||||
for (int i = 0; i < (int)longText.length(); ++i)
|
for (int i = 0; i < (int)longText.length(); ++i)
|
||||||
{
|
{
|
||||||
letter_t l;
|
letter_t l;
|
||||||
@@ -39,9 +40,28 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
l.enabled = false;
|
l.enabled = false;
|
||||||
letters.push_back(l);
|
letters.push_back(l);
|
||||||
}
|
}
|
||||||
letters.at(0).enabled = true;
|
letters[0].enabled = true;
|
||||||
marqueeSpeed = 3;
|
marqueeSpeed = 3;
|
||||||
|
|
||||||
|
// Crea el cartel de PRESS ENTER
|
||||||
|
#ifdef GAME_CONSOLE
|
||||||
|
const std::string caption = "PRESS START TO PLAY";
|
||||||
|
#else
|
||||||
|
const std::string caption = "PRESS ENTER TO PLAY";
|
||||||
|
#endif
|
||||||
|
const color_t textColor = stringToColor(options->palette, "white");
|
||||||
|
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
|
||||||
|
|
||||||
|
// Crea la textura
|
||||||
|
pressEnterTexture = new Texture(renderer);
|
||||||
|
pressEnterTexture->createBlank(renderer, text->lenght(caption) + 2, text->getCharacterSize() + 2, SDL_TEXTUREACCESS_TARGET);
|
||||||
|
pressEnterTexture->setAsRenderTarget(renderer);
|
||||||
|
pressEnterTexture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
|
text->writeDX(TXT_COLOR | TXT_STROKE, 1, 1, caption, 1, textColor, 1, strokeColor);
|
||||||
|
|
||||||
|
// Crea el sprite
|
||||||
|
pressEnterSprite = new Sprite(128 - (pressEnterTexture->getWidth() / 2), 192 / 5 * 4, pressEnterTexture->getWidth(), pressEnterTexture->getHeight(), pressEnterTexture, renderer);
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
|
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
|
||||||
}
|
}
|
||||||
@@ -51,6 +71,8 @@ Title::~Title()
|
|||||||
{
|
{
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
delete sprite;
|
delete sprite;
|
||||||
|
delete pressEnterSprite;
|
||||||
|
delete pressEnterTexture;
|
||||||
delete text;
|
delete text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,68 +85,54 @@ void Title::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Title::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_RETURN:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
section.name = SECTION_PROG_GAME;
|
{
|
||||||
section.subsection = 0;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
resource->reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
resource->reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
resource->reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
resource->reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_pause, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_GAME;
|
||||||
break;
|
section->subsection = 0;
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
case SDL_SCANCODE_F6:
|
|
||||||
screen->showNotification("MAMA MIRA! SIN MANOS!");
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,20 +141,20 @@ void Title::updateMarquee()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)letters.size(); ++i)
|
for (int i = 0; i < (int)letters.size(); ++i)
|
||||||
{
|
{
|
||||||
if (letters.at(i).enabled)
|
if (letters[i].enabled)
|
||||||
{
|
{
|
||||||
letters.at(i).x -= marqueeSpeed;
|
letters[i].x -= marqueeSpeed;
|
||||||
if (letters.at(i).x < -10)
|
if (letters[i].x < -10)
|
||||||
{
|
{
|
||||||
letters.at(i).enabled = false;
|
letters[i].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i > 0 && letters.at(i - 1).x < 256 && letters.at(i - 1).enabled)
|
if (i > 0 && letters[i - 1].x < 256 && letters[i - 1].enabled)
|
||||||
{
|
{
|
||||||
letters.at(i).enabled = true;
|
letters[i].enabled = true;
|
||||||
letters.at(i).x = letters.at(i - 1).x + text->lenght(letters.at(i - 1).letter) + 1;
|
letters[i].x = letters[i - 1].x + text->lenght(letters[i - 1].letter) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,14 +175,17 @@ void Title::renderMarquee()
|
|||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Title::update()
|
void Title::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Incrementa el contador
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
@@ -186,10 +197,10 @@ void Title::update()
|
|||||||
screen->updateNotifier();
|
screen->updateNotifier();
|
||||||
|
|
||||||
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
||||||
if (letters.at(letters.size() - 1).x < -10)
|
if (letters[letters.size() - 1].x < -10)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section->name = SECTION_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,27 +211,13 @@ void Title::render()
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean();
|
|
||||||
|
|
||||||
// Dibuja el fondo del titulo
|
// Dibuja el fondo del titulo
|
||||||
sprite->render();
|
sprite->render();
|
||||||
|
|
||||||
// Dibuja el texto de PRESS ENTER TO PLAY
|
|
||||||
// SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
|
||||||
// const SDL_Rect rect = {0, 192 / 5 * 4, 256, 8};
|
|
||||||
// SDL_RenderFillRect(renderer, &rect);
|
|
||||||
// if (counter % 80 < 60)
|
|
||||||
//{
|
|
||||||
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Dibuja el texto de PRESS ENTER TO PLAY
|
// Dibuja el texto de PRESS ENTER TO PLAY
|
||||||
if (counter % 80 < 60)
|
if (counter % 80 < 60)
|
||||||
{
|
{
|
||||||
const color_t textColor = stringToColor(options->palette, "white");
|
pressEnterSprite->render();
|
||||||
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
|
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la marquesina
|
// Dibuja la marquesina
|
||||||
@@ -231,15 +228,13 @@ void Title::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Title::run()
|
void Title::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_TITLE)
|
while (section->name == SECTION_PROG_TITLE)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga las texturas
|
// Recarga las texturas
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/resource.h"
|
#include "common/resource.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
@@ -25,19 +26,22 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *texture; // Textura con los graficos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite; // Sprite para manejar la textura
|
Texture *texture; // Textura con los graficos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Sprite *sprite; // Sprite para manejar la textura
|
||||||
options_t *options; // Puntero a las opciones del juego
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
|
||||||
|
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
std::string longText; // Texto que aparece en la parte inferior del titulo
|
std::string longText; // Texto que aparece en la parte inferior del titulo
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
@@ -53,6 +57,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza la marquesina
|
// Actualiza la marquesina
|
||||||
void updateMarquee();
|
void updateMarquee();
|
||||||
|
|
||||||
@@ -67,13 +74,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||