Optimizaciones de código

This commit is contained in:
2022-09-24 19:16:39 +02:00
parent f3aeed9428
commit b44869341c
99 changed files with 441 additions and 509 deletions

View File

@@ -1,16 +1,13 @@
name=THE JAIL name=THE JAIL
bgColor=bright_blue bgColor=bright_blue
border=blue border=blue
tilemap=01.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=02.room roomRight=02.room
[tilemap]
01.tmx
[/tilemap]
[enemy] [enemy]
tileset=jailer.png tileset=jailer.png
animation=jailer.ani animation=jailer.ani

View File

@@ -1,16 +1,13 @@
name=road to the jail name=road to the jail
bgColor=black bgColor=black
border=cyan border=cyan
tilemap=02.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=04.room roomDown=04.room
roomLeft=01.room roomLeft=01.room
roomRight=03.room roomRight=03.room
[tilemap]
02.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=void main name=void main
bgColor=black bgColor=black
border=magenta border=magenta
tilemap=03.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=02.room roomLeft=02.room
roomRight=0 roomRight=0
[tilemap]
03.tmx
[/tilemap]
[enemy] [enemy]
tileset=bin.png tileset=bin.png
animation=bin.ani animation=bin.ani

View File

@@ -1,16 +1,13 @@
name=no 04 name=no 04
bgColor=black bgColor=black
border=red border=red
tilemap=04.tmx
tileset=standard.png tileset=standard.png
roomUp=02.room roomUp=02.room
roomDown=0 roomDown=0
roomLeft=07.room roomLeft=07.room
roomRight=05.room roomRight=05.room
[tilemap]
04.tmx
[/tilemap]
[enemy] [enemy]
tileset=chip.png tileset=chip.png
animation=chip.ani animation=chip.ani

View File

@@ -1,16 +1,13 @@
name=no 05 name=no 05
bgColor=black bgColor=black
border=red border=red
tilemap=05.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=60.room roomDown=60.room
roomLeft=04.room roomLeft=04.room
roomRight=06.room roomRight=06.room
[tilemap]
05.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 06 name=no 06
bgColor=black bgColor=black
border=red border=red
tilemap=06.tmx
tileset=standard.png tileset=standard.png
roomUp=15.room roomUp=15.room
roomDown=0 roomDown=0
roomLeft=05.room roomLeft=05.room
roomRight=25.room roomRight=25.room
[tilemap]
06.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=sigmasua name=sigmasua
bgColor=black bgColor=black
border=black border=black
tilemap=07.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=08.room roomLeft=08.room
roomRight=04.room roomRight=04.room
[tilemap]
07.tmx
[/tilemap]
[enemy] [enemy]
tileset=sigmasua.png tileset=sigmasua.png
animation=sigmasua.ani animation=sigmasua.ani

View File

@@ -1,16 +1,13 @@
name=THE GARDEN name=THE GARDEN
bgColor=black bgColor=black
border=cyan border=cyan
tilemap=08.tmx
tileset=standard.png tileset=standard.png
roomUp=09.room roomUp=09.room
roomDown=0 roomDown=0
roomLeft=16.room roomLeft=16.room
roomRight=07.room roomRight=07.room
[tilemap]
08.tmx
[/tilemap]
[enemy] [enemy]
tileset=abad.png tileset=abad.png
animation=abad.ani animation=abad.ani

View File

@@ -1,16 +1,13 @@
name=no 09 name=no 09
bgColor=black bgColor=black
border=red border=red
tilemap=09.tmx
tileset=standard.png tileset=standard.png
roomUp=10.room roomUp=10.room
roomDown=08.room roomDown=08.room
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
09.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=the hall name=the hall
bgColor=black bgColor=black
border=magenta border=magenta
tilemap=10.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=09.room roomDown=09.room
roomLeft=0 roomLeft=0
roomRight=11.room roomRight=11.room
[tilemap]
10.tmx
[/tilemap]
[item] [item]
tileset=items.png tileset=items.png
tile=22 tile=22

View File

@@ -1,16 +1,13 @@
name=no 11 name=no 11
bgColor=black bgColor=black
border=red border=red
tilemap=11.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=10.room roomLeft=10.room
roomRight=12.room roomRight=12.room
[tilemap]
11.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=THE PASSAGE name=THE PASSAGE
bgColor=black bgColor=black
border=green border=green
tilemap=12.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=11.room roomLeft=11.room
roomRight=13.room roomRight=13.room
[tilemap]
12.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=matatunos name=matatunos
bgColor=black bgColor=black
border=blue border=blue
tilemap=13.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=12.room roomLeft=12.room
roomRight=14.room roomRight=14.room
[tilemap]
13.tmx
[/tilemap]
[enemy] [enemy]
tileset=matatunos.png tileset=matatunos.png
animation=matatunos.ani animation=matatunos.ani

View File

@@ -1,16 +1,13 @@
name=KILLING SPREE name=KILLING SPREE
bgColor=black bgColor=black
border=blue border=blue
tilemap=14.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=15.room roomDown=15.room
roomLeft=13.room roomLeft=13.room
roomRight=45.room roomRight=45.room
[tilemap]
14.tmx
[/tilemap]
[enemy] [enemy]
tileset=matatunos.png tileset=matatunos.png
animation=matatunos.ani animation=matatunos.ani

View File

@@ -1,16 +1,13 @@
name=no 15 name=no 15
bgColor=black bgColor=black
border=red border=red
tilemap=15.tmx
tileset=standard.png tileset=standard.png
roomUp=14.room roomUp=14.room
roomDown=06.room roomDown=06.room
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
15.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -3,16 +3,13 @@ bgColor=blue
border=blue border=blue
itemColor1=bright_cyan itemColor1=bright_cyan
itemColor2=yellow itemColor2=yellow
tilemap=16.tmx
tileset=standard.png tileset=standard.png
roomUp=44.room roomUp=44.room
roomDown=0 roomDown=0
roomLeft=17.room roomLeft=17.room
roomRight=08.room roomRight=08.room
[tilemap]
16.tmx
[/tilemap]
[enemy] [enemy]
tileset=chip.png tileset=chip.png
animation=chip.ani animation=chip.ani

View File

@@ -1,16 +1,13 @@
name=no 17 name=no 17
bgColor=black bgColor=black
border=red border=red
tilemap=17.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=18.room roomDown=18.room
roomLeft=49.room roomLeft=49.room
roomRight=16.room roomRight=16.room
[tilemap]
17.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 18 name=no 18
bgColor=black bgColor=black
border=red border=red
tilemap=18.tmx
tileset=standard.png tileset=standard.png
roomUp=17.room roomUp=17.room
roomDown=54.room roomDown=54.room
roomLeft=19.room roomLeft=19.room
roomRight=0 roomRight=0
[tilemap]
18.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 19 name=no 19
bgColor=black bgColor=black
border=red border=red
tilemap=19.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=20.room roomLeft=20.room
roomRight=18.room roomRight=18.room
[tilemap]
19.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 20 name=no 20
bgColor=black bgColor=black
border=red border=red
tilemap=20.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=21.room roomLeft=21.room
roomRight=19.room roomRight=19.room
[tilemap]
20.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 21 name=no 21
bgColor=black bgColor=black
border=red border=red
tilemap=21.tmx
tileset=standard.png tileset=standard.png
roomUp=23.room roomUp=23.room
roomDown=0 roomDown=0
roomLeft=22.room roomLeft=22.room
roomRight=20.room roomRight=20.room
[tilemap]
01.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 22 name=no 22
bgColor=black bgColor=black
border=red border=red
tilemap=22.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=21.room roomRight=21.room
[tilemap]
22.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 23 name=no 23
bgColor=black bgColor=black
border=red border=red
tilemap=23.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=21.room roomDown=21.room
roomLeft=24.room roomLeft=24.room
roomRight=0 roomRight=0
[tilemap]
23.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 24 name=no 24
bgColor=black bgColor=black
border=red border=red
tilemap=24.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=23.room roomRight=23.room
[tilemap]
24.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 25 name=no 25
bgColor=black bgColor=black
border=red border=red
tilemap=25.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=06.room roomLeft=06.room
roomRight=26.room roomRight=26.room
[tilemap]
25.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 26 name=no 26
bgColor=black bgColor=black
border=red border=red
tilemap=26.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=25.room roomLeft=25.room
roomRight=27.room roomRight=27.room
[tilemap]
26.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 27 name=no 27
bgColor=black bgColor=black
border=red border=red
tilemap=27.tmx
tileset=standard.png tileset=standard.png
roomUp=28.room roomUp=28.room
roomDown=29.room roomDown=29.room
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
27.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 28 name=no 28
bgColor=black bgColor=black
border=red border=red
tilemap=28.tmx
tileset=standard.png tileset=standard.png
roomUp=32.room roomUp=32.room
roomDown=27.room roomDown=27.room
roomLeft=0 roomLeft=0
roomRight=31.room roomRight=31.room
[tilemap]
28.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 29 name=no 29
bgColor=black bgColor=black
border=red border=red
tilemap=29.tmx
tileset=standard.png tileset=standard.png
roomUp=27.room roomUp=27.room
roomDown=0 roomDown=0
roomLeft=30.room roomLeft=30.room
roomRight=0 roomRight=0
[tilemap]
29.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 30 name=no 30
bgColor=black bgColor=black
border=red border=red
tilemap=30.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=29.room roomRight=29.room
[tilemap]
30.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 31 name=no 31
bgColor=black bgColor=black
border=red border=red
tilemap=31.tmx
tileset=standard.png tileset=standard.png
roomUp=33.room roomUp=33.room
roomDown=0 roomDown=0
roomLeft=28.room roomLeft=28.room
roomRight=0 roomRight=0
[tilemap]
31.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 32 name=no 32
bgColor=black bgColor=black
border=red border=red
tilemap=32.tmx
tileset=standard.png tileset=standard.png
roomUp=34.room roomUp=34.room
roomDown=28.room roomDown=28.room
roomLeft=0 roomLeft=0
roomRight=33.room roomRight=33.room
[tilemap]
32.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 33 name=no 33
bgColor=black bgColor=black
border=red border=red
tilemap=33.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=31.room roomDown=31.room
roomLeft=32.room roomLeft=32.room
roomRight=0 roomRight=0
[tilemap]
33.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 34 name=no 34
bgColor=black bgColor=black
border=red border=red
tilemap=34.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=32.room roomDown=32.room
roomLeft=35.room roomLeft=35.room
roomRight=0 roomRight=0
[tilemap]
34.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 35 name=no 35
bgColor=black bgColor=black
border=red border=red
tilemap=35.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=36.room roomLeft=36.room
roomRight=34.room roomRight=34.room
[tilemap]
35.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 36 name=no 36
bgColor=black bgColor=black
border=red border=red
tilemap=36.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=37.room roomLeft=37.room
roomRight=35.room roomRight=35.room
[tilemap]
36.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 37 name=no 37
bgColor=black bgColor=black
border=red border=red
tilemap=37.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=38.room roomLeft=38.room
roomRight=36.room roomRight=36.room
[tilemap]
37.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 38 name=no 38
bgColor=black bgColor=black
border=red border=red
tilemap=38.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=39.room roomLeft=39.room
roomRight=37.room roomRight=37.room
[tilemap]
38.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 39 name=no 39
bgColor=black bgColor=black
border=red border=red
tilemap=39.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=40.room roomLeft=40.room
roomRight=38.room roomRight=38.room
[tilemap]
39.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 40 name=no 40
bgColor=black bgColor=black
border=red border=red
tilemap=40.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=41.room roomLeft=41.room
roomRight=39.room roomRight=39.room
[tilemap]
40.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 41 name=no 41
bgColor=black bgColor=black
border=red border=red
tilemap=41.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=42.room roomLeft=42.room
roomRight=40.room roomRight=40.room
[tilemap]
41.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 42 name=no 42
bgColor=black bgColor=black
border=red border=red
tilemap=42.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=43.room roomDown=43.room
roomLeft=53.room roomLeft=53.room
roomRight=41.room roomRight=41.room
[tilemap]
42.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 43 name=no 43
bgColor=black bgColor=black
border=red border=red
tilemap=43.tmx
tileset=standard.png tileset=standard.png
roomUp=42.room roomUp=42.room
roomDown=44.room roomDown=44.room
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
43.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 44 name=no 44
bgColor=black bgColor=black
border=red border=red
tilemap=44.tmx
tileset=standard.png tileset=standard.png
roomUp=43.room roomUp=43.room
roomDown=16.room roomDown=16.room
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
44.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=FEEL THE HEAT name=FEEL THE HEAT
bgColor=red bgColor=red
border=black border=black
tilemap=45.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=14.room roomLeft=14.room
roomRight=46.room roomRight=46.room
[tilemap]
45.tmx
[/tilemap]
[enemy] [enemy]
tileset=chip.png tileset=chip.png
animation=chip.ani animation=chip.ani

View File

@@ -1,16 +1,13 @@
name=no 46 name=no 46
bgColor=black bgColor=black
border=red border=red
tilemap=46.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=45.room roomLeft=45.room
roomRight=0 roomRight=0
[tilemap]
46.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 47 name=no 47
bgColor=black bgColor=black
border=red border=red
tilemap=47.tmx
tileset=standard.png tileset=standard.png
roomUp=51.room roomUp=51.room
roomDown=0 roomDown=0
roomLeft=48.room roomLeft=48.room
roomRight=0 roomRight=0
[tilemap]
47.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 48 name=no 48
bgColor=black bgColor=black
border=red border=red
tilemap=48.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=49.room roomDown=49.room
roomLeft=0 roomLeft=0
roomRight=47.room roomRight=47.room
[tilemap]
48.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 49 name=no 49
bgColor=black bgColor=black
border=red border=red
tilemap=49.tmx
tileset=standard.png tileset=standard.png
roomUp=48.room roomUp=48.room
roomDown=0 roomDown=0
roomLeft=50.room roomLeft=50.room
roomRight=17.room roomRight=17.room
[tilemap]
49.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 50 name=no 50
bgColor=black bgColor=black
border=red border=red
tilemap=50.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=49.room roomRight=49.room
[tilemap]
50.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 51 name=no 51
bgColor=black bgColor=black
border=red border=red
tilemap=51.tmx
tileset=standard.png tileset=standard.png
roomUp=53.room roomUp=53.room
roomDown=47.room roomDown=47.room
roomLeft=52.room roomLeft=52.room
roomRight=0 roomRight=0
[tilemap]
51.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 52 name=no 52
bgColor=black bgColor=black
border=red border=red
tilemap=52.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=51.room roomRight=51.room
[tilemap]
52.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 53 name=no 53
bgColor=black bgColor=black
border=red border=red
tilemap=53.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=51.room roomDown=51.room
roomLeft=0 roomLeft=0
roomRight=42.room roomRight=42.room
[tilemap]
53.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 54 name=no 54
bgColor=black bgColor=black
border=red border=red
tilemap=54.tmx
tileset=standard.png tileset=standard.png
roomUp=18.room roomUp=18.room
roomDown=0 roomDown=0
roomLeft=0 roomLeft=0
roomRight=55.room roomRight=55.room
[tilemap]
54.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 55 name=no 55
bgColor=black bgColor=black
border=red border=red
tilemap=55.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=54.room roomLeft=54.room
roomRight=56.room roomRight=56.room
[tilemap]
55.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 56 name=no 56
bgColor=black bgColor=black
border=red border=red
tilemap=56.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=55.room roomLeft=55.room
roomRight=57.room roomRight=57.room
[tilemap]
56.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=no 57 name=no 57
bgColor=black bgColor=black
border=red border=red
tilemap=57.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=56.room roomLeft=56.room
roomRight=58.room roomRight=58.room
[tilemap]
57.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png
animation=diskette.ani animation=diskette.ani

View File

@@ -1,16 +1,13 @@
name=chirping name=chirping
bgColor=black bgColor=black
border=magenta border=magenta
tilemap=58.tmx
tileset=standard.png tileset=standard.png
roomUp=0 roomUp=0
roomDown=0 roomDown=0
roomLeft=57.room roomLeft=57.room
roomRight=59.room roomRight=59.room
[tilemap]
58.tmx
[/tilemap]
[enemy] [enemy]
tileset=bird.png tileset=bird.png
animation=bird.ani animation=bird.ani

View File

@@ -1,16 +1,13 @@
name=static name=static
bgColor=black bgColor=black
border=bright_magenta border=bright_magenta
tilemap=59.tmx
tileset=standard.png tileset=standard.png
roomUp=60.room roomUp=60.room
roomDown=0 roomDown=0
roomLeft=58.room roomLeft=58.room
roomRight=0 roomRight=0
[tilemap]
59.tmx
[/tilemap]
[enemy] [enemy]
tileset=wave.png tileset=wave.png
animation=wave.ani animation=wave.ani

View File

@@ -1,6 +1,7 @@
name=magnetic fields name=magnetic fields
bgColor=black bgColor=black
border=red border=red
tilemap=60.tmx
tileset=standard.png tileset=standard.png
roomUp=05.room roomUp=05.room
roomDown=59.room roomDown=59.room
@@ -9,10 +10,6 @@ roomRight=0
itemColor1=red itemColor1=red
itemColor2=green itemColor2=green
[tilemap]
60.tmx
[/tilemap]
[enemy] [enemy]
tileset=wave_v.png tileset=wave_v.png
animation=wave_v.ani animation=wave_v.ani

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=06.room roomLeft=06.room
roomRight=02.room roomRight=02.room
[tilemap]
01.tmx 01.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png

View File

@@ -7,9 +7,9 @@ roomDown=04.room
roomLeft=01.room roomLeft=01.room
roomRight=03.room roomRight=03.room
[tilemap]
02.tmx 02.tmx
[/tilemap]
[enemy] [enemy]
tileset=paco.png tileset=paco.png

View File

@@ -7,9 +7,9 @@ roomDown=05.room
roomLeft=02.room roomLeft=02.room
roomRight=11.room roomRight=11.room
[tilemap]
03.tmx 03.tmx
[/tilemap]
[enemy] [enemy]
tileset=chip.png tileset=chip.png

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=07.room roomLeft=07.room
roomRight=05.room roomRight=05.room
[tilemap]
04.tmx 04.tmx
[/tilemap]
[enemy] [enemy]
tileset=chip.png tileset=chip.png

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=04.room roomLeft=04.room
roomRight=12.room roomRight=12.room
[tilemap]
05.tmx 05.tmx
[/tilemap]
[enemy] [enemy]
tileset=sigmasua.png tileset=sigmasua.png

View File

@@ -7,6 +7,5 @@ roomDown=0
roomLeft=13.room roomLeft=13.room
roomRight=01.room roomRight=01.room
[tilemap]
06.tmx 06.tmx
[/tilemap]

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=08.room roomLeft=08.room
roomRight=04.room roomRight=04.room
[tilemap]
07.tmx 07.tmx
[/tilemap]
[enemy] [enemy]
tileset=bird.png tileset=bird.png

View File

@@ -7,6 +7,5 @@ roomDown=09.room
roomLeft=10.room roomLeft=10.room
roomRight=07.room roomRight=07.room
[tilemap]
08.tmx 08.tmx
[/tilemap]

View File

@@ -7,6 +7,5 @@ roomDown=0
roomLeft=0 roomLeft=0
roomRight=0 roomRight=0
[tilemap]
09.tmx 09.tmx
[/tilemap]

View File

@@ -7,6 +7,5 @@ roomDown=0
roomLeft=0 roomLeft=0
roomRight=08.room roomRight=08.room
[tilemap]
10.tmx 10.tmx
[/tilemap]

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=03.room roomLeft=03.room
roomRight=0 roomRight=0
[tilemap]
11.tmx 11.tmx
[/tilemap]
[enemy] [enemy]
tileset=qvoid.png tileset=qvoid.png

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=05.room roomLeft=05.room
roomRight=0 roomRight=0
[tilemap]
01.tmx 01.tmx
[/tilemap]
[enemy] [enemy]
tileset=diskette.png tileset=diskette.png

View File

@@ -7,9 +7,9 @@ roomDown=0
roomLeft=0 roomLeft=0
roomRight=06.room roomRight=06.room
[tilemap]
13.tmx 13.tmx
[/tilemap]
[enemy] [enemy]
tileset=batman.png tileset=batman.png

View File

@@ -32,7 +32,7 @@ int AnimatedSprite::getIndex(std::string name)
for (auto a : animation) for (auto a : animation)
{ {
index++; ++index;
if (a.name == name) if (a.name == name)
{ {
return index; return index;
@@ -57,7 +57,7 @@ void AnimatedSprite::animate()
// 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[currentAnimation].currentFrame >= animation[currentAnimation].frames.size()) if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
{ {
if (animation[currentAnimation].loop == -1) if (animation[currentAnimation].loop == -1)
{ // Si no hay loop, deja el último frame { // Si no hay loop, deja el último frame
@@ -77,7 +77,7 @@ void AnimatedSprite::animate()
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]); setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
// Incrementa el contador de la animacion // Incrementa el contador de la animacion
animation[currentAnimation].counter++; ++animation[currentAnimation].counter;
} }
} }
@@ -85,7 +85,7 @@ void AnimatedSprite::animate()
void AnimatedSprite::setCurrentFrame(int num) void AnimatedSprite::setCurrentFrame(int num)
{ {
// Descarta valores fuera de rango // Descarta valores fuera de rango
if (num >= animation[currentAnimation].frames.size()) if (num >= (int)animation[currentAnimation].frames.size())
{ {
num = 0; num = 0;
} }
@@ -136,9 +136,9 @@ SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
// Carga la animación desde un fichero // Carga la animación desde un fichero
bool AnimatedSprite::load(std::string filePath) bool AnimatedSprite::load(std::string filePath)
{ {
int frames_per_row = 0; int framesPerRow = 0;
int frame_width = 0; int frameWidth = 0;
int frame_height = 0; int frameHeight = 0;
// Indicador de éxito en la carga // Indicador de éxito en la carga
bool success = true; bool success = true;
@@ -170,7 +170,7 @@ bool AnimatedSprite::load(std::string filePath)
int pos = line.find("="); int pos = line.find("=");
// Procesa las dos subcadenas // Procesa las dos subcadenas
if (pos != line.npos) if (pos != (int)line.npos)
{ {
if (line.substr(0, pos) == "name") if (line.substr(0, pos) == "name")
{ {
@@ -189,12 +189,12 @@ bool AnimatedSprite::load(std::string filePath)
// Se introducen los valores separados por comas en un vector // Se introducen los valores separados por comas en un vector
std::stringstream ss(line.substr(pos + 1, line.length())); std::stringstream ss(line.substr(pos + 1, line.length()));
std::string tmp; std::string tmp;
SDL_Rect rect = {0, 0, frame_width, frame_height}; SDL_Rect rect = {0, 0, frameWidth, frameHeight};
while (getline(ss, tmp, ',')) while (getline(ss, tmp, ','))
{ {
int num_tile = std::stoi(tmp); int numTile = std::stoi(tmp);
rect.x = (num_tile % frames_per_row) * frame_width; rect.x = (numTile % framesPerRow) * frameWidth;
rect.y = (num_tile / frames_per_row) * frame_height; rect.y = (numTile / framesPerRow) * frameHeight;
buffer.frames.push_back(rect); buffer.frames.push_back(rect);
} }
} }
@@ -217,27 +217,27 @@ bool AnimatedSprite::load(std::string filePath)
int pos = line.find("="); int pos = line.find("=");
// Procesa las dos subcadenas // Procesa las dos subcadenas
if (pos != line.npos) if (pos != (int)line.npos)
{ {
if (line.substr(0, pos) == "frames_per_row") if (line.substr(0, pos) == "framesPerRow")
{ {
frames_per_row = std::stoi(line.substr(pos + 1, line.length())); framesPerRow = std::stoi(line.substr(pos + 1, line.length()));
} }
else if (line.substr(0, pos) == "frame_width") else if (line.substr(0, pos) == "frameWidth")
{ {
frame_width = std::stoi(line.substr(pos + 1, line.length())); frameWidth = std::stoi(line.substr(pos + 1, line.length()));
// Normaliza valores // Normaliza valores
if (frames_per_row == 0) if (framesPerRow == 0)
{ {
frames_per_row = texture->getWidth() / frame_width; framesPerRow = texture->getWidth() / frameWidth;
} }
} }
else if (line.substr(0, pos) == "frame_height") else if (line.substr(0, pos) == "frameHeight")
{ {
frame_height = std::stoi(line.substr(pos + 1, line.length())); frameHeight = std::stoi(line.substr(pos + 1, line.length()));
} }
else else
@@ -261,7 +261,7 @@ bool AnimatedSprite::load(std::string filePath)
} }
// Pone un valor por defecto // Pone un valor por defecto
setPos({0, 0, frame_width, frame_height}); setPos({0, 0, frameWidth, frameHeight});
return success; return success;
} }

View File

@@ -3,8 +3,8 @@
// Constructor // Constructor
Asset::Asset(std::string path) Asset::Asset(std::string path)
{ {
mExecutablePath = path; executablePath = path;
longest_name = 0; longestName = 0;
} }
// Destructor // Destructor
@@ -16,21 +16,25 @@ Asset::~Asset()
void Asset::add(std::string file, enum assetType type, bool required) void Asset::add(std::string file, enum assetType type, bool required)
{ {
item_t temp; item_t temp;
temp.file = mExecutablePath + "/.." + file; temp.file = executablePath + "/.." + file;
temp.type = type; temp.type = type;
temp.required = required; temp.required = required;
mFileList.push_back(temp); fileList.push_back(temp);
const std::string filename = file.substr(file.find_last_of("\\/") + 1); const std::string filename = file.substr(file.find_last_of("\\/") + 1);
longest_name = SDL_max(longest_name, filename.size()); longestName = SDL_max(longestName, filename.size());
} }
// Devuelve el fichero de un elemento de la lista a partir de una cadena // Devuelve el fichero de un elemento de la lista a partir de una cadena
std::string Asset::get(std::string text) std::string Asset::get(std::string text)
{ {
for (int i = 0; i < mFileList.size(); i++) for (auto f : fileList)
if (mFileList[i].file.find(text) != std::string::npos) {
return mFileList[i].file; if (f.file.find(text) != std::string::npos)
{
return f.file;
}
}
printf("Warning: file %s not found\n", text.c_str()); printf("Warning: file %s not found\n", text.c_str());
return ""; return "";
@@ -44,31 +48,43 @@ bool Asset::check()
printf("\n** Checking files.\n"); printf("\n** Checking files.\n");
// Comprueba la lista de ficheros clasificandolos por tipo // Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < maxAssetType; type++) for (int type = 0; type < maxAssetType; ++type)
{ {
// Comprueba si hay ficheros de ese tipo // Comprueba si hay ficheros de ese tipo
bool any = false; bool any = false;
for (int i = 0; i < mFileList.size(); i++) for (auto f : fileList)
if ((mFileList[i].required) && (mFileList[i].type == type)) {
if ((f.required) && (f.type == type))
{
any = true; any = true;
}
}
// Si hay ficheros de ese tipo, comprueba si existen // Si hay ficheros de ese tipo, comprueba si existen
if (any) if (any)
{ {
printf("\n>> %s FILES\n", getTypeName(type).c_str()); printf("\n>> %s FILES\n", getTypeName(type).c_str());
for (int i = 0; i < mFileList.size(); i++) for (auto f : fileList)
if ((mFileList[i].required) && (mFileList[i].type == type)) {
success &= checkFile(mFileList[i].file); if ((f.required) && (f.type == type))
{
success &= checkFile(f.file);
}
}
} }
} }
// Resultado // Resultado
if (success) if (success)
{
printf("\n** All files OK.\n\n"); printf("\n** All files OK.\n\n");
}
else else
{
printf("\n** A file is missing. Exiting.\n\n"); printf("\n** A file is missing. Exiting.\n\n");
}
return success; return success;
} }
@@ -83,14 +99,14 @@ bool Asset::checkFile(std::string path)
const std::string filename = path.substr(path.find_last_of("\\/") + 1); const std::string filename = path.substr(path.find_last_of("\\/") + 1);
SDL_RWops *file = SDL_RWFromFile(path.c_str(), "r+b"); SDL_RWops *file = SDL_RWFromFile(path.c_str(), "r+b");
if (file != NULL) if (file != nullptr)
{ {
result = "OK"; result = "OK";
success = true; success = true;
SDL_RWclose(file); SDL_RWclose(file);
} }
const std::string s = "Checking file %-" + std::to_string(longest_name) + "s [" + result + "]\n"; const std::string s = "Checking file %-" + std::to_string(longestName) + "s [" + result + "]\n";
printf(s.c_str(), filename.c_str()); printf(s.c_str(), filename.c_str());
return success; return success;
@@ -104,30 +120,39 @@ std::string Asset::getTypeName(int type)
case bitmap: case bitmap:
return "BITMAP"; return "BITMAP";
break; break;
case music: case music:
return "MUSIC"; return "MUSIC";
break; break;
case sound: case sound:
return "SOUND"; return "SOUND";
break; break;
case font: case font:
return "FONT"; return "FONT";
break; break;
case lang: case lang:
return "LANG"; return "LANG";
break; break;
case data: case data:
return "DATA"; return "DATA";
break; break;
case room: case room:
return "ROOM"; return "ROOM";
break; break;
case enemy: case enemy:
return "ENEMY"; return "ENEMY";
break; break;
case item: case item:
return "ITEM"; return "ITEM";
break; break;
default: default:
return "ERROR"; return "ERROR";
break; break;

View File

@@ -33,10 +33,10 @@ private:
bool required; // Indica si es un fichero que debe de existir bool required; // Indica si es un fichero que debe de existir
}; };
int longest_name; // Contiene la longitud del nombre de fichero mas largo int longestName; // Contiene la longitud del nombre de fichero mas largo
std::vector<item_t> mFileList; std::vector<item_t> fileList;
std::string mExecutablePath; std::string executablePath;
// Comprueba que existe un fichero // Comprueba que existe un fichero
bool checkFile(std::string path); bool checkFile(std::string path);

View File

@@ -49,9 +49,12 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
texts.push_back(""); texts.push_back("");
// Crea la textura para el texto que se escribe en pantalla // Crea la textura para el texto que se escribe en pantalla
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (textTexture == NULL) if (textTexture == nullptr)
printf("Error: textTexture could not be created!\nSDL Error: %s\n", SDL_GetError()); {
printf("Error: textTexture could not be created!\nSDL Error: %s\n", SDL_GetError());
}
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
// Escribe el texto en la textura // Escribe el texto en la textura
fillTexture(); fillTexture();
@@ -101,18 +104,21 @@ void Credits::checkEventHandler()
// Escribe el texto en la textura // Escribe el texto en la textura
void Credits::fillTexture() void Credits::fillTexture()
{ {
SDL_SetRenderTarget(renderer, textTexture); SDL_SetRenderTarget(renderer, textTexture);
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); SDL_RenderClear(renderer);
SDL_RenderClear(renderer);
// Escribe el texto en la textura // Escribe el texto en la textura
for (int i = 0; i < texts.size(); ++i) const int size = text->getCharacterSize();
int i = 0;
for (auto t:texts)
{ {
text->write(0, i * 8, texts[i]); text->write(0, i * size, t);
++i;
} }
SDL_SetRenderTarget(renderer, nullptr); SDL_SetRenderTarget(renderer, nullptr);
} }
// Actualiza las variables // Actualiza las variables
@@ -128,7 +134,7 @@ void Credits::update()
checkEventHandler(); checkEventHandler();
// Incrementa el contador // Incrementa el contador
counter++; ++counter;
// Comprueba si ha terminado la sección // Comprueba si ha terminado la sección
if (counter > 1000) if (counter > 1000)
@@ -147,11 +153,10 @@ void Credits::render()
// Limpia la pantalla // Limpia la pantalla
screen->clean(); screen->clean();
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
// Dibuja la textura con el mapa en pantalla
SDL_RenderCopy(renderer, textTexture, &rect, NULL);
// Dibuja la textura con el mapa en pantalla
SDL_RenderCopy(renderer, textTexture, &rect, nullptr);
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
screen->blit(); screen->blit();

View File

@@ -31,8 +31,8 @@ private:
Text *text; // Objeto para escribir texto en pantalla Text *text; // Objeto para escribir texto en pantalla
int counter; // Contador int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale section_t section; // Estado del bucle principal para saber si continua o se sale
int ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
int 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<std::string> texts; // Vector con las letras de la marquesina std::vector<std::string> texts; // Vector con las letras de la marquesina
SDL_Texture *textTexture; // Textura para dibujar el texto SDL_Texture *textTexture; // Textura para dibujar el texto

View File

@@ -313,7 +313,7 @@ bool Director::initSDL()
// Crea la ventana // Crea la ventana
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth, options->screenHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth, options->screenHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if (window == NULL) if (window == nullptr)
{ {
printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError()); printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError());
success = false; success = false;
@@ -326,7 +326,7 @@ bool Director::initSDL()
else else
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (renderer == NULL) if (renderer == nullptr)
{ {
printf("Renderer could not be created!\nSDL Error: %s\n", SDL_GetError()); printf("Renderer could not be created!\nSDL Error: %s\n", SDL_GetError());
success = false; success = false;

View File

@@ -303,8 +303,6 @@ void Game::renderRoomName()
// Cambia de habitación // Cambia de habitación
bool Game::changeRoom(std::string file) bool Game::changeRoom(std::string file)
{ {
bool success = false;
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada // En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
if (file != "0") if (file != "0")
// Verifica que exista el fichero que se va a cargar // Verifica que exista el fichero que se va a cargar
@@ -322,16 +320,16 @@ bool Game::changeRoom(std::string file)
board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negrom cambialo a blanco board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negrom cambialo a blanco
if (roomTracker->addRoom(file)) if (roomTracker->addRoom(file))
{ // Incrementa el contador de habitaciones visitadas { // Incrementa el contador de habitaciones visitadas
board.rooms++; ++board.rooms;
} }
// Pasa la nueva habitación al jugador // Pasa la nueva habitación al jugador
player->setRoom(room); player->setRoom(room);
success = true; return true;
} }
return success; return false;
} }
// Comprueba si el jugador esta en el borde de la pantalla // Comprueba si el jugador esta en el borde de la pantalla
@@ -339,11 +337,11 @@ void Game::checkPlayerOnBorder()
{ {
if (player->getOnBorder()) if (player->getOnBorder())
{ {
const std::string room_name = room->getRoom(player->getBorder()); const std::string roomName = room->getRoom(player->getBorder());
if (changeRoom(room_name)) if (changeRoom(roomName))
{ {
player->switchBorders(); player->switchBorders();
currentRoom = room_name; currentRoom = roomName;
spawnPoint = player->getSpawnParams(); spawnPoint = player->getSpawnParams();
} }
} }
@@ -434,7 +432,7 @@ void Game::updateBlackScreen()
{ {
//if (screen->spectrumFadeEnded()) //if (screen->spectrumFadeEnded())
{ {
blackScreenCounter++; ++blackScreenCounter;
if (blackScreenCounter > 10) if (blackScreenCounter > 10)
{ {
blackScreen = false; blackScreen = false;

View File

@@ -38,8 +38,8 @@ private:
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
JA_Music music; // Musica que suena durante el juego JA_Music music; // Musica que suena durante el juego
Debug *debug; // Objeto para gestionar la información de debug Debug *debug; // Objeto para gestionar la información de debug
int ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
int 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 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
player_t spawnPoint; // Lugar de la habitación donde aparece el jugador player_t spawnPoint; // Lugar de la habitación donde aparece el jugador

View File

@@ -1,23 +1,20 @@
#include "input.h" #include "input.h"
#include <iostream> #include <iostream>
// Contestar cuantos joystics ha detectado
// Preguntarlepor los joystics que ha encontrado para ir poniendolos en la variable de opciones
// Constructor // Constructor
Input::Input(std::string file) Input::Input(std::string file)
{ {
// Fichero gamecontrollerdb.txt // Fichero gamecontrollerdb.txt
mDBpath = file; dbPath = file;
// Inicializa las variables // Inicializa las variables
for (int i = 0; i < 17; i++) for (int i = 0; i < 17; ++i)
{ {
mKeyBindings[i].scancode = 0; keyBindings[i].scancode = 0;
mKeyBindings[i].active = false; keyBindings[i].active = false;
mGameControllerBindings[i].button = SDL_CONTROLLER_BUTTON_INVALID; gameControllerBindings[i].button = SDL_CONTROLLER_BUTTON_INVALID;
mGameControllerBindings[i].active = false; gameControllerBindings[i].active = false;
} }
discoverGameController(); discoverGameController();
@@ -26,20 +23,20 @@ Input::Input(std::string file)
// Destructor // Destructor
Input::~Input() Input::~Input()
{ {
for (int i = 0; i < mNumGamepads; i++) for (int i = 0; i < numGamepads; ++i)
mConnectedControllers[i] = nullptr; connectedControllers[i] = nullptr;
} }
// Asigna uno de los posibles inputs a una tecla del teclado // Asigna uno de los posibles inputs a una tecla del teclado
void Input::bindKey(Uint8 input, SDL_Scancode code) void Input::bindKey(Uint8 input, SDL_Scancode code)
{ {
mKeyBindings[input].scancode = code; keyBindings[input].scancode = code;
} }
// Asigna uno de los posibles inputs a un botón del mando // Asigna uno de los posibles inputs a un botón del mando
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button) void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
{ {
mGameControllerBindings[input].button = button; gameControllerBindings[input].button = button;
} }
// Comprueba si un input esta activo // Comprueba si un input esta activo
@@ -53,22 +50,22 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY)) if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
{ {
const Uint8 *mKeystates = SDL_GetKeyboardState(NULL); const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
if (repeat) if (repeat)
{ {
if (mKeystates[mKeyBindings[input].scancode] != 0) if (mKeystates[keyBindings[input].scancode] != 0)
successKeyboard = true; successKeyboard = true;
else else
successKeyboard = false; successKeyboard = false;
} }
else else
{ {
if (!mKeyBindings[input].active) if (!keyBindings[input].active)
{ {
if (mKeystates[mKeyBindings[input].scancode] != 0) if (mKeystates[keyBindings[input].scancode] != 0)
{ {
mKeyBindings[input].active = true; keyBindings[input].active = true;
successKeyboard = true; successKeyboard = true;
} }
else else
@@ -78,9 +75,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (mKeystates[mKeyBindings[input].scancode] == 0) if (mKeystates[keyBindings[input].scancode] == 0)
{ {
mKeyBindings[input].active = false; keyBindings[input].active = false;
successKeyboard = false; successKeyboard = false;
} }
else else
@@ -96,18 +93,18 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
{ {
if (repeat) if (repeat)
{ {
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
successGameController = true; successGameController = true;
else else
successGameController = false; successGameController = false;
} }
else else
{ {
if (!mGameControllerBindings[input].active) if (!gameControllerBindings[input].active)
{ {
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
{ {
mGameControllerBindings[input].active = true; gameControllerBindings[input].active = true;
successGameController = true; successGameController = true;
} }
else else
@@ -117,9 +114,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) == 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0)
{ {
mGameControllerBindings[input].active = false; gameControllerBindings[input].active = false;
successGameController = false; successGameController = false;
} }
else else
@@ -133,6 +130,43 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
return (successKeyboard || successGameController); return (successKeyboard || successGameController);
} }
// Comprueba si hay almenos un input activo
bool Input::checkAnyInput(int device, int index)
{
bool successKeyboard = false;
bool successGameController = false;
if (device == INPUT_USE_ANY)
index = 0;
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
{
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
for (int i = 0; i < 17; ++i)
{
if (mKeystates[keyBindings[i].scancode] != 0)
{
successKeyboard |= true;
}
}
}
if (gameControllerFound())
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
{
for (int i = 0; i < 17; ++i)
{
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
{
successGameController |= true;
}
}
}
return (successKeyboard || successGameController);
}
// Comprueba si hay un mando conectado // Comprueba si hay un mando conectado
bool Input::discoverGameController() bool Input::discoverGameController()
{ {
@@ -141,43 +175,43 @@ bool Input::discoverGameController()
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1) if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
if (SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()) < 0) if (SDL_GameControllerAddMappingsFromFile(dbPath.c_str()) < 0)
printf("Error, could not load %s file: %s\n", mDBpath.c_str(), SDL_GetError()); printf("Error, could not load %s file: %s\n", dbPath.c_str(), SDL_GetError());
int nJoysticks = SDL_NumJoysticks(); int nJoysticks = SDL_NumJoysticks();
mNumGamepads = 0; numGamepads = 0;
// Cuenta el numero de mandos // Cuenta el numero de mandos
for (int i = 0; i < nJoysticks; i++) for (int i = 0; i < nJoysticks; ++i)
if (SDL_IsGameController(i)) if (SDL_IsGameController(i))
mNumGamepads++; numGamepads++;
printf("\nChecking for game controllers...\n"); printf("** Checking for game controllers ...\n");
printf("%i joysticks found, %i are gamepads\n", nJoysticks, mNumGamepads); printf("%i joysticks found, %i are gamepads\n\n", nJoysticks, numGamepads);
if (mNumGamepads > 0) if (numGamepads > 0)
{ {
found = true; found = true;
for (int i = 0; i < mNumGamepads; i++) for (int i = 0; i < numGamepads; ++i)
{ {
// Abre el mando y lo añade a la lista // Abre el mando y lo añade a la lista
SDL_GameController *pad = SDL_GameControllerOpen(i); SDL_GameController *pad = SDL_GameControllerOpen(i);
if (SDL_GameControllerGetAttached(pad) == 1) if (SDL_GameControllerGetAttached(pad) == 1)
{ {
mConnectedControllers.push_back(pad); connectedControllers.push_back(pad);
std::string separator(" #"); std::string separator(" #");
std::string name = SDL_GameControllerNameForIndex(i); std::string name = SDL_GameControllerNameForIndex(i);
name.resize(25); name.resize(25);
name = name + separator + std::to_string(i); name = name + separator + std::to_string(i);
std::cout << name << std::endl; std::cout << name << std::endl;
mControllerNames.push_back(name); controllerNames.push_back(name);
} }
else else
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl; std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
} }
// mGameController = mConnectedControllers[0]; // mGameController = connectedControllers[0];
SDL_GameControllerEventState(SDL_ENABLE); SDL_GameControllerEventState(SDL_ENABLE);
} }
@@ -187,7 +221,7 @@ bool Input::discoverGameController()
// Comprueba si hay algun mando conectado // Comprueba si hay algun mando conectado
bool Input::gameControllerFound() bool Input::gameControllerFound()
{ {
if (mNumGamepads > 0) if (numGamepads > 0)
return true; return true;
else else
return false; return false;
@@ -196,8 +230,8 @@ bool Input::gameControllerFound()
// Obten el nombre de un mando de juego // Obten el nombre de un mando de juego
std::string Input::getControllerName(int index) std::string Input::getControllerName(int index)
{ {
if (mNumGamepads > 0) if (numGamepads > 0)
return mControllerNames[index]; return controllerNames[index];
else else
return ""; return "";
} }
@@ -205,5 +239,5 @@ std::string Input::getControllerName(int index)
// Obten el numero de mandos conectados // Obten el numero de mandos conectados
int Input::getNumControllers() int Input::getNumControllers()
{ {
return mNumGamepads; return numGamepads;
} }

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -40,20 +41,19 @@ private:
Uint8 scancode; // Scancode asociado Uint8 scancode; // Scancode asociado
bool active; // Indica si está activo bool active; // Indica si está activo
}; };
keyBindings_t mKeyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos keyBindings_t keyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
struct GameControllerBindings_t struct GameControllerBindings_t
{ {
SDL_GameControllerButton button; // GameControllerButton asociado SDL_GameControllerButton button; // GameControllerButton asociado
bool active; // Indica si está activo bool active; // Indica si está activo
}; };
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos GameControllerBindings_t gameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
// SDL_GameController *mGameController; // Manejador para el mando std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
std::vector<SDL_GameController *> mConnectedControllers; std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
std::vector<std::string> mControllerNames; int numGamepads; // Numero de mandos conectados
int mNumGamepads; std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
// Comprueba si hay un mando conectado // Comprueba si hay un mando conectado
bool discoverGameController(); bool discoverGameController();
@@ -74,6 +74,9 @@ public:
// 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, int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay almenos un input activo
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay algun mando conectado // Comprueba si hay algun mando conectado
bool gameControllerFound(); bool gameControllerFound();

View File

@@ -101,11 +101,11 @@ void Intro::updateCounter()
{ {
JA_PlayMusic(loadingSound2); JA_PlayMusic(loadingSound2);
} }
counter++; ++counter;
} }
else else
{ {
preCounter++; ++preCounter;
} }
} }
@@ -124,7 +124,7 @@ void Intro::renderLoad()
SDL_Rect rect = {0, 0 + loadCounter, 256, 8 - loadCounter}; SDL_Rect rect = {0, 0 + loadCounter, 256, 8 - loadCounter};
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; ++i)
{ {
rect.y += 8; rect.y += 8;
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
@@ -139,7 +139,7 @@ void Intro::renderLoad()
SDL_Rect rect = {0, 64 + (loadCounter - 8), 256, 8 - (loadCounter - 8)}; SDL_Rect rect = {0, 64 + (loadCounter - 8), 256, 8 - (loadCounter - 8)};
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; ++i)
{ {
rect.y += 8; rect.y += 8;
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
@@ -154,7 +154,7 @@ void Intro::renderLoad()
SDL_Rect rect = {0, 128 + (loadCounter - 16), 256, 8 - (loadCounter - 16)}; SDL_Rect rect = {0, 128 + (loadCounter - 16), 256, 8 - (loadCounter - 16)};
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; ++i)
{ {
rect.y += 8; rect.y += 8;
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
@@ -166,7 +166,7 @@ void Intro::renderLoad()
{ {
sprite->render(); sprite->render();
SDL_Rect rect = {0, 0, 8, 8}; SDL_Rect rect = {0, 0, 8, 8};
for (int i = 0; i < loadCounter; i++) for (int i = 0; i < loadCounter; ++i)
{ {
rect.x = (i * 8) % 256; rect.x = (i * 8) % 256;
rect.y = (i / 32) * 8; rect.y = (i / 32) * 8;

View File

@@ -30,8 +30,8 @@ private:
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 section_t section; // Estado del bucle principal para saber si continua o se sale
int ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
int 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 load1, load2; bool load1, load2;
JA_Music loadingSound1, loadingSound2, loadingSound3; JA_Music loadingSound1, loadingSound2, loadingSound3;

View File

@@ -58,7 +58,7 @@ void Item::render()
// Actualiza las variables del objeto // Actualiza las variables del objeto
void Item::update() void Item::update()
{ {
counter++; ++counter;
} }
// Obtiene el rectangulo de colision del objeto // Obtiene el rectangulo de colision del objeto

View File

@@ -57,31 +57,33 @@ void ItemTracker::addItem(std::string name, SDL_Point pos)
// Busca una entrada en la lista por nombre // Busca una entrada en la lista por nombre
int ItemTracker::findByName(std::string name) int ItemTracker::findByName(std::string name)
{ {
const int c = -1; int i = 0;
for (int i = 0; i < list.size(); i++) for (auto l : list)
{ {
if (list[i].name == name) if (l.name == name)
{ {
return i; return i;
} }
++i;
} }
return c; return -1;
} }
// Busca una entrada en la lista por posición // Busca una entrada en la lista por posición
int ItemTracker::findByPos(int index, SDL_Point pos) int ItemTracker::findByPos(int index, SDL_Point pos)
{ {
const int c = -1; int i = 0;
for (int i = 0; i < list[index].pos.size(); i++) for (auto l:list[index].pos)
{ {
if ((list[index].pos[i].x == pos.x) && (list[index].pos[i].y == pos.y)) if ((l.x == pos.x) && (l.y == pos.y))
{ {
return i; return i;
} }
++i;
} }
return c; return -1;
} }

View File

@@ -16,7 +16,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
sprite2->setSpriteClip(0, 0, texture2->getWidth(), texture2->getHeight()); sprite2->setSpriteClip(0, 0, texture2->getWidth(), texture2->getHeight());
texture2->setColor(0, 0, 0); texture2->setColor(0, 0, 0);
for (int i = 0; i < texture->getHeight(); i++) for (int i = 0; i < texture->getHeight(); ++i)
{ {
sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer)); sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer));
if (i % 2 == 0) if (i % 2 == 0)
@@ -110,7 +110,7 @@ void Logo::updateJAILGAMES()
{ {
if (counter > 30) if (counter > 30)
{ {
for (int i = 1; i < sprite.size(); i++) for (int i = 1; i < (int)sprite.size(); ++i)
{ {
const int speed = 8; const int speed = 8;
const int dest = 37; const int dest = 37;
@@ -227,7 +227,7 @@ void Logo::update()
checkEventHandler(); checkEventHandler();
// Incrementa el contador // Incrementa el contador
counter++; ++counter;
// Gestiona el logo de JAILGAME // Gestiona el logo de JAILGAME
updateJAILGAMES(); updateJAILGAMES();

View File

@@ -27,8 +27,8 @@ private:
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 section_t section; // Estado del bucle principal para saber si continua o se sale
int ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
int 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
int endLogo; // Tiempo del contador para terminar el logo int endLogo; // Tiempo del contador para terminar el logo
int postLogo; // Tiempo que dura el logo con el fade al maximo int postLogo; // Tiempo que dura el logo con el fade al maximo

View File

@@ -11,7 +11,7 @@ LTexture::LTexture(SDL_Renderer *renderer, std::string path)
this->path = path; this->path = path;
// Inicializa // Inicializa
texture = NULL; texture = nullptr;
width = 0; width = 0;
height = 0; height = 0;
@@ -35,7 +35,7 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
int req_format = STBI_rgb_alpha; int req_format = STBI_rgb_alpha;
int width, height, orig_format; int width, height, orig_format;
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format); unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
if (data == NULL) if (data == nullptr)
{ {
SDL_Log("Loading image failed: %s", stbi_failure_reason()); SDL_Log("Loading image failed: %s", stbi_failure_reason());
exit(1); exit(1);
@@ -60,11 +60,11 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
unload(); unload();
// La textura final // La textura final
SDL_Texture *newTexture = NULL; SDL_Texture *newTexture = nullptr;
// Carga la imagen desde una ruta específica // Carga la imagen desde una ruta específica
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format); SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
if (loadedSurface == NULL) if (loadedSurface == nullptr)
{ {
printf("Unable to load image %s!\n", path.c_str()); printf("Unable to load image %s!\n", path.c_str());
} }
@@ -72,7 +72,7 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
{ {
// Crea la textura desde los pixels de la surface // Crea la textura desde los pixels de la surface
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface); newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
if (newTexture == NULL) if (newTexture == nullptr)
{ {
printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError()); printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
} }
@@ -89,7 +89,7 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
// Return success // Return success
texture = newTexture; texture = newTexture;
return texture != NULL; return texture != nullptr;
} }
// Crea una textura en blanco // Crea una textura en blanco
@@ -97,7 +97,7 @@ bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Te
{ {
// Crea una textura sin inicializar // Crea una textura sin inicializar
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
if (texture == NULL) if (texture == nullptr)
{ {
printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError()); printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError());
} }
@@ -107,17 +107,17 @@ bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Te
this->height = height; this->height = height;
} }
return texture != NULL; return texture != nullptr;
} }
// Libera la memoria de la textura // Libera la memoria de la textura
void LTexture::unload() void LTexture::unload()
{ {
// Libera la textura si existe // Libera la textura si existe
if (texture != NULL) if (texture != nullptr)
{ {
SDL_DestroyTexture(texture); SDL_DestroyTexture(texture);
texture = NULL; texture = nullptr;
width = 0; width = 0;
height = 0; height = 0;
} }
@@ -148,7 +148,7 @@ void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, floa
SDL_Rect renderQuad = {x, y, width, height}; SDL_Rect renderQuad = {x, y, width, height};
// Obtiene las dimesiones del clip de renderizado // Obtiene las dimesiones del clip de renderizado
if (clip != NULL) if (clip != nullptr)
{ {
renderQuad.w = clip->w; renderQuad.w = clip->w;
renderQuad.h = clip->h; renderQuad.h = clip->h;

View File

@@ -43,7 +43,7 @@ public:
void setAlpha(Uint8 alpha); void setAlpha(Uint8 alpha);
// Renderiza la textura en un punto específico // Renderiza la textura en un punto específico
void render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip = NULL, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE); void render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip = nullptr, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE);
// Establece la textura como objetivo de renderizado // Establece la textura como objetivo de renderizado
void setAsRenderTarget(SDL_Renderer *renderer); void setAsRenderTarget(SDL_Renderer *renderer);

View File

@@ -232,7 +232,7 @@ void Player::checkState()
{ {
vx = 0.0f; vx = 0.0f;
vy = maxVY; vy = maxVY;
fallCounter++; ++fallCounter;
playFallSound(); playFallSound();
} }
@@ -249,7 +249,7 @@ void Player::checkState()
else if (state == s_jumping) else if (state == s_jumping)
{ {
jumpCounter++; ++jumpCounter;
playJumpSound(); playJumpSound();
} }
} }

View File

@@ -4,13 +4,12 @@
#include <sstream> #include <sstream>
// Constructor // Constructor
Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *itemTracker, int *items, Debug *debug) Room::Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *itemTracker, int *items, Debug *debug)
{ {
// Inicializa variables // Inicializa variables
tileSize = 8; tileSize = 8;
mapWidth = 32; mapWidth = 32;
mapHeight = 16; mapHeight = 16;
tilesetWidth = 20;
paused = false; paused = false;
itemColor1 = stringToColor("magenta"); itemColor1 = stringToColor("magenta");
itemColor2 = stringToColor("yellow"); itemColor2 = stringToColor("yellow");
@@ -24,13 +23,14 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset
this->debug = debug; this->debug = debug;
// Crea los objetos // Crea los objetos
load(file_path); loadMapFile(file);
texture = new LTexture(renderer, asset->get(tileset)); texture = new LTexture(renderer, asset->get(tileset));
itemSound = JA_LoadSound(asset->get("item.wav").c_str()); tilesetWidth = texture->getWidth() / tileSize;
// debug->clearLog(); itemSound = JA_LoadSound(asset->get("item.wav").c_str());
// debug->addToLog(tileset); loadMapTileFile(asset->get(tileMapFile));
// Calcula las superficies
// Calcula las superficies
setBottomSurfaces(); setBottomSurfaces();
setTopSurfaces(); setTopSurfaces();
setLeftSurfaces(); setLeftSurfaces();
@@ -40,8 +40,11 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset
// 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, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (mapTexture == NULL) if (mapTexture == nullptr)
{
printf("Error: mapTexture could not be created!\nSDL Error: %s\n", SDL_GetError()); printf("Error: mapTexture could not be created!\nSDL Error: %s\n", SDL_GetError());
}
SDL_SetTextureBlendMode(mapTexture, SDL_BLENDMODE_BLEND);
// Pinta el mapa de la habitación en la textura // Pinta el mapa de la habitación en la textura
fillMapTexture(); fillMapTexture();
@@ -69,13 +72,10 @@ Room::~Room()
} }
} }
// Carga las variables desde un fichero // Carga las variables desde un fichero de mapa
bool Room::load(std::string file_path) bool Room::loadMapFile(std::string file_path)
{ {
// Indicador de éxito en la carga const std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
bool success = true;
std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
std::string line; std::string line;
std::ifstream file(file_path); std::ifstream file(file_path);
@@ -83,7 +83,7 @@ bool Room::load(std::string file_path)
if (file.good()) if (file.good())
{ {
// Procesa el fichero linea a linea // Procesa el fichero linea a linea
printf("Reading file %s\n", filename.c_str()); printf("Reading file %s\n\n", filename.c_str());
while (std::getline(file, line)) while (std::getline(file, line))
{ {
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo // Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
@@ -104,7 +104,6 @@ bool Room::load(std::string file_path)
if (!setEnemy(&enemy, line.substr(0, pos), line.substr(pos + 1, line.length()))) if (!setEnemy(&enemy, line.substr(0, pos), line.substr(pos + 1, line.length())))
{ {
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str()); printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
success = false;
} }
} while (line != "[/enemy]"); } while (line != "[/enemy]");
@@ -113,7 +112,7 @@ bool Room::load(std::string file_path)
} }
// Si la linea contiene el texto [tilemap] se realiza el proceso de carga del fichero tmx // Si la linea contiene el texto [tilemap] se realiza el proceso de carga del fichero tmx
else if (line == "[tilemap]") /*else if (line == "[tilemap]")
{ {
do do
{ {
@@ -159,7 +158,7 @@ bool Room::load(std::string file_path)
} }
} }
} while (line != "[/tilemap]"); } while (line != "[/tilemap]");
} }*/
// Si la linea contiene el texto [item] se realiza el proceso de carga de un item // Si la linea contiene el texto [item] se realiza el proceso de carga de un item
else if (line == "[item]") else if (line == "[item]")
@@ -177,12 +176,13 @@ bool Room::load(std::string file_path)
// Encuentra la posición del caracter '=' // Encuentra la posición del caracter '='
int pos = line.find("="); int pos = line.find("=");
// Procesa las dos subcadenas // Procesa las dos subcadenas
if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length()))) if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length())))
{ {
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str()); printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
success = false;
} }
} while (line != "[/item]"); } while (line != "[/item]");
// Añade el item al vector de items // Añade el item al vector de items
@@ -202,7 +202,6 @@ bool Room::load(std::string file_path)
if (!setVars(line.substr(0, pos), line.substr(pos + 1, line.length()))) if (!setVars(line.substr(0, pos), line.substr(pos + 1, line.length())))
{ {
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str()); printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
success = false;
} }
} }
} }
@@ -215,10 +214,58 @@ bool Room::load(std::string file_path)
else else
{ {
printf("Warning: Unable to open %s file\n", filename.c_str()); printf("Warning: Unable to open %s file\n", filename.c_str());
success = false; return false;
} }
return success; return true;
}
// Carga las variables y texturas desde un fichero de mapa de tiles
bool Room::loadMapTileFile(std::string file_path)
{
const std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
std::string line;
std::ifstream file(file_path);
// El fichero se puede abrir
if (file.good())
{
// Procesa el fichero linea a linea
printf("Reading file %s\n\n", filename.c_str());
while (std::getline(file, line))
{ // Lee el fichero linea a linea
if (line.find("data encoding") != std::string::npos)
{
// Lee la primera linea
std::getline(file, line);
while (line != "</data>")
{ // Procesa lineas mientras haya
std::stringstream ss(line);
std::string tmp;
while (getline(ss, tmp, ','))
{
tilemap.push_back(std::stoi(tmp) - 1);
}
// Lee la siguiente linea
std::getline(file, line);
}
}
}
// Cierra el fichero
printf("Closing file %s\n\n", filename.c_str());
file.close();
}
else
{ // El fichero no se puede abrir
printf("Warning: Unable to open %s file\n", filename.c_str());
return false;
}
return true;
} }
// Asigna variables a partir de dos cadenas // Asigna variables a partir de dos cadenas
@@ -227,7 +274,12 @@ bool Room::setVars(std::string var, std::string value)
// Indicador de éxito en la asignación // Indicador de éxito en la asignación
bool success = true; bool success = true;
if (var == "name") if (var == "tilemap")
{
tileMapFile = value;
}
else if (var == "name")
{ {
name = value; name = value;
} }
@@ -453,34 +505,36 @@ color_t Room::getBorderColor()
void Room::fillMapTexture() void Room::fillMapTexture()
{ {
SDL_SetRenderTarget(renderer, mapTexture); SDL_SetRenderTarget(renderer, mapTexture);
SDL_SetTextureBlendMode(mapTexture, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
// Los tilesets son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo // Los tilesets son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
SDL_Rect clip = {0, 0, 8, 8}; SDL_Rect clip = {0, 0, tileSize, tileSize};
for (int y = 0; y < 16; y++) for (int y = 0; y < mapHeight; ++y)
for (int x = 0; x < 32; x++) for (int x = 0; x < mapWidth; ++x)
{ {
// Tiled pone los tiles vacios del mapa como cero y empieza a contar de 1 a n. // Tiled pone los tiles vacios del mapa como cero y empieza a contar de 1 a n.
// 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
const int index = (y * 32) + x; const int index = (y * mapWidth) + x;
if (index > -1) if (index > -1)
{ {
clip.x = (tilemap[index] % 20) * 8; clip.x = (tilemap[index] % tilesetWidth) * tileSize;
clip.y = (tilemap[index] / 20) * 8; clip.y = (tilemap[index] / tilesetWidth) * tileSize;
texture->render(renderer, x * 8, y * 8, &clip); texture->render(renderer, x * tileSize, y * tileSize, &clip);
// ****
if (debug->getEnabled()) if (debug->getEnabled())
{ {
if (clip.x != -8) if (clip.x != -tileSize)
{ {
clip.x = x * 8; clip.x = x * tileSize;
clip.y = y * 8; clip.y = y * tileSize;
SDL_SetRenderDrawColor(renderer, 64, 64, 64, 224); SDL_SetRenderDrawColor(renderer, 64, 64, 64, 224);
SDL_RenderFillRect(renderer, &clip); SDL_RenderFillRect(renderer, &clip);
} }
} }
// ****
} }
} }
@@ -560,7 +614,7 @@ void Room::renderMap()
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
// Dibuja la textura con el mapa en pantalla // Dibuja la textura con el mapa en pantalla
SDL_RenderCopy(renderer, mapTexture, &rect, NULL); SDL_RenderCopy(renderer, mapTexture, &rect, nullptr);
} }
// Dibuja los enemigos en pantalla // Dibuja los enemigos en pantalla
@@ -691,8 +745,7 @@ bool Room::enemyCollision(SDL_Rect &rect)
// Indica si hay colision con un objeto a partir de un rectangulo // Indica si hay colision con un objeto a partir de un rectangulo
bool Room::itemCollision(SDL_Rect &rect) bool Room::itemCollision(SDL_Rect &rect)
{ {
bool collision = false; for (int i = 0; i < (int)items.size(); ++i)
for (int i = 0; i < items.size(); i++)
{ {
if (checkCollision(rect, items[i]->getCollider())) if (checkCollision(rect, items[i]->getCollider()))
{ {
@@ -701,11 +754,11 @@ bool Room::itemCollision(SDL_Rect &rect)
items.erase(items.begin() + i); items.erase(items.begin() + i);
JA_PlaySound(itemSound); JA_PlaySound(itemSound);
*itemsPicked = *itemsPicked + 1; *itemsPicked = *itemsPicked + 1;
collision = true; return true;
} }
} }
return collision; return false;
} }
// Recarga la textura // Recarga la textura
@@ -763,7 +816,7 @@ void Room::setBottomSurfaces()
// Busca todos los tiles de tipo muro que no tengan debajo otro muro // Busca todos los tiles de tipo muro que no tengan debajo otro muro
// Hay que recorrer la habitación por filas (excepto los de la última fila) // Hay que recorrer la habitación por filas (excepto los de la última fila)
for (int i = 0; i < tilemap.size() - mapWidth; i++) for (int i = 0; i < (int)tilemap.size() - mapWidth; ++i)
{ {
if (getTile(i) == t_wall && getTile(i + mapWidth) != t_wall) if (getTile(i) == t_wall && getTile(i + mapWidth) != t_wall)
{ {
@@ -780,28 +833,26 @@ void Room::setBottomSurfaces()
// Recorre el vector de tiles buscando tiles consecutivos para localizar las superficies // Recorre el vector de tiles buscando tiles consecutivos para localizar las superficies
int i = 0; int i = 0;
int lastOne = 0; int lastOne = 0;
while (i < tile.size()) while (i < (int)tile.size())
{ {
h_line_t line; h_line_t line;
line.x1 = (tile[i] % mapWidth) * tileSize; line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1; line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
lastOne = i; lastOne = i;
i++; ++i;
while (tile[i] == tile[i - 1] + 1) while (tile[i] == tile[i - 1] + 1)
{ {
lastOne = i; lastOne = i;
i++; ++i;
} }
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1; line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
bottomSurfaces.push_back(line); bottomSurfaces.push_back(line);
if (tile[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;
} }
// debug->addToLog("B: " + std::to_string(line.x1) + "," + std::to_string(line.y) + "," + std::to_string(line.x2) + "," + std::to_string(line.y));
} }
} }
@@ -810,11 +861,9 @@ void Room::setTopSurfaces()
{ {
std::vector<int> tile; std::vector<int> tile;
// debug->addToLog(std::to_string(tilemap.size()));
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro // Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
// Hay que recorrer la habitación por filas (excepto los de la primera fila) // Hay que recorrer la habitación por filas (excepto los de la primera fila)
for (int i = mapWidth; i < tilemap.size(); i++) for (int i = mapWidth; i < (int)tilemap.size(); ++i)
{ {
if ((getTile(i) == t_wall || getTile(i) == t_passable) && getTile(i - mapWidth) != t_wall) if ((getTile(i) == t_wall || getTile(i) == t_passable) && getTile(i - mapWidth) != t_wall)
{ {
@@ -831,28 +880,26 @@ void Room::setTopSurfaces()
// Recorre el vector de tiles buscando tiles consecutivos para localizar las superficies // Recorre el vector de tiles buscando tiles consecutivos para localizar las superficies
int i = 0; int i = 0;
int lastOne = 0; int lastOne = 0;
while (i < tile.size()) while (i < (int)tile.size())
{ {
h_line_t line; h_line_t line;
line.x1 = (tile[i] % mapWidth) * tileSize; line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = (tile[i] / mapWidth) * tileSize; line.y = (tile[i] / mapWidth) * tileSize;
lastOne = i; lastOne = i;
i++; ++i;
while (tile[i] == tile[i - 1] + 1) while (tile[i] == tile[i - 1] + 1)
{ {
lastOne = i; lastOne = i;
i++; ++i;
} }
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1; line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
topSurfaces.push_back(line); topSurfaces.push_back(line);
if (tile[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;
} }
// debug->addToLog("T: " + std::to_string(line.x1) + "," + std::to_string(line.y) + "," + std::to_string(line.x2) + "," + std::to_string(line.y));
} }
} }
@@ -879,18 +926,18 @@ void Room::setLeftSurfaces()
// (Los tiles de la misma columna, la diferencia entre ellos es de mapWidth) // (Los tiles de la misma columna, la diferencia entre ellos es de mapWidth)
// para localizar las superficies // para localizar las superficies
int i = 0; int i = 0;
while (i < tile.size()) while (i < (int)tile.size())
{ {
v_line_t line; v_line_t line;
line.x = (tile[i] % mapWidth) * tileSize; line.x = (tile[i] % mapWidth) * tileSize;
line.y1 = ((tile[i] / mapWidth) * tileSize); line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1]) while (tile[i] + mapWidth == tile[i + 1])
{ {
i++; ++i;
} }
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1; line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
leftSurfaces.push_back(line); leftSurfaces.push_back(line);
i++; ++i;
} }
} }
@@ -917,18 +964,18 @@ void Room::setRightSurfaces()
// (Los tiles de la misma columna, la diferencia entre ellos es de mapWidth) // (Los tiles de la misma columna, la diferencia entre ellos es de mapWidth)
// para localizar las superficies // para localizar las superficies
int i = 0; int i = 0;
while (i < tile.size()) while (i < (int)tile.size())
{ {
v_line_t line; v_line_t line;
line.x = ((tile[i] % mapWidth) * tileSize) + tileSize - 1; line.x = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
line.y1 = ((tile[i] / mapWidth) * tileSize); line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1]) while (tile[i] + mapWidth == tile[i + 1])
{ {
i++; ++i;
} }
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1; line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
rightSurfaces.push_back(line); rightSurfaces.push_back(line);
i++; ++i;
} }
} }
@@ -937,7 +984,7 @@ void Room::setLeftSlopes()
{ {
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l // Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
std::vector<int> found; std::vector<int> found;
for (int i = 0; i < tilemap.size(); ++i) for (int i = 0; i < (int)tilemap.size(); ++i)
{ {
if (getTile(i) == t_slope_l) if (getTile(i) == t_slope_l)
{ {
@@ -957,7 +1004,7 @@ void Room::setLeftSlopes()
int lookingFor = found[0] + mapWidth + 1; int lookingFor = found[0] + mapWidth + 1;
int lastOneFound = found[0]; int lastOneFound = found[0];
found.erase(found.begin()); found.erase(found.begin());
for (int i = 0; i < found.size(); i++) for (int i = 0; i < (int)found.size(); ++i)
{ {
if (found[i] == lookingFor) if (found[i] == lookingFor)
{ {
@@ -970,7 +1017,6 @@ void Room::setLeftSlopes()
line.x2 = ((lastOneFound % mapWidth) * tileSize) + tileSize - 1; line.x2 = ((lastOneFound % mapWidth) * tileSize) + tileSize - 1;
line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1; line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1;
leftSlopes.push_back(line); leftSlopes.push_back(line);
// debug->addToLog("LS: " + std::to_string(line.x1) + "," + std::to_string(line.y1) + "," + std::to_string(line.x2) + "," + std::to_string(line.y2));
} }
} }
@@ -979,7 +1025,7 @@ void Room::setRightSlopes()
{ {
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r // Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
std::vector<int> found; std::vector<int> found;
for (int i = 0; i < tilemap.size(); ++i) for (int i = 0; i < (int)tilemap.size(); ++i)
{ {
if (getTile(i) == t_slope_r) if (getTile(i) == t_slope_r)
{ {
@@ -999,7 +1045,7 @@ void Room::setRightSlopes()
int lookingFor = found[0] + mapWidth - 1; int lookingFor = found[0] + mapWidth - 1;
int lastOneFound = found[0]; int lastOneFound = found[0];
found.erase(found.begin()); found.erase(found.begin());
for (int i = 0; i < found.size(); i++) for (int i = 0; i < (int)found.size(); ++i)
{ {
if (found[i] == lookingFor) if (found[i] == lookingFor)
{ {
@@ -1012,7 +1058,6 @@ void Room::setRightSlopes()
line.x2 = (lastOneFound % mapWidth) * tileSize; line.x2 = (lastOneFound % mapWidth) * tileSize;
line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1; line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1;
rightSlopes.push_back(line); rightSlopes.push_back(line);
// debug->addToLog("RS: " + std::to_string(line.x1) + "," + std::to_string(line.y1) + "," + std::to_string(line.x2) + "," + std::to_string(line.y2));
} }
} }

View File

@@ -45,14 +45,15 @@ class Room
private: private:
std::string name; // Nombre de la habitación std::string name; // Nombre de la habitación
color_t bgColor; // Color de fondo de la habitación color_t bgColor; // Color de fondo de la habitación
color_t borderColor; // Color de fondo de la habitación color_t borderColor; // Color del borde de la pantalla
color_t itemColor1; color_t itemColor1; // Color 1 para los items de la habitación
color_t itemColor2; color_t itemColor2; // Color 2 para los items de la habitación
std::string roomUp; // Identificador de la habitación que se encuentra arriba std::string roomUp; // Identificador de la habitación que se encuentra arriba
std::string roomDown; // Identificador de la habitación que se encuentra abajp std::string roomDown; // Identificador de la habitación que se encuentra abajp
std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda
std::string roomRight; // Identificador de la habitación que se encuentra a la derecha std::string roomRight; // Identificador de la habitación que se encuentra a la derecha
std::string tileset; // Imagen con los graficos para la habitación std::string tileset; // Imagen con los graficos para la habitación
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
std::vector<Enemy *> enemies; // Listado con los enemigos de la habitación std::vector<Enemy *> enemies; // Listado con los enemigos de la habitación
std::vector<Item *> items; // Listado con los items que hay en la habitación std::vector<Item *> items; // Listado con los items que hay en la habitación
@@ -78,8 +79,11 @@ private:
int mapHeight; // Alto del mapa en tiles int mapHeight; // Alto del mapa en tiles
int tilesetWidth; // Ancho del tileset en tiles int tilesetWidth; // Ancho del tileset en tiles
// Carga las variables desde un fichero // Carga las variables desde un fichero de mapa
bool load(std::string file_path); bool loadMapFile(std::string file);
// Carga las variables y texturas desde un fichero de mapa de tiles
bool loadMapTileFile(std::string file);
// Asigna variables a partir de dos cadenas // Asigna variables a partir de dos cadenas
bool setVars(std::string var, std::string value); bool setVars(std::string var, std::string value);
@@ -116,7 +120,7 @@ private:
public: public:
// Constructor // Constructor
Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *item_tracker, int *items, Debug *debug); Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *item_tracker, int *items, Debug *debug);
// Destructor // Destructor
~Room(); ~Room();

View File

@@ -96,7 +96,7 @@ void ScoreBoard::render()
const int frame = desp % 4; const int frame = desp % 4;
sprite->setCurrentFrame(frame); sprite->setCurrentFrame(frame);
for (int i = 0; i < board->lives; i++) for (int i = 0; i < board->lives; ++i)
{ {
sprite->setPosX(8 + (16 * i) + desp); sprite->setPosX(8 + (16 * i) + desp);
index = i % color.size(); index = i % color.size();
@@ -129,7 +129,7 @@ void ScoreBoard::render()
// Actualiza las variables del objeto // Actualiza las variables del objeto
void ScoreBoard::update() void ScoreBoard::update()
{ {
counter++; ++counter;
sprite->update(); sprite->update();
if (!paused) if (!paused)

View File

@@ -21,7 +21,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
// Crea la textura donde se dibujan los graficos del juego // Crea la textura donde se dibujan los graficos del juego
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight); gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
if (gameCanvas == NULL) if (gameCanvas == nullptr)
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
// Establece el modo de video // Establece el modo de video
@@ -59,14 +59,14 @@ void Screen::start()
void Screen::blit() void Screen::blit()
{ {
// Vuelve a dejar el renderizador en modo normal // Vuelve a dejar el renderizador en modo normal
SDL_SetRenderTarget(renderer, NULL); SDL_SetRenderTarget(renderer, nullptr);
// Borra el contenido previo // Borra el contenido previo
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF); SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
// Copia la textura de juego en el renderizador en la posición adecuada // Copia la textura de juego en el renderizador en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, NULL, &dest); SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
// Muestra por pantalla el renderizador // Muestra por pantalla el renderizador
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@@ -115,7 +115,7 @@ void Screen::setVideoMode(int fullScreenMode)
int scale = 0; int scale = 0;
while (((gameCanvasWidth * (scale + 1)) <= screenWidth) && ((gameCanvasHeight * (scale + 1)) <= screenHeight)) while (((gameCanvasWidth * (scale + 1)) <= screenWidth) && ((gameCanvasHeight * (scale + 1)) <= screenHeight))
{ {
scale++; ++scale;
} }
dest.w = gameCanvasWidth * scale; dest.w = gameCanvasWidth * scale;
@@ -259,7 +259,7 @@ void Screen::updateFade()
return; return;
} }
fadeCounter++; ++fadeCounter;
if (fadeCounter > fadeLenght) if (fadeCounter > fadeLenght)
{ {
iniFade(); iniFade();
@@ -325,7 +325,7 @@ void Screen::updateSpectrumFade()
return; return;
} }
spectrumFadeCounter++; ++spectrumFadeCounter;
if (spectrumFadeCounter > spectrumFadeLenght) if (spectrumFadeCounter > spectrumFadeLenght)
{ {
iniSpectrumFade(); iniSpectrumFade();

View File

@@ -33,7 +33,7 @@ Test::~Test()
// Actualiza las variables // Actualiza las variables
void Test::update() void Test::update()
{ {
for (int i = 0; i < points.size(); ++i) for (int i = 0; i < (int)points.size(); ++i)
{ {
points[i].x += points[i].vx; points[i].x += points[i].vx;
points[i].y += points[i].vy; points[i].y += points[i].vy;

View File

@@ -22,7 +22,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
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 P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. 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 P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. 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?";
for (int i = 0; i < longText.length(); i++) for (int i = 0; i < (int)longText.length(); i++)
{ {
letter_t l; letter_t l;
l.letter = longText.substr(i, 1); l.letter = longText.substr(i, 1);
@@ -108,7 +108,7 @@ void Title::checkEventHandler()
// Actualiza la marquesina // Actualiza la marquesina
void Title::updateMarquee() void Title::updateMarquee()
{ {
for (int i = 0; i < letters.size(); i++) for (int i = 0; i < (int)letters.size(); i++)
{ {
if (letters[i].enabled) if (letters[i].enabled)
{ {

View File

@@ -35,8 +35,8 @@ private:
int counter; // Contador int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale 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
int ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
int 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<letter_t> letters; // Vector con las letras de la marquesina std::vector<letter_t> letters; // Vector con las letras de la marquesina
// Actualiza las variables // Actualiza las variables