40 Commits

Author SHA1 Message Date
908ffa6d55 - Canvis que vaig fer fa 2 messos, però no sé en què estava pensant, he de arreglar-ho. 2023-02-13 11:50:37 +01:00
d230259e42 - Añadido getEntry(r,g,b) a systempalette 2023-02-13 11:41:56 +01:00
a61c2e8d46 - [WIP] Modificaciones a la clase Textura 2022-12-02 12:30:25 +01:00
9bb9d26417 - Clase para pintado al pixel sobre una textura 2022-12-02 12:29:59 +01:00
a96ce4afc9 - Creada la paleta de sistema 2022-12-02 12:29:37 +01:00
29a2ebf221 - Added opendingux build stage to Makefile 2022-12-01 20:05:15 +01:00
bcccfb026f - Files needed to create opk package 2022-12-01 20:05:00 +01:00
aad60d9849 - Added Some build notes to the repo 2022-12-01 20:04:36 +01:00
4de0743a77 -Some options for Opendingux 2022-12-01 20:02:26 +01:00
80e91e7acd - Executable Path in OpenDingux is exe name alone. Set "." instead 2022-12-01 20:02:12 +01:00
4cbe55c2d4 Actualizado jail_audio a la última versión 2022-12-01 19:51:53 +01:00
564f316586 Cambiado el nombre del enemigo diskette a floppy 2022-12-01 19:32:59 +01:00
522ab8e726 Cambios cosméticos en algunas habitaciones. Cambiado el nombre de STATIC a BE CAREFUL WITH THE FUSE 2022-12-01 19:31:35 +01:00
4911282777 El color de fondo de la habitación se pinta en la textura del mapa 2022-12-01 11:40:35 +01:00
06ecabc676 Corregido un "memory leak" en texture.cpp 2022-12-01 10:43:58 +01:00
5d89a3057e Optimizado un poco el title.cpp 2022-11-30 13:43:47 +01:00
75228cc451 Eliminado el resto de accesos a vector mediante at() 2022-11-30 12:09:45 +01:00
357eec20b1 Eliminados la mayor parte de accesos a vector mediante at() 2022-11-30 12:03:37 +01:00
62c1e2715e Preparando el juego para ser compatble con consolas 2022-11-30 11:06:27 +01:00
34fc2b6b06 Optimizada la intro 2022-11-30 10:10:10 +01:00
6557dea2bb Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-11-30 08:27:11 +01:00
2caea7ba6e Optimizando la intro 2022-11-30 08:26:16 +01:00
d33d2e4a09 Cambiado el nombre de algunos enemigos 2022-11-29 21:26:28 +01:00
d9174dcdb9 Cambiado el nombre de algunos enemigos 2022-11-29 21:08:33 +01:00
22f7204e08 Añadidas mas dll para el release de windows 2022-11-29 19:41:14 +01:00
06fab0d457 Actualizado Makefile 2022-11-29 19:16:14 +01:00
f180f88068 Corregido error en el texto de las teclas nuevas para moverse 2022-11-29 19:12:04 +01:00
4109d6c938 Actualizado Readme.md. Cambiado LICENSE a LICENSE.txt 2022-11-29 19:11:02 +01:00
9c2264ca75 Actualizado Makefile 2022-11-29 19:07:59 +01:00
c59739c7ba Cambiado el tamaño del borde de porcentaje a valor absoluto en pixeles 2022-11-29 18:45:25 +01:00
4a430c0d5b Actualizadas las instrucciones con el método de control escogido 2022-11-29 18:22:40 +01:00
5a7f637f4b Cambiada la tecla de pausa a la tecla H (HOLD) 2022-11-29 18:07:31 +01:00
c63298b555 Posibilidad de escoger diferentes configuraciónes prefijadas de teclas de control desde el fichero de configuración 2022-11-29 18:05:38 +01:00
82aa91bead Corregida la funcion para verificar si existen los ficheros de recursos 2022-11-29 17:29:18 +01:00
f4129e109a Actualizado Makefile 2022-11-29 17:25:08 +01:00
5e8714697d Añadido un tile para poder bajar en la fase ULA HOP! 2022-11-29 17:23:12 +01:00
dd4355051f Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-11-28 09:01:22 +01:00
160b212a43 Actualizado info.plist 2022-11-28 09:01:21 +01:00
69d3b076d7 Modificadas algunas fases para prevenir glitches 2022-11-28 07:53:07 +01:00
3817a01712 Guardado de las opciones de las notificaciones 2022-11-24 12:55:34 +01:00
99 changed files with 1212 additions and 749 deletions

View File

@@ -2,13 +2,14 @@ executable = jaildoctors_dilemma
source = source/*.cpp source/common/*.cpp
appName = JailDoctor's Dilemma
releaseFolder = jdd_release
version = v1.06.1
version = v1.06.2
# Release names
windowsRelease = $(executable)-$(version)-win32-x64.zip
macosIntelRelease = $(executable)-$(version)-macos-intel.dmg
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
linuxRelease = $(executable)-$(version)-linux.tar.gz
opendinguxRelease = $(executable).opk
windows:
@echo off
@@ -33,9 +34,9 @@ windows_release:
powershell if (Test-Path "$(releaseFolder)\data\room\standard.tsx") {Remove-Item "$(releaseFolder)\data\room\standard.tsx" -Recurse -Force}
# Copy root files
powershell Copy-Item "LICENSE" -Destination "$(releaseFolder)"
powershell Copy-Item "LICENSE.txt" -Destination "$(releaseFolder)"
powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
powershell Copy-Item "release\SDL2.dll" -Destination "$(releaseFolder)"
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
# Build
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
@@ -80,9 +81,12 @@ macos_release:
# Copy files
cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources"
cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents"
cp LICENSE "$(releaseFolder)"
cp LICENSE.txt "$(releaseFolder)"
cp README.md "$(releaseFolder)"
# Create links
ln -s /Applications "$(releaseFolder)"/Applications
# Build INTEL
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
@@ -120,7 +124,7 @@ linux_release:
# Copy data
cp -R data "$(releaseFolder)"
cp LICENSE "$(releaseFolder)"
cp LICENSE.txt "$(releaseFolder)"
cp README.md "$(releaseFolder)"
# Delete data
@@ -137,3 +141,32 @@ linux_release:
# Remove data
rm -rdf "$(releaseFolder)"
opendingux:
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ -std=c++11 $(source) -o "$(executable)"
opendingux_release:
# Remove data
rm -rdf "$(releaseFolder)"
# Create folders
mkdir -p "$(releaseFolder)"
# Copy data
cp -R data "$(releaseFolder)"
cp -R default.gcw0.desktop "$(releaseFolder)"
cp -R icon.png "$(releaseFolder)"
# Delete data
rm -f "$(releaseFolder)/data/room/map.world"
rm -f "$(releaseFolder)/data/room/standard.tsx"
# Build
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ -std=c++11 $(source) -o "$(releaseFolder)/$(executable)"
# Pack files
rm -f "$(opendinguxRelease)"
cd "$(releaseFolder)" && /opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./data ./$(executable) "../$(opendinguxRelease)" -all-root -noappend -no-exports -no-xattrs
# Remove data
rm -rdf "$(releaseFolder)"

View File

@@ -1,4 +1,4 @@
# JailDoctor's Dilemma (v1.06.1)
# JailDoctor's Dilemma (v1.06.2)
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
@@ -40,7 +40,7 @@ El juego permite tanto el uso del teclado como de un mando de control. Las tecla
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar. En el fichero de configuración se pueden cambiar las teclas por otras opciones prefijadas: O, P para moverse y Q para saltar o A, D para moverse y W para saltar.
- **Tecla M**: Activa o desactiva la música

3
build.txt Normal file
View File

@@ -0,0 +1,3 @@
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lstdc++ -std=c++11 source/*.cpp source/common/*.cpp -o jdd
sftp root@10.1.1.2:jdd <<< $'put jdd'
ssh root@10.1.1.2

View File

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 310 B

View File

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 271 B

View File

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 122 B

View File

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 205 B

View File

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View File

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 378 B

View File

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

View File

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

View File

@@ -9,8 +9,8 @@ roomLeft=0
roomRight=02.room
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=1
@@ -25,8 +25,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer3.png
animation=jailer3.ani
tileSetFile=jailer_#3.png
animation=jailer_#3.ani
width=16
height=16
x=4
@@ -41,8 +41,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=7
@@ -57,8 +57,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer2.png
animation=jailer2.ani
tileSetFile=jailer_#2.png
animation=jailer_#2.ani
width=16
height=16
x=10
@@ -73,8 +73,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=13
@@ -89,8 +89,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=printer.png
animation=printer.ani
tileSetFile=elsa.png
animation=elsa.ani
width=16
height=16
x=3
@@ -105,8 +105,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=printer.png
animation=printer.ani
tileSetFile=elsa.png
animation=elsa.ani
width=16
height=16
x=6

View File

@@ -1,6 +1,6 @@
name=ROAD TO THE JAIL
bgColor=black
border=cyan
border=blue
tileMapFile=02.tmx
tileSetFile=standard.png
roomUp=0

View File

@@ -3,22 +3,22 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,43,43,43,43,43,
43,166,166,167,168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,166,185,167,166,166,166,185,25,25,25,25,
43,43,211,212,212,211,181,211,213,211,181,211,212,213,211,181,211,211,211,211,212,213,211,181,211,213,181,211,135,0,0,0,
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
34,34,304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
34,34,0,413,413,413,413,0,0,0,0,413,413,413,413,413,0,0,0,0,413,413,413,413,413,413,413,0,0,0,25,25,
34,34,0,413,413,413,413,0,0,0,0,413,304,413,413,413,0,0,0,0,413,304,413,413,413,413,304,0,0,0,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
34,34,389,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
34,34,413,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,513,189,190,537,0,0,0,0,
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,190,25,25
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,524,189,191,548,0,0,0,0,
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,191,25,25
</data>
</layer>
</map>

View File

@@ -11,8 +11,8 @@ itemColor1=bright_green
itemColor2=green
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=15

View File

@@ -10,7 +10,7 @@
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,387,25,
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,25,
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -18,7 +18,7 @@
0,0,0,0,0,0,0,0,531,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,531,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,0,349,349,349,349,349,349,349,349,349,349,349,538,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,349,349,349,349,349,349,349,349,349,349,0,0,349,349,349
563,563,563,563,563,563,563,563,563,563,0,0,0,41,41,41,41,349,349,349,349,349,349,349,349,349,349,0,0,349,349,349
</data>
</layer>
</map>

View File

@@ -11,8 +11,8 @@ itemColor1=red
itemColor2=magenta
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=9
@@ -27,8 +27,8 @@ color=green
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=1

View File

@@ -9,13 +9,13 @@
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25,0,0,0,527,25,25,25,25,25,25,25,25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,551,0,0,0,0,0,0,0,0,0,527,25,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,0,0,0,0,0,25,25,25,25,25,
25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,251,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,395,395,395,395,395,371,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,0,0,0,0,0,0,0,
25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,251,0,0,0,0,0,25,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
0,0,0,0,395,395,395,395,395,371,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,0,0,0,0,0,0,25,
0,0,0,0,0,0,0,0,0,323,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25,25,551,0,0,0,0,0,0,347,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25

View File

@@ -30,7 +30,7 @@ flip=true
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=14
y=2
@@ -46,7 +46,7 @@ color=bright_blue
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=10
y=10
@@ -62,7 +62,7 @@ color=cyan
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=15
y=1

View File

@@ -11,8 +11,8 @@ itemColor1=yellow
itemColor2=red
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=5
@@ -27,8 +27,8 @@ color=green
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=12

View File

@@ -3,16 +3,16 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
5,5,5,5,5,5,5,5,5,5,5,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
5,5,5,5,5,5,5,5,0,0,0,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,0,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,173,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
557,557,557,557,557,557,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
5,5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
5,5,5,5,5,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,

View File

@@ -4,15 +4,15 @@
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,188,
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,

View File

@@ -9,8 +9,8 @@ roomLeft=26.room
roomRight=0
#[enemy]
#tileSetFile=diskette.png
#animation=diskette.ani
#tileSetFile=floppy.png
#animation=floppy.ani
#width=16
#height=16
#x=2

View File

@@ -3,17 +3,17 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,41,235,235,0,0,235,235,41,89,90,89,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,0,
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,94,41,235,235,0,0,235,235,41,89,90,89,
89,94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,215,0,0,0,0,0,0,0,0,214,89,90,
214,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,214,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -11,8 +11,8 @@ itemColor1=green
itemColor2=red
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=20

View File

@@ -15,7 +15,7 @@
116,0,0,0,377,377,377,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,377,377,377,377,0,0,0,0,140,116,
140,0,0,0,0,0,0,0,0,0,0,377,0,114,115,114,115,0,0,377,0,0,0,0,0,0,0,0,0,0,116,140,
116,0,0,0,0,0,0,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,0,0,0,0,431,432,114,115,140,116,
140,0,0,0,0,0,0,0,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140,
140,0,0,0,0,0,0,377,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140,
0,0,0,0,0,0,0,0,0,0,0,0,377,115,114,115,114,0,0,377,0,0,0,0,0,0,0,0,0,0,140,116,
0,0,0,0,0,0,0,0,0,0,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140,
114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,0,0,114,115,114,115,114,115

View File

@@ -1,4 +1,4 @@
name=STATIC
name=BE CAREFUL WITH THE FUSE
bgColor=black
border=bright_cyan
tileMapFile=36.tmx

View File

@@ -9,8 +9,8 @@ roomLeft=39.room
roomRight=37.room
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=9
@@ -25,8 +25,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=18
@@ -41,8 +41,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=12
@@ -75,8 +75,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=3

View File

@@ -27,8 +27,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=9
@@ -44,8 +44,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=15
@@ -61,8 +61,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=22
@@ -78,8 +78,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=16

View File

@@ -25,8 +25,8 @@ color=red
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=10
@@ -42,8 +42,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=15
@@ -59,8 +59,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=20
@@ -76,8 +76,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14

View File

@@ -25,8 +25,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=8
@@ -41,8 +41,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=11
@@ -57,8 +57,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=24
@@ -73,8 +73,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=12
@@ -90,8 +90,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14
@@ -107,8 +107,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14

View File

@@ -11,8 +11,8 @@ itemColor1=red
itemColor2=yellow
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=13
height=15
x=10
@@ -28,8 +28,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=13
height=15
x=25
@@ -45,8 +45,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=7
@@ -62,8 +62,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=18

View File

@@ -11,8 +11,8 @@ itemColor1=white
itemColor2=green
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=17
@@ -28,8 +28,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=2
@@ -45,8 +45,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=11
height=13
x=24

View File

@@ -9,8 +9,8 @@ roomLeft=0
roomRight=49.room
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=7
@@ -25,8 +25,8 @@ color=magenta
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=20

View File

@@ -4,7 +4,7 @@
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

10
default.gcw0.desktop Normal file
View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.6
Type=Application
Name=JailDoctor's Dilemma
Comment=JailDoctor's Dilemma
Icon=icon
Exec=jaildoctors_dilemma
Categories=games;Game;SDL;
Terminal=false

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

View File

@@ -23,11 +23,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.3</string>
<string>1.0.6.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.6</string>
<string>1.0.6.2</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSMinimumSystemVersion</key>

BIN
release/libgcc_s_seh-1.dll Normal file

Binary file not shown.

BIN
release/libstdc++-6.dll Normal file

Binary file not shown.

BIN
release/libwinpthread-1.dll Normal file

Binary file not shown.

View File

@@ -222,121 +222,121 @@ int AnimatedSprite::getIndex(std::string name)
// Calcula el frame correspondiente a la animación
void AnimatedSprite::animate()
{
if (!enabled || animation.at(currentAnimation).speed == 0)
if (!enabled || animation[currentAnimation].speed == 0)
{
return;
}
// Calcula el frame actual a partir del contador
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed;
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
// Si alcanza el final de la animación, reinicia el contador de la animación
// en función de la variable loop y coloca el nuevo frame
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size())
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
{
if (animation.at(currentAnimation).loop == -1)
if (animation[currentAnimation].loop == -1)
{ // Si no hay loop, deja el último frame
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size();
animation.at(currentAnimation).completed = true;
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
animation[currentAnimation].completed = true;
}
else
{ // Si hay loop, vuelve al frame indicado
animation.at(currentAnimation).counter = 0;
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop;
animation[currentAnimation].counter = 0;
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
}
}
// En caso contrario
else
{
// Escoge el frame correspondiente de la animación
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
// Incrementa el contador de la animacion
animation.at(currentAnimation).counter++;
animation[currentAnimation].counter++;
}
}
// Obtiene el numero de frames de la animación actual
int AnimatedSprite::getNumFrames()
{
return (int)animation.at(currentAnimation).frames.size();
return (int)animation[currentAnimation].frames.size();
}
// Establece el frame actual de la animación
void AnimatedSprite::setCurrentFrame(int num)
{
// Descarta valores fuera de rango
if (num >= (int)animation.at(currentAnimation).frames.size())
if (num >= (int)animation[currentAnimation].frames.size())
{
num = 0;
}
// Cambia el valor de la variable
animation.at(currentAnimation).currentFrame = num;
animation.at(currentAnimation).counter = 0;
animation[currentAnimation].currentFrame = num;
animation[currentAnimation].counter = 0;
// Escoge el frame correspondiente de la animación
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
}
// Establece el valor del contador
void AnimatedSprite::setAnimationCounter(std::string name, int num)
{
animation.at(getIndex(name)).counter = num;
animation[getIndex(name)].counter = num;
}
// Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
{
animation.at(getIndex(name)).counter = speed;
animation[getIndex(name)].counter = speed;
}
// Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(int index, int speed)
{
animation.at(index).counter = speed;
animation[index].counter = speed;
}
// Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
{
animation.at(getIndex(name)).loop = loop;
animation[getIndex(name)].loop = loop;
}
// Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(int index, int loop)
{
animation.at(index).loop = loop;
animation[index].loop = loop;
}
// Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
{
animation.at(getIndex(name)).completed = value;
animation[getIndex(name)].completed = value;
}
// OLD - Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(int index, bool value)
{
animation.at(index).completed = value;
animation[index].completed = value;
}
// Comprueba si ha terminado la animación
bool AnimatedSprite::animationIsCompleted()
{
return animation.at(currentAnimation).completed;
return animation[currentAnimation].completed;
}
// Devuelve el rectangulo de una animación y frame concreto
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
{
return animation.at(getIndex(name)).frames.at(index);
return animation[getIndex(name)].frames[index];
}
// Devuelve el rectangulo de una animación y frame concreto
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
{
return animation.at(indexA).frames.at(indexF);
return animation[indexA].frames[indexF];
}
// Carga la animación desde un vector
@@ -484,9 +484,9 @@ void AnimatedSprite::setCurrentAnimation(std::string name)
if (currentAnimation != newAnimation)
{
currentAnimation = newAnimation;
animation.at(currentAnimation).currentFrame = 0;
animation.at(currentAnimation).counter = 0;
animation.at(currentAnimation).completed = false;
animation[currentAnimation].currentFrame = 0;
animation[currentAnimation].counter = 0;
animation[currentAnimation].completed = false;
}
}
@@ -497,9 +497,9 @@ void AnimatedSprite::setCurrentAnimation(int index)
if (currentAnimation != newAnimation)
{
currentAnimation = newAnimation;
animation.at(currentAnimation).currentFrame = 0;
animation.at(currentAnimation).counter = 0;
animation.at(currentAnimation).completed = false;
animation[currentAnimation].currentFrame = 0;
animation[currentAnimation].counter = 0;
animation[currentAnimation].completed = false;
}
}
@@ -513,7 +513,7 @@ void AnimatedSprite::update()
// Establece el rectangulo para un frame de una animación
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
{
animation.at(index_animation).frames.push_back({x, y, w, h});
animation[index_animation].frames.push_back({x, y, w, h});
}
// OLD - Establece el contador para todas las animaciones
@@ -528,7 +528,7 @@ void AnimatedSprite::setAnimationCounter(int value)
// Reinicia la animación
void AnimatedSprite::resetAnimation()
{
animation.at(currentAnimation).currentFrame = 0;
animation.at(currentAnimation).counter = 0;
animation.at(currentAnimation).completed = false;
animation[currentAnimation].currentFrame = 0;
animation[currentAnimation].counter = 0;
animation[currentAnimation].completed = false;
}

View File

@@ -4,7 +4,11 @@
// Constructor
Asset::Asset(std::string executablePath)
{
#ifdef __MIPSEL
this->executablePath = ".";
#else
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
#endif
longestName = 0;
verbose = true;
}
@@ -114,7 +118,7 @@ bool Asset::checkFile(std::string path)
// Comprueba si existe el fichero
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(), "rb");
if (file != nullptr)
{

View File

@@ -0,0 +1,30 @@
#include "destsurface.h"
#include "systempalette.h"
namespace DestSurface
{
uint8_t *pixels = nullptr;
int width, height;
void init(int width, int height)
{
if (pixels==nullptr) pixels = new uint8_t[width*height];
DestSurface::width = width;
DestSurface::height = height;
}
void clear(uint32_t color)
{
SDL_memset(pixels, SystemPalette::getEntry(color), width*height);
}
uint8_t *getPixels()
{
return pixels;
}
int getWidth()
{
return width;
}
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <SDL2/SDL.h>
namespace DestSurface
{
void init(int width, int height);
void clear(uint32_t color);
uint8_t *getPixels();
int getWidth();
}

View File

@@ -34,13 +34,13 @@ void Input::update()
// Asigna inputs a teclas
void Input::bindKey(Uint8 input, SDL_Scancode code)
{
keyBindings.at(input).scancode = code;
keyBindings[input].scancode = code;
}
// Asigna inputs a botones del mando
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
{
gameControllerBindings.at(input).button = button;
gameControllerBindings[input].button = button;
}
// Comprueba si un input esta activo
@@ -65,7 +65,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
if (repeat)
{
if (keyStates[keyBindings.at(input).scancode] != 0)
if (keyStates[keyBindings[input].scancode] != 0)
{
successKeyboard = true;
}
@@ -76,11 +76,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
}
else
{
if (!keyBindings.at(input).active)
if (!keyBindings[input].active)
{
if (keyStates[keyBindings.at(input).scancode] != 0)
if (keyStates[keyBindings[input].scancode] != 0)
{
keyBindings.at(input).active = true;
keyBindings[input].active = true;
successKeyboard = true;
}
else
@@ -90,9 +90,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
}
else
{
if (keyStates[keyBindings.at(input).scancode] == 0)
if (keyStates[keyBindings[input].scancode] == 0)
{
keyBindings.at(input).active = false;
keyBindings[input].active = false;
successKeyboard = false;
}
else
@@ -108,7 +108,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
{
if (repeat)
{
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
{
successGameController = true;
}
@@ -119,11 +119,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
}
else
{
if (!gameControllerBindings.at(input).active)
if (!gameControllerBindings[input].active)
{
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
{
gameControllerBindings.at(input).active = true;
gameControllerBindings[input].active = true;
successGameController = true;
}
else
@@ -133,9 +133,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
}
else
{
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0)
{
gameControllerBindings.at(input).active = false;
gameControllerBindings[input].active = false;
successGameController = false;
}
else
@@ -163,7 +163,7 @@ bool Input::checkAnyInput(int device, int index)
for (int i = 0; i < (int)keyBindings.size(); ++i)
{
if (mKeystates[keyBindings.at(i).scancode] != 0)
if (mKeystates[keyBindings[i].scancode] != 0)
{
return true;
}
@@ -176,7 +176,7 @@ bool Input::checkAnyInput(int device, int index)
{
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
{
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
{
return true;
}
@@ -277,7 +277,7 @@ std::string Input::getControllerName(int index)
{
if (numGamepads > 0)
{
return controllerNames.at(index);
return controllerNames[index];
}
else
{

View File

@@ -1,3 +1,4 @@
#ifndef JA_USESDLMIXER
#include "jail_audio.h"
#include "stb_vorbis.c"
#include <SDL2/SDL.h>
@@ -11,7 +12,7 @@ struct JA_Sound_t {
};
struct JA_Channel_t {
JA_Sound sound;
JA_Sound_t *sound;
int pos {0};
int times {0};
JA_Channel_state state { JA_CHANNEL_FREE };
@@ -25,7 +26,7 @@ struct JA_Music_t {
JA_Music_state state {JA_MUSIC_INVALID};
};
JA_Music current_music{NULL};
JA_Music_t *current_music{NULL};
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
int JA_freq {48000};
@@ -86,7 +87,7 @@ void JA_Quit() {
sdlAudioDevice = 0;
}
JA_Music JA_LoadMusic(const char* filename) {
JA_Music_t *JA_LoadMusic(const char* filename) {
int chan, samplerate;
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
@@ -98,7 +99,7 @@ JA_Music JA_LoadMusic(const char* filename) {
if (fread(buffer, fsize, 1, f)!=1) return NULL;
fclose(f);
JA_Music music = new JA_Music_t();
JA_Music_t *music = new JA_Music_t();
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
free(buffer);
@@ -121,7 +122,7 @@ JA_Music JA_LoadMusic(const char* filename) {
return music;
}
void JA_PlayMusic(JA_Music music, const int loop) {
void JA_PlayMusic(JA_Music_t *music, const int loop) {
if (current_music != NULL) {
current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED;
@@ -153,21 +154,21 @@ JA_Music_state JA_GetMusicState() {
return current_music->state;
}
void JA_DeleteMusic(JA_Music music) {
void JA_DeleteMusic(JA_Music_t *music) {
if (current_music == music) current_music = NULL;
free(music->output);
delete music;
}
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length) {
JA_Sound sound = new JA_Sound_t();
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
JA_Sound_t *sound = new JA_Sound_t();
sound->buffer = buffer;
sound->length = length;
return sound;
}
JA_Sound JA_LoadSound(const char* filename) {
JA_Sound sound = new JA_Sound_t();
JA_Sound_t *JA_LoadSound(const char* filename) {
JA_Sound_t *sound = new JA_Sound_t();
SDL_AudioSpec wavSpec;
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
@@ -184,7 +185,7 @@ JA_Sound JA_LoadSound(const char* filename) {
return sound;
}
int JA_PlaySound(JA_Sound sound, const int loop) {
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
int channel = 0;
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
@@ -196,7 +197,7 @@ int JA_PlaySound(JA_Sound sound, const int loop) {
return channel;
}
void JA_DeleteSound(JA_Sound sound) {
void JA_DeleteSound(JA_Sound_t *sound) {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
if (channels[i].sound == sound) JA_StopChannel(i);
}
@@ -247,3 +248,4 @@ int JA_SetVolume(int volume) {
JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
return JA_volume;
}
#endif

View File

@@ -4,27 +4,27 @@
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED };
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED };
typedef struct JA_Sound_t *JA_Sound;
typedef struct JA_Music_t *JA_Music;
struct JA_Sound_t;
struct JA_Music_t;
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
void JA_Quit();
JA_Music JA_LoadMusic(const char* filename);
void JA_PlayMusic(JA_Music music, const int loop = -1);
JA_Music_t *JA_LoadMusic(const char* filename);
void JA_PlayMusic(JA_Music_t *music, const int loop = -1);
void JA_PauseMusic();
void JA_ResumeMusic();
void JA_StopMusic();
JA_Music_state JA_GetMusicState();
void JA_DeleteMusic(JA_Music music);
void JA_DeleteMusic(JA_Music_t *music);
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length);
JA_Sound JA_LoadSound(const char* filename);
int JA_PlaySound(JA_Sound sound, const int loop = 0);
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
JA_Sound_t *JA_LoadSound(const char* filename);
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
void JA_PauseChannel(const int channel);
void JA_ResumeChannel(const int channel);
void JA_StopChannel(const int channel);
JA_Channel_state JA_GetChannelState(const int channel);
void JA_DeleteSound(JA_Sound sound);
void JA_DeleteSound(JA_Sound_t *sound);
int JA_SetVolume(int volume);

View File

@@ -0,0 +1,101 @@
#ifdef JA_USESDLMIXER
#include "jail_audio.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
struct JA_Sound_t {}; // Dummy structs
struct JA_Music_t {};
int JA_freq {48000};
SDL_AudioFormat JA_format {AUDIO_S16};
Uint8 JA_channels {2};
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
JA_freq = freq;
JA_format = format;
JA_channels = channels;
Mix_OpenAudio(JA_freq, JA_format, JA_channels, 1024);
}
void JA_Quit() {
Mix_CloseAudio();
}
JA_Music_t *JA_LoadMusic(const char* filename) {
return (JA_Music_t*)Mix_LoadMUS(filename);
}
void JA_PlayMusic(JA_Music_t *music, const int loop) {
Mix_PlayMusic((Mix_Music*)music, loop);
}
void JA_PauseMusic() {
Mix_PauseMusic();
}
void JA_ResumeMusic() {
Mix_ResumeMusic();
}
void JA_StopMusic() {
Mix_HaltMusic();
}
JA_Music_state JA_GetMusicState() {
if (Mix_PausedMusic()) {
return JA_MUSIC_PAUSED;
} else if (Mix_PlayingMusic()) {
return JA_MUSIC_PLAYING;
} else {
return JA_MUSIC_STOPPED;
}
}
void JA_DeleteMusic(JA_Music_t *music) {
Mix_FreeMusic((Mix_Music*)music);
}
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
return NULL;
}
JA_Sound_t *JA_LoadSound(const char* filename) {
JA_Sound_t *sound = (JA_Sound_t*)Mix_LoadWAV(filename);
return sound;
}
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
return Mix_PlayChannel(-1, (Mix_Chunk*)sound, loop);
}
void JA_DeleteSound(JA_Sound_t *sound) {
Mix_FreeChunk((Mix_Chunk*)sound);
}
void JA_PauseChannel(const int channel) {
Mix_Pause(channel);
}
void JA_ResumeChannel(const int channel) {
Mix_Resume(channel);
}
void JA_StopChannel(const int channel) {
Mix_HaltChannel(channel);
}
JA_Channel_state JA_GetChannelState(const int channel) {
if (Mix_Paused(channel)) {
return JA_CHANNEL_PAUSED;
} else if (Mix_Playing(channel)) {
return JA_CHANNEL_PLAYING;
} else {
return JA_CHANNEL_FREE;
}
}
int JA_SetVolume(int volume) {
return Mix_Volume(-1, volume);
}
#endif

View File

@@ -458,7 +458,7 @@ void Menu::setSelectorPos(int index)
if (index < (int)item.size())
{
selector.index = index;
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y;
selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
selector.rect.w = rectBG.rect.w;
selector.rect.x = rectBG.rect.x;
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
@@ -486,13 +486,13 @@ void Menu::reset()
{
itemSelected = MENU_NO_OPTION;
selector.index = 0;
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
selector.originH = selector.targetH = item.at(0).rect.h;
selector.originY = selector.targetY = selector.y = item[0].rect.y;
selector.originH = selector.targetH = item[0].rect.h;
selector.moving = false;
selector.resizing = false;
// Si el primer elemento no es seleccionable, incrementa el selector
if (!item.at(selector.index).selectable)
if (!item[selector.index].selectable)
{
increaseSelectorIndex();
setSelectorPos(selector.index);
@@ -524,18 +524,18 @@ void Menu::reorganize()
bool Menu::increaseSelectorIndex()
{
// Obten las coordenadas del elemento actual
selector.y = selector.originY = item.at(selector.index).rect.y;
selector.y = selector.originY = item[selector.index].rect.y;
selector.h = selector.originH = getSelectorHeight(selector.index);
// Calcula cual es el siguiente elemento
++selector.index %= item.size();
while (!item.at(selector.index).selectable)
while (!item[selector.index].selectable)
{
++selector.index %= item.size();
}
// Establece las coordenadas y altura de destino
selector.targetY = item.at(selector.index).rect.y;
selector.targetY = item[selector.index].rect.y;
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
selector.targetH = getSelectorHeight(selector.index);
@@ -554,7 +554,7 @@ bool Menu::increaseSelectorIndex()
bool Menu::decreaseSelectorIndex()
{
// Obten las coordenadas del elemento actual
selector.y = selector.originY = item.at(selector.index).rect.y;
selector.y = selector.originY = item[selector.index].rect.y;
selector.h = selector.originH = getSelectorHeight(selector.index);
// Calcula cual es el siguiente elemento
@@ -567,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
selector.index--;
}
while (!item.at(selector.index).selectable)
while (!item[selector.index].selectable)
{
if (selector.index == 0)
{
@@ -580,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
}
// Establece las coordenadas y altura de destino
selector.targetY = item.at(selector.index).rect.y;
selector.targetY = item[selector.index].rect.y;
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
selector.targetH = getSelectorHeight(selector.index);
@@ -630,29 +630,29 @@ void Menu::render()
if (i == selector.index)
{
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
}
else if (item.at(i).selectable)
else if (item[i].selectable)
{
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
}
else if (item.at(i).greyed)
else if (item[i].greyed)
{
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
}
else
{ // No seleccionable
if ((item.at(i).linkedUp) && (i == selector.index + 1))
if ((item[i].linkedUp) && (i == selector.index + 1))
{
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
}
else // No enlazado con el de arriba
{
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
}
}
}
@@ -822,7 +822,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
if (item.size() > 1)
{
if (item.at(item.size() - 2).linkedDown)
if (item[item.size() - 2].linkedDown)
{
item.back().linkedUp = true;
}
@@ -835,9 +835,9 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
// Cambia el texto de un item
void Menu::setItemCaption(int index, std::string text)
{
item.at(index).label = text;
item.at(index).rect.w = this->text->lenght(item.at(index).label);
item.at(index).rect.h = this->text->getCharacterSize();
item[index].label = text;
item[index].rect.w = this->text->lenght(item[index].label);
item[index].rect.h = this->text->getCharacterSize();
reorganize();
}
@@ -914,42 +914,42 @@ int Menu::findHeight()
// Recoloca los elementos del menu en el eje Y
void Menu::replaceElementsOnY()
{
item.at(0).rect.y = y;
item[0].rect.y = y;
for (int i = 1; i < (int)item.size(); i++)
{
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
}
}
// Establece el estado seleccionable de un item
void Menu::setSelectable(int index, bool value)
{
item.at(index).selectable = value;
item[index].selectable = value;
}
// Establece el estado agrisado de un item
void Menu::setGreyed(int index, bool value)
{
item.at(index).greyed = value;
item[index].greyed = value;
}
// Establece el estado de enlace de un item
void Menu::setLinkedDown(int index, bool value)
{
item.at(index).linkedDown = value;
item[index].linkedDown = value;
}
// Calcula la altura del selector
int Menu::getSelectorHeight(int value)
{
if (item.at(value).linkedDown)
if (item[value].linkedDown)
{
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
}
else
{
return item.at(value).rect.h;
return item[value].rect.h;
}
}

View File

@@ -91,9 +91,9 @@ private:
bool isCenteredOnY; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y
bool areElementsCenteredOnX; // Variable para saber si los elementos van centrados en el eje X
int widestItem; // Anchura del elemento más ancho
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu
JA_Sound soundCancel; // Sonido al cancelar el menu
JA_Sound soundMove; // Sonido al mover el selector
JA_Sound_t* soundAccept; // Sonido al aceptar o elegir una opción del menu
JA_Sound_t* soundCancel; // Sonido al cancelar el menu
JA_Sound_t* soundMove; // Sonido al mover el selector
color_t colorGreyed; // Color para los elementos agrisados
rectangle_t rectBG; // Rectangulo de fondo del menu
std::vector<item_t> item; // Estructura para cada elemento del menu

View File

@@ -4,11 +4,12 @@
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile)
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
{
// Inicializa variables
this->renderer = renderer;
bgColor = {64, 64, 64};
this->options = options;
bgColor = options->notifications.color;
waitTime = 300;
// Crea objetos
@@ -37,7 +38,7 @@ void Notify::render()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
notifications.at(i).sprite->render();
notifications[i].sprite->render();
}
}
@@ -46,49 +47,63 @@ void Notify::update()
{
for (int i = 0; i < (int)notifications.size(); ++i)
{
notifications.at(i).counter++;
notifications[i].counter++;
// Comprueba los estados
if (notifications.at(i).state == ns_rising)
if (notifications[i].state == ns_rising)
{
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
const int alpha = 255 * step;
notifications.at(i).rect.y++;
notifications.at(i).texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y)
if (options->notifications.posV == pos_top)
{
notifications.at(i).state = ns_stay;
notifications.at(i).texture->setAlpha(255);
notifications.at(i).counter = 0;
notifications[i].rect.y++;
}
else
{
notifications[i].rect.y--;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y)
{
notifications[i].state = ns_stay;
notifications[i].texture->setAlpha(255);
notifications[i].counter = 0;
}
}
else if (notifications.at(i).state == ns_stay)
else if (notifications[i].state == ns_stay)
{
if (notifications.at(i).counter == waitTime)
if (notifications[i].counter == waitTime)
{
notifications.at(i).state = ns_vanishing;
notifications.at(i).counter = 0;
notifications[i].state = ns_vanishing;
notifications[i].counter = 0;
}
}
else if (notifications.at(i).state == ns_vanishing)
else if (notifications[i].state == ns_vanishing)
{
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
const int alpha = 255 * (1 - step);
notifications.at(i).rect.y--;
notifications.at(i).texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
if (options->notifications.posV == pos_top)
{
notifications.at(i).state = ns_finished;
notifications[i].rect.y--;
}
else
{
notifications[i].rect.y++;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
{
notifications[i].state = ns_finished;
}
}
notifications.at(i).sprite->setRect(notifications.at(i).rect);
notifications[i].sprite->setRect(notifications[i].rect);
}
clearFinishedNotifications();
@@ -99,10 +114,10 @@ void Notify::clearFinishedNotifications()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
if (notifications.at(i).state == ns_finished)
if (notifications[i].state == ns_finished)
{
delete notifications.at(i).sprite;
delete notifications.at(i).texture;
delete notifications[i].sprite;
delete notifications[i].texture;
notifications.erase(notifications.begin() + i);
}
}
@@ -111,24 +126,67 @@ void Notify::clearFinishedNotifications()
// Muestra una notificación de texto por pantalla;
void Notify::showText(std::string text)
{
// Crea constantes
// Inicializa variables
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
const int height = this->text->getCharacterSize() * 2;
const int despH = this->text->getCharacterSize() / 2;
const int despV = despH;
const int travelDist = height + despV;
const int offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
const int padding = (this->text->getCharacterSize() / 2);
// Posición horizontal
int despH = 0;
if (options->notifications.posH == pos_left)
{
despH = padding;
}
else if (options->notifications.posH == pos_middle)
{
despH = ((options->screen.windowWidth * options->windowSize) / 2 - (width / 2));
}
else
{
despH = (options->screen.windowWidth * options->windowSize) - width - padding;
}
// Posición vertical
int despV = 0;
if (options->notifications.posV == pos_top)
{
despV = padding;
}
else
{
despV = (options->screen.windowHeight * options->windowSize) - height - padding;
}
const int travelDist = height + padding;
// Offset
int offset = 0;
if (options->notifications.posV == pos_top)
{
offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
}
else
{
offset = (int)notifications.size() > 0 ? notifications.back().y - travelDist : despV;
}
// Crea la notificacion
notification_t n;
// inicializa variables
// Inicializa variables
n.y = offset;
n.travelDist = travelDist;
n.counter = 0;
n.state = ns_rising;
n.text = text;
if (options->notifications.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
}
else
{
n.rect = {despH, offset + travelDist, width, height};
}
// Crea la textura
n.texture = new Texture(renderer);
@@ -137,7 +195,7 @@ void Notify::showText(std::string text)
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer);
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, despV, text, 1, {255, 255, 255}, 1, {0, 0, 0});
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, padding, text, 1, {255, 255, 255}, 1, {0, 0, 0});
SDL_SetRenderTarget(renderer, nullptr);
// Crea el sprite
@@ -147,8 +205,11 @@ void Notify::showText(std::string text)
notifications.push_back(n);
// Reproduce el sonido de la notificación
if (options->notifications.sound)
{
JA_PlaySound(sound);
}
}
// Indica si hay notificaciones activas
bool Notify::active()

View File

@@ -51,12 +51,13 @@ private:
SDL_Renderer *renderer; // El renderizador de la ventana
Texture *texture; // Textura para la fuente de las notificaciones
Text *text; // Objeto para dibujar texto
options_t *options; // Variable con todas las opciones del programa
// Variables
color_t bgColor; // Color de fondo de las notificaciones
int waitTime; // Tiempo que se ve la notificación
std::vector<notification_t> notifications; // La lista de notificaciones activas
JA_Sound sound; // Sonido a reproducir cuando suena la notificación
JA_Sound_t* sound; // Sonido a reproducir cuando suena la notificación
// Elimina las notificaciones finalizadas
void clearFinishedNotifications();
@@ -69,7 +70,7 @@ public:
void update();
// Constructor
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile);
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
// Destructor
~Notify();

View File

@@ -1,6 +1,8 @@
#include "screen.h"
#include <string>
#include <iostream>
#include "destsurface.h"
#include "systempalette.h"
// Constructor
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options)
@@ -12,12 +14,12 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
this->asset = asset;
// Crea los objetos
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"));
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
gameCanvasWidth = options->gameWidth;
gameCanvasHeight = options->gameHeight;
borderWidth = options->gameWidth * options->borderSize;
borderHeight = options->gameHeight * options->borderSize;
borderWidth = options->borderWidth * 2;
borderHeight = options->borderHeight * 2;
notificationLogicalWidth = gameCanvasWidth;
notificationLogicalHeight = gameCanvasHeight;
@@ -28,7 +30,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
borderColor = {0x00, 0x00, 0x00};
// 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_STREAMING, gameCanvasWidth, gameCanvasHeight);
if (gameCanvas == nullptr)
{
if (options->console)
@@ -37,6 +39,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
}
}
DestSurface::init(gameCanvasWidth, gameCanvasHeight);
// Establece el modo de video
setVideoMode(options->videoMode);
@@ -53,26 +57,34 @@ Screen::~Screen()
// Limpia la pantalla
void Screen::clean(color_t color)
{
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
DestSurface::clear((color.r<<24) + (color.g<<16) + (color.b<<8) + 255);
}
// Prepara para empezar a dibujar en la textura de juego
void Screen::start()
{
SDL_SetRenderTarget(renderer, gameCanvas);
//SDL_SetRenderTarget(renderer, gameCanvas);
}
// Vuelca el contenido del renderizador en pantalla
void Screen::blit()
{
// Vuelve a dejar el renderizador en modo normal
SDL_SetRenderTarget(renderer, nullptr);
//SDL_SetRenderTarget(renderer, nullptr);
// Borra el contenido previo
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
SDL_RenderClear(renderer);
uint8_t *destSurface = DestSurface::getPixels();
Uint32 *pixels;
int pitch;
int size = gameCanvasWidth*gameCanvasHeight;
SDL_LockTexture(gameCanvas, NULL, (void**)&pixels, &pitch);
for (int i=0;i<size;++i) pixels[i] = SystemPalette::getRGBA(destSurface[i]);
SDL_UnlockTexture(gameCanvas);
// Copia la textura de juego en el renderizador en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
@@ -167,8 +179,10 @@ void Screen::setVideoMode(int videoMode)
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}
// Actualiza el valor de la variable
// Actualiza las opciones
options->videoMode = videoMode;
options->screen.windowWidth = windowWidth;
options->screen.windowHeight = windowHeight;
// Establece el tamaño de las notificaciones
setNotificationSize();
@@ -201,9 +215,15 @@ void Screen::setBlendMode(SDL_BlendMode blendMode)
}
// Establece el tamaño del borde
void Screen::setBorderSize(float s)
void Screen::setBorderWidth(int s)
{
options->borderSize = s;
options->borderWidth = s;
}
// Establece el tamaño del borde
void Screen::setBorderHeight(int s)
{
options->borderHeight = s;
}
// Establece si se ha de ver el borde en el modo ventana
@@ -336,7 +356,7 @@ void Screen::renderSpectrumFade()
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
const int max = spectrumColor.size() - 1;
const int index = max + (0 - max) * step;
const color_t c = spectrumColor.at(index);
const color_t c = spectrumColor[index];
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
}
@@ -375,9 +395,9 @@ void Screen::renderNotifications()
return;
}
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
//SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
notify->render();
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
//SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}
// Establece el tamaño de las notificaciones

View File

@@ -101,7 +101,8 @@ public:
void setBlendMode(SDL_BlendMode blendMode);
// Establece el tamaño del borde
void setBorderSize(float s);
void setBorderWidth(int s);
void setBorderHeight(int s);
// Establece si se ha de ver el borde en el modo ventana
void setBorderEnabled(bool value);

View File

@@ -27,12 +27,12 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *rende
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
{
// Establece la posición X,Y del sprite
x = rect.x;
y = rect.y;
this->x = rect.x;
this->y = rect.y;
// Establece el alto y el ancho del sprite
w = rect.w;
h = rect.h;
this->w = rect.w;
this->h = rect.h;
// Establece el puntero al renderizador de la ventana
this->renderer = renderer;

View File

@@ -0,0 +1,60 @@
#include "systempalette.h"
namespace SystemPalette
{
uint32_t entries[256]; // Las 256 entradas de la paleta
uint8_t numEntries; // El número de entradas existente actualmente
// Vacía la paleta
void Clear()
{
// Fijamos el color transparente en 0 y el blanco en 1
entries[0] = 0x00000000; // Transparente
entries[1] = 0xffffffff; // Blanco
numEntries = 2;
// Ya que 'getRGBA' no comprueba que el índice solicitado sea menor que
// 'numentries', rellenamos con 'negro' todas las entradas no usadas.
for (int i = 2; i < 256; ++i ) entries[i] = 0x000000ff;
}
// Obtenemos el índice de la paleta para el color especificado. Si no existe se crea.
uint8_t getEntry(const uint32_t color)
{
// ATENCIÓN!!! Si intentamos introducir más de 256 colores empezará a
// sobreescribir los primeros colores. Al menos no corromperá la
// memoria. Pensar la mejor forma de controlar esto.
// Recorremos la paleta...
for (int i = 0; i < numEntries; ++i)
{
// Si encontramos el color, devolvemos su índice y salimos
if (entries[i] == color) return i;
}
// Si no se ha encontrado, lo ponemos al final
entries[numEntries] = color;
// Y devolvemos su índice
return numEntries++;
}
// Versión de getEntry para obtener el color con los componentes R, G y B
uint8_t getEntry(const uint8_t r, const uint8_t g, const uint8_t b)
{
return getEntry( (r<<24) + (g<<16) + (b<<8) + 255 );
}
// Dado un índice, devolvemos su color
uint32_t getRGBA(const uint8_t entry)
{
// ATENCIÓN!!! No compruebo que el parámetro 'entry' sea menor que el
// miembro 'numEntries', por lo que se puede acceder a colores no
// definidos (por ejemplo tener 4 colores y acceder al color 8). La
// razón es que necesito que esta función sea lo más rápida posible.
// En cualquier caso, nunca se va a salir de la memoria ni nada raro.
return entries[entry];
}
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
namespace SystemPalette
{
// Vacía la paleta
void Clear();
// Obtenemos el índice de la paleta para el color especificado. Si no existe se crea.
uint8_t getEntry(const uint32_t color);
// Versión de getEntry para obtener el color con los componentes R, G y B
uint8_t getEntry(const uint8_t r, const uint8_t g, const uint8_t b);
// Dado un índice, devolvemos su color
uint32_t getRGBA(const uint8_t entry);
}

View File

@@ -3,6 +3,8 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <iostream>
#include "systempalette.h"
#include "destsurface.h"
// Constructor
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
@@ -12,14 +14,15 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
this->path = path;
// Inicializa
texture = nullptr;
width = 0;
height = 0;
this->pixels = nullptr;
this->width = 0;
this->height = 0;
this->color = 0xffffffff;
// Carga el fichero en la textura
if (path != "")
{
loadFromFile(path, renderer, verbose);
loadFromFile(path, verbose);
}
}
@@ -31,7 +34,7 @@ Texture::~Texture()
}
// Carga una imagen desde un fichero
bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose)
bool Texture::loadFromFile(std::string path, bool verbose)
{
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
int req_format = STBI_rgb_alpha;
@@ -50,89 +53,39 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbos
}
}
int depth, pitch;
Uint32 pixel_format;
if (req_format == STBI_rgb)
{
depth = 24;
pitch = 3 * width; // 3 bytes por pixel * pixels per linea
pixel_format = SDL_PIXELFORMAT_RGB24;
}
else
{ // STBI_rgb_alpha (RGBA)
depth = 32;
pitch = 4 * width;
pixel_format = SDL_PIXELFORMAT_RGBA32;
}
// Limpia
unload();
// La textura final
SDL_Texture *newTexture = nullptr;
// Carga la imagen desde una ruta específica
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
if (loadedSurface == nullptr)
{
if (verbose)
{
std::cout << "Unable to load image " << path.c_str() << std::endl;
}
}
else
{
// Crea la textura desde los pixels de la surface
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
if (newTexture == nullptr)
{
if (verbose)
{
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
}
}
else
{
// Obtiene las dimensiones de la imagen
this->width = loadedSurface->w;
this->height = loadedSurface->h;
}
// Elimina la textura cargada
SDL_FreeSurface(loadedSurface);
}
this->width = width;
this->height = height;
const int size = width*height;
this->pixels = new uint8_t[size];
for (int i = 0; i < size; ++i) this->pixels[i] = SystemPalette::getEntry(data[i]);
// Return success
texture = newTexture;
return texture != nullptr;
stbi_image_free(data);
return this->pixels != nullptr;
}
// Crea una textura en blanco
bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
{
// Crea una textura sin inicializar
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
if (texture == nullptr)
{
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
}
else
{
this->pixels = new uint8_t[width*height];
this->width = width;
this->height = height;
}
return texture != nullptr;
return this->pixels != nullptr;
}
// Libera la memoria de la textura
void Texture::unload()
{
// Libera la textura si existe
if (texture != nullptr)
if (pixels != nullptr)
{
SDL_DestroyTexture(texture);
texture = nullptr;
delete[] pixels;
pixels = nullptr;
width = 0;
height = 0;
}
@@ -141,19 +94,19 @@ void Texture::unload()
// Establece el color para la modulacion
void Texture::setColor(Uint8 red, Uint8 green, Uint8 blue)
{
SDL_SetTextureColorMod(texture, red, green, blue);
this->color = (red << 24) + (green << 16) + (blue << 8) + 255;
}
// Establece el blending
void Texture::setBlendMode(SDL_BlendMode blending)
{
SDL_SetTextureBlendMode(texture, blending);
//SDL_SetTextureBlendMode(texture, blending);
}
// Establece el alpha para la modulación
void Texture::setAlpha(Uint8 alpha)
{
SDL_SetTextureAlphaMod(texture, alpha);
//SDL_SetTextureAlphaMod(texture, alpha);
}
// Renderiza la textura en un punto específico
@@ -173,13 +126,24 @@ void Texture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float
renderQuad.h = renderQuad.h * zoomH;
// Renderiza a pantalla
SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
//SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
uint8_t *destSurface = DestSurface::getPixels();
int canvasWidth = DestSurface::getWidth();
int y_inc = 1, y_ini = 0, y_fin = renderQuad.h-1; if (flip && SDL_FLIP_VERTICAL==SDL_FLIP_VERTICAL) { auto tmp=y_ini; y_ini=y_fin; y_fin=tmp; y_inc=-1; }
int x_inc = 1, x_ini = 0, x_fin = renderQuad.w-1; if (flip && SDL_FLIP_HORIZONTAL==SDL_FLIP_HORIZONTAL) { auto tmp=x_ini; x_ini=x_fin; x_fin=tmp; x_inc=-1; }
for (int yy=y_ini; yy <= y_fin; yy += y_inc) {
for (int xx=x_ini; xx <= x_fin; xx += x_inc) {
destSurface[ x+xx + y+yy * canvasWidth ] = pixels[ clip->x+xx + clip->y+yy * width ];
}
}
}
// Establece la textura como objetivo de renderizado
void Texture::setAsRenderTarget(SDL_Renderer *renderer)
{
SDL_SetRenderTarget(renderer, texture);
//SDL_SetRenderTarget(renderer, texture);
}
// Obtiene el ancho de la imagen
@@ -203,5 +167,5 @@ bool Texture::reLoad()
// Obtiene la textura
SDL_Texture *Texture::getSDLTexture()
{
return texture;
return nullptr; //texture;
}

View File

@@ -11,13 +11,14 @@ class Texture
{
private:
// Objetos y punteros
SDL_Texture *texture; // La textura
uint8_t *pixels; // Los pixels de esta textura
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
// Variables
int width; // Ancho de la imagen
int height; // Alto de la imagen
std::string path; // Ruta de la imagen de la textura
uint32_t color; // Color para el pintado de 1 bit (sprites y tal)
public:
// Constructor
@@ -27,7 +28,7 @@ public:
~Texture();
// Carga una imagen desde un fichero
bool loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose = false);
bool loadFromFile(std::string path, bool verbose = false);
// Crea una textura en blanco
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);

View File

@@ -54,6 +54,33 @@ enum palette_e
p_zxarne
};
// Posiciones de las notificaciones
enum not_pos_e
{
pos_top,
pos_bottom,
pos_left,
pos_middle,
pos_right
};
// Tipos de control de teclado
enum ctrl_schem_e
{
ctrl_cursor,
ctrl_opqa,
ctrl_wasd
};
// Estructura para las opciones de las notificaciones
struct op_notification_t
{
not_pos_e posH; // Ubicación de las notificaciones en pantalla
not_pos_e posV; // Ubicación de las notificaciones en pantalla
bool sound; // Indica si las notificaciones suenan
color_t color; // Color de las notificaciones
};
// Estructura para saber la seccion y subseccion del programa
struct section_t
{
@@ -89,6 +116,13 @@ struct op_stats_t
std::string worstNightmare; // Habitación con más muertes acumuladas
};
// Estructura con opciones de la pantalla
struct op_screen_t
{
int windowWidth; // Ancho de la ventana
int windowHeight; // Alto de la ventana
};
// Estructura con todas las opciones de configuración del programa
struct options_t
{
@@ -102,12 +136,16 @@ struct options_t
bool integerScale; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana
float borderSize; // Porcentaje de borde que se añade a lo ventana
int borderWidth; // Cantidad de pixels que se añade en el borde de la ventana
int borderHeight; // Cantidad de pixels que se añade en el borde de la ventana
palette_e palette; // Paleta de colores a usar en el juego
bool console; // Indica si ha de mostrar información por la consola de texto
cheat_t cheat; // Contiene trucos y ventajas para el juego
op_stats_t stats; // Datos con las estadisticas de juego
online_t online; // Datos del servicio online
op_notification_t notifications; // Opciones relativas a las notificaciones;
op_screen_t screen; // Opciones relativas a la clase screen
ctrl_schem_e keys; // Teclas usadas para jugar
};
// Calcula el cuadrado de la distancia entre dos puntos

View File

@@ -133,6 +133,20 @@ void Credits::checkEventHandler()
// Inicializa los textos
void Credits::iniTexts()
{
std::string keys = "";
if (options->keys == ctrl_cursor)
{
keys = "CURSORS";
}
else if (options->keys == ctrl_opqa)
{
keys = "O,P AND Q";
}
else
{
keys = "A,D AND W";
}
texts.clear();
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
@@ -145,9 +159,9 @@ void Credits::iniTexts()
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"CURSORS TO MOVE AND JUMP", stringToColor(options->palette, "white")});
texts.push_back({keys + " TO MOVE AND JUMP", stringToColor(options->palette, "white")});
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"P TO PAUSE THE GAME", stringToColor(options->palette, "white")});
texts.push_back({"H TO HOLD/PAUSE THE GAME", stringToColor(options->palette, "white")});
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
texts.push_back({"B TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
@@ -186,7 +200,7 @@ void Credits::fillTexture()
}
// Escribe el corazón
const int textLenght = text->lenght(texts.at(22).label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int textLenght = text->lenght(texts[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));

View File

@@ -15,7 +15,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
rooms.push_back("44.room");
roomIndex = 0;
currentRoom = rooms.at(roomIndex);
currentRoom = rooms[roomIndex];
// Copia los punteros
this->resource = resource;
@@ -164,8 +164,8 @@ void Demo::render()
{
// Prepara para dibujar el frame
screen->start();
screen->clean(room->getBGColor());
// Dibuja los elementos del juego en orden
room->renderMap();
room->renderEnemies();
room->renderItems();
@@ -260,7 +260,7 @@ void Demo::checkRoomChange()
}
else
{
changeRoom(rooms.at(roomIndex));
changeRoom(rooms[roomIndex]);
}
}
}

View File

@@ -57,9 +57,6 @@ Director::Director(int argc, char *argv[])
screen->setBorderColor(borderColor);
debug = new Debug(renderer, screen, asset);
music = JA_LoadMusic(asset->get("title.ogg").c_str());
// Inicializa los servicios online
//initOnline();
}
Director::~Director()
@@ -112,24 +109,32 @@ void Director::initOptions()
// Crea el puntero a la estructura de opciones
options = new options_t;
// Version
// Version del archivo de configuración
options->configVersion = "v1.06.1";
// Opciones dee video
// Opciones de control
options->keys = ctrl_cursor;
// Opciones de video
options->gameWidth = GAMECANVAS_WIDTH;
options->gameHeight = GAMECANVAS_HEIGHT;
options->videoMode = 0;
options->windowSize = 3;
options->filter = FILTER_NEAREST;
options->vSync = true;
options->vSync = false;
options->integerScale = true;
options->keepAspect = true;
options->borderEnabled = true;
options->borderSize = 0.2f;
options->borderWidth = 32;
options->borderHeight = 24;
options->palette = p_zxspectrum;
#ifdef GAME_CONSOLE
options->windowSize = 1;
#endif
// Estos valores no se guardan en el fichero de configuraci´ón
options->console = false;
options->console = true;
options->cheat.infiniteLives = false;
options->cheat.invincible = false;
options->cheat.jailEnabled = false;
@@ -147,6 +152,12 @@ void Director::initOptions()
options->online.gameID = "jaildoctors_dilemma";
#endif
options->online.jailerID = "";
// Opciones de las notificaciones
options->notifications.posV = pos_top;
options->notifications.posH = pos_left;
options->notifications.sound = true;
options->notifications.color = {64, 64, 64};
}
// Comprueba los parametros del programa
@@ -306,6 +317,21 @@ bool Director::saveConfig()
file << "## VERSION\n";
file << "configVersion=" + options->configVersion + "\n";
file << "\n## CONTROL OPTIONS\n";
file << "## keys = CURSOR | OPQA | WASD\n";
if (options->keys == ctrl_cursor)
{
file << "keys=CURSOR\n";
}
else if (options->keys == ctrl_opqa)
{
file << "keys=OPQA\n";
}
else if (options->keys == ctrl_wasd)
{
file << "keys=WASD\n";
}
file << "\n## VISUAL OPTIONS\n";
if (options->videoMode == 0)
{
@@ -337,7 +363,8 @@ bool Director::saveConfig()
file << "integerScale=" + boolToString(options->integerScale) + "\n";
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
file << "borderSize=" + std::to_string(options->borderSize) + "\n";
file << "borderWidth=" + std::to_string(options->borderWidth) + "\n";
file << "borderHeight=" + std::to_string(options->borderHeight) + "\n";
file << "palette=" + std::to_string(options->palette) + "\n";
file << "\n## ONLINE OPTIONS\n";
@@ -346,6 +373,33 @@ bool Director::saveConfig()
file << "port=" + std::to_string(options->online.port) + "\n";
file << "jailerID=" + options->online.jailerID + "\n";
file << "\n## NOTIFICATION OPTIONS\n";
file << "## notifications.posV = pos_top | pos_bottom\n";
if (options->notifications.posV == pos_top)
{
file << "notifications.posV=pos_top\n";
}
else
{
file << "notifications.posV=pos_bottom\n";
}
file << "## notifications.posH = pos_left | pos_middle | pos_right\n";
if (options->notifications.posH == pos_left)
{
file << "notifications.posH=pos_left\n";
}
else if (options->notifications.posH == pos_middle)
{
file << "notifications.posH=pos_middle\n";
}
else
{
file << "notifications.posH=pos_right\n";
}
file << "notifications.sound=" + boolToString(options->notifications.sound) + "\n";
// Cierra el fichero
file.close();
@@ -510,9 +564,9 @@ void Director::loadResources(section_t section)
textureList.push_back("abad.png");
textureList.push_back("abad_bell.png");
textureList.push_back("amstrad_cs.png");
textureList.push_back("arounder_fly.png");
textureList.push_back("arounder_stop.png");
textureList.push_back("arounder_walk.png");
textureList.push_back("flying_arounder.png");
textureList.push_back("stopped_arounder.png");
textureList.push_back("walking_arounder.png");
textureList.push_back("arounders_door.png");
textureList.push_back("arounders_machine.png");
textureList.push_back("bat.png");
@@ -531,14 +585,14 @@ void Director::loadResources(section_t section)
textureList.push_back("demon.png");
textureList.push_back("heavy.png");
textureList.push_back("dimallas.png");
textureList.push_back("diskette.png");
textureList.push_back("floppy.png");
textureList.push_back("dong.png");
textureList.push_back("guitar.png");
textureList.push_back("jb_alien.png");
textureList.push_back("jb_human.png");
textureList.push_back("jailer.png");
textureList.push_back("jailer2.png");
textureList.push_back("jailer3.png");
textureList.push_back("jailbattle_alien.png");
textureList.push_back("jailbattle_human.png");
textureList.push_back("jailer_#1.png");
textureList.push_back("jailer_#2.png");
textureList.push_back("jailer_#3.png");
textureList.push_back("jeannine.png");
textureList.push_back("lamp.png");
textureList.push_back("lord_abad.png");
@@ -546,7 +600,7 @@ void Director::loadResources(section_t section)
textureList.push_back("matatunos.png");
textureList.push_back("mummy.png");
textureList.push_back("paco.png");
textureList.push_back("printer.png");
textureList.push_back("elsa.png");
textureList.push_back("qvoid.png");
textureList.push_back("sam.png");
textureList.push_back("sigmasua.png");
@@ -573,9 +627,9 @@ void Director::loadResources(section_t section)
animationList.push_back("abad.ani");
animationList.push_back("abad_bell.ani");
animationList.push_back("amstrad_cs.ani");
animationList.push_back("arounder_fly.ani");
animationList.push_back("arounder_stop.ani");
animationList.push_back("arounder_walk.ani");
animationList.push_back("flying_arounder.ani");
animationList.push_back("stopped_arounder.ani");
animationList.push_back("walking_arounder.ani");
animationList.push_back("arounders_door.ani");
animationList.push_back("arounders_machine.ani");
animationList.push_back("bat.ani");
@@ -594,14 +648,14 @@ void Director::loadResources(section_t section)
animationList.push_back("demon.ani");
animationList.push_back("heavy.ani");
animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani");
animationList.push_back("floppy.ani");
animationList.push_back("dong.ani");
animationList.push_back("guitar.ani");
animationList.push_back("jb_alien.ani");
animationList.push_back("jb_human.ani");
animationList.push_back("jailer.ani");
animationList.push_back("jailer2.ani");
animationList.push_back("jailer3.ani");
animationList.push_back("jailbattle_alien.ani");
animationList.push_back("jailbattle_human.ani");
animationList.push_back("jailer_#1.ani");
animationList.push_back("jailer_#2.ani");
animationList.push_back("jailer_#3.ani");
animationList.push_back("jeannine.ani");
animationList.push_back("lamp.ani");
animationList.push_back("lord_abad.ani");
@@ -609,7 +663,7 @@ void Director::loadResources(section_t section)
animationList.push_back("matatunos.ani");
animationList.push_back("mummy.ani");
animationList.push_back("paco.ani");
animationList.push_back("printer.ani");
animationList.push_back("elsa.ani");
animationList.push_back("qvoid.ani");
animationList.push_back("sam.ani");
animationList.push_back("sigmasua.ani");
@@ -684,9 +738,9 @@ void Director::loadResources(section_t section)
textureList.push_back("abad.png");
textureList.push_back("aerojailer.png");
textureList.push_back("amstrad_cs.png");
textureList.push_back("arounder_fly.png");
textureList.push_back("arounder_stop.png");
textureList.push_back("arounder_walk.png");
textureList.push_back("flying_arounder.png");
textureList.push_back("stopped_arounder.png");
textureList.push_back("walking_arounder.png");
textureList.push_back("arounder.png");
textureList.push_back("arounders_door.png");
textureList.push_back("arounders_machine.png");
@@ -705,15 +759,15 @@ void Director::loadResources(section_t section)
textureList.push_back("crosshair.png");
textureList.push_back("demon.png");
textureList.push_back("dimallas.png");
textureList.push_back("diskette.png");
textureList.push_back("floppy.png");
textureList.push_back("dong.png");
textureList.push_back("guitar.png");
textureList.push_back("heavy.png");
textureList.push_back("jailer.png");
textureList.push_back("jailer2.png");
textureList.push_back("jailer3.png");
textureList.push_back("jb_alien.png");
textureList.push_back("jb_human.png");
textureList.push_back("jailer_#1.png");
textureList.push_back("jailer_#2.png");
textureList.push_back("jailer_#3.png");
textureList.push_back("jailbattle_alien.png");
textureList.push_back("jailbattle_human.png");
textureList.push_back("jeannine.png");
textureList.push_back("lamp.png");
textureList.push_back("lord_abad.png");
@@ -721,7 +775,7 @@ void Director::loadResources(section_t section)
textureList.push_back("mummy.png");
textureList.push_back("paco.png");
textureList.push_back("pepe_rosita_job.png");
textureList.push_back("printer.png");
textureList.push_back("elsa.png");
textureList.push_back("qvoid.png");
textureList.push_back("robot.png");
textureList.push_back("sam.png");
@@ -765,9 +819,9 @@ void Director::loadResources(section_t section)
animationList.push_back("abad.ani");
animationList.push_back("aerojailer.ani");
animationList.push_back("amstrad_cs.ani");
animationList.push_back("arounder_fly.ani");
animationList.push_back("arounder_stop.ani");
animationList.push_back("arounder_walk.ani");
animationList.push_back("flying_arounder.ani");
animationList.push_back("stopped_arounder.ani");
animationList.push_back("walking_arounder.ani");
animationList.push_back("arounder.ani");
animationList.push_back("arounders_door.ani");
animationList.push_back("arounders_machine.ani");
@@ -786,15 +840,15 @@ void Director::loadResources(section_t section)
animationList.push_back("crosshair.ani");
animationList.push_back("demon.ani");
animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani");
animationList.push_back("floppy.ani");
animationList.push_back("dong.ani");
animationList.push_back("guitar.ani");
animationList.push_back("heavy.ani");
animationList.push_back("jailer.ani");
animationList.push_back("jailer2.ani");
animationList.push_back("jailer3.ani");
animationList.push_back("jb_alien.ani");
animationList.push_back("jb_human.ani");
animationList.push_back("jailer_#1.ani");
animationList.push_back("jailer_#2.ani");
animationList.push_back("jailer_#3.ani");
animationList.push_back("jailbattle_alien.ani");
animationList.push_back("jailbattle_human.ani");
animationList.push_back("jeannine.ani");
animationList.push_back("lamp.ani");
animationList.push_back("lord_abad.ani");
@@ -802,7 +856,7 @@ void Director::loadResources(section_t section)
animationList.push_back("mummy.ani");
animationList.push_back("paco.ani");
animationList.push_back("pepe_rosita_job.ani");
animationList.push_back("printer.ani");
animationList.push_back("elsa.ani");
animationList.push_back("qvoid.ani");
animationList.push_back("robot.ani");
animationList.push_back("sam.ani");
@@ -976,6 +1030,22 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->configVersion = value;
}
else if (var == "keys")
{
if (value == "OPQA")
{
options->keys = ctrl_opqa;
}
else if (value == "WASD")
{
options->keys = ctrl_wasd;
}
else
{
options->keys = ctrl_cursor;
}
}
else if (var == "videoMode")
{
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
@@ -1033,13 +1103,14 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->borderEnabled = stringToBool(value);
}
else if (var == "borderSize")
else if (var == "borderWidth")
{
options->borderSize = std::stof(value);
if (options->borderSize < 0.0f || options->borderSize > 0.5f)
{
options->borderSize = 0.1f;
options->borderWidth = std::stoi(value);
}
else if (var == "borderHeight")
{
options->borderHeight = std::stoi(value);
}
else if (var == "palette")
@@ -1081,6 +1152,39 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->online.jailerID = value;
}
else if (var == "notifications.posH")
{
if (value == "pos_left")
{
options->notifications.posH = pos_left;
}
else if (value == "pos_middle")
{
options->notifications.posH = pos_middle;
}
else
{
options->notifications.posH = pos_right;
}
}
else if (var == "notifications.posV")
{
if (value == "pos_top")
{
options->notifications.posV = pos_top;
}
else
{
options->notifications.posV = pos_bottom;
}
}
else if (var == "notifications.sound")
{
options->notifications.sound = stringToBool(value);
}
else if (var == "" || var.substr(0, 1) == "#")
{
}
@@ -1103,10 +1207,26 @@ void Director::initInput()
input->discoverGameController();
// Asigna inputs a teclas
if (options->keys == ctrl_cursor)
{
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
}
else if (options->keys == ctrl_opqa)
{
input->bindKey(INPUT_UP, SDL_SCANCODE_Q);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_O);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_P);
}
else if (options->keys == ctrl_wasd)
{
input->bindKey(INPUT_UP, SDL_SCANCODE_W);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_A);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_D);
}
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN);
input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE);
@@ -1114,14 +1234,14 @@ void Director::initInput()
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE);
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_START);
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
}
@@ -1165,8 +1285,8 @@ bool Director::initSDL()
int incH = 0;
if (options->borderEnabled)
{
incW = options->gameWidth * options->borderSize;
incH = options->gameHeight * options->borderSize;
incW = options->borderWidth * 2;
incH = options->borderHeight * 2;
}
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (options->gameWidth + incW) * options->windowSize, (options->gameHeight + incH) * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
@@ -1377,12 +1497,12 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/abad.png", t_bitmap);
asset->add(prefix + "/data/enemies/amstrad_cs.ani", t_data);
asset->add(prefix + "/data/enemies/amstrad_cs.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_fly.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_fly.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_stop.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_stop.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_walk.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_walk.png", t_bitmap);
asset->add(prefix + "/data/enemies/flying_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/flying_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/stopped_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/stopped_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/walking_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/walking_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounders_door.ani", t_data);
asset->add(prefix + "/data/enemies/arounders_door.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounders_machine.ani", t_data);
@@ -1417,24 +1537,24 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
asset->add(prefix + "/data/enemies/diskette.ani", t_data);
asset->add(prefix + "/data/enemies/diskette.png", t_bitmap);
asset->add(prefix + "/data/enemies/floppy.ani", t_data);
asset->add(prefix + "/data/enemies/floppy.png", t_bitmap);
asset->add(prefix + "/data/enemies/dong.ani", t_data);
asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
asset->add(prefix + "/data/enemies/guitar.ani", t_data);
asset->add(prefix + "/data/enemies/guitar.png", t_bitmap);
asset->add(prefix + "/data/enemies/heavy.ani", t_data);
asset->add(prefix + "/data/enemies/heavy.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer.ani", t_data);
asset->add(prefix + "/data/enemies/jailer.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer2.ani", t_data);
asset->add(prefix + "/data/enemies/jailer2.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer3.ani", t_data);
asset->add(prefix + "/data/enemies/jailer3.png", t_bitmap);
asset->add(prefix + "/data/enemies/jb_alien.ani", t_data);
asset->add(prefix + "/data/enemies/jb_alien.png", t_bitmap);
asset->add(prefix + "/data/enemies/jb_human.ani", t_data);
asset->add(prefix + "/data/enemies/jb_human.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#1.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#1.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#2.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#2.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#3.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#3.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailbattle_alien.ani", t_data);
asset->add(prefix + "/data/enemies/jailbattle_alien.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailbattle_human.ani", t_data);
asset->add(prefix + "/data/enemies/jailbattle_human.png", t_bitmap);
asset->add(prefix + "/data/enemies/jeannine.ani", t_data);
asset->add(prefix + "/data/enemies/jeannine.png", t_bitmap);
asset->add(prefix + "/data/enemies/lamp.ani", t_data);
@@ -1447,8 +1567,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/mummy.png", t_bitmap);
asset->add(prefix + "/data/enemies/paco.ani", t_data);
asset->add(prefix + "/data/enemies/paco.png", t_bitmap);
asset->add(prefix + "/data/enemies/printer.ani", t_data);
asset->add(prefix + "/data/enemies/printer.png", t_bitmap);
asset->add(prefix + "/data/enemies/elsa.ani", t_data);
asset->add(prefix + "/data/enemies/elsa.png", t_bitmap);
asset->add(prefix + "/data/enemies/qvoid.ani", t_data);
asset->add(prefix + "/data/enemies/qvoid.png", t_bitmap);
asset->add(prefix + "/data/enemies/robot.ani", t_data);

View File

@@ -49,7 +49,7 @@ private:
// Variables
section_t section; // Sección y subsección actual del programa;
JA_Music music; // Musica del titulo
JA_Music_t* music; // Musica del titulo
std::string executablePath; // Path del ejecutable
std::string systemFolder; // Carpeta del sistema donde guardar datos

View File

@@ -119,16 +119,16 @@ void Ending::render()
screen->clean(stringToColor(options->palette, "black"));
// Dibuja las imagenes de la escena
spritePics.at(scene).sprite->render();
spritePics.at(scene).coverSprite->render();
spritePics[scene].sprite->render();
spritePics[scene].coverSprite->render();
// Dibuja los textos de la escena
for (auto ti : scenes.at(scene).textIndex)
for (auto ti : scenes[scene].textIndex)
{
if (counter > ti.trigger)
{
spriteTexts.at(ti.index).sprite->render();
spriteTexts.at(ti.index).coverSprite->render();
spriteTexts[ti.index].sprite->render();
spriteTexts[ti.index].coverSprite->render();
}
}
@@ -511,7 +511,7 @@ void Ending::updateCounters()
counter++;
}
if (counter > scenes.at(scene).counterEnd - 100)
if (counter > scenes[scene].counterEnd - 100)
{
coverCounter++;
}
@@ -522,20 +522,20 @@ void Ending::updateSpriteCovers()
{ // Actualiza la cortinilla de los textos
if (counter % 4 == 0)
{
for (auto ti : scenes.at(scene).textIndex)
for (auto ti : scenes[scene].textIndex)
{
if (counter > ti.trigger)
{
if (spriteTexts.at(ti.index).clipDesp > 0)
if (spriteTexts[ti.index].clipDesp > 0)
{
spriteTexts.at(ti.index).clipDesp -= 2;
spriteTexts[ti.index].clipDesp -= 2;
}
else if (spriteTexts.at(ti.index).clipHeight > 0)
else if (spriteTexts[ti.index].clipHeight > 0)
{
spriteTexts.at(ti.index).clipHeight -= 2;
spriteTexts.at(ti.index).coverSprite->setPosY(spriteTexts.at(ti.index).coverSprite->getPosY() + 2);
spriteTexts[ti.index].clipHeight -= 2;
spriteTexts[ti.index].coverSprite->setPosY(spriteTexts[ti.index].coverSprite->getPosY() + 2);
}
spriteTexts.at(ti.index).coverSprite->setSpriteClip(0, spriteTexts.at(ti.index).clipDesp, spriteTexts.at(ti.index).coverSprite->getWidth(), spriteTexts.at(ti.index).clipHeight);
spriteTexts[ti.index].coverSprite->setSpriteClip(0, spriteTexts[ti.index].clipDesp, spriteTexts[ti.index].coverSprite->getWidth(), spriteTexts[ti.index].clipHeight);
}
}
}
@@ -543,27 +543,27 @@ void Ending::updateSpriteCovers()
// Actualiza la cortinilla de las imagenes
if (counter % 2 == 0)
{
if (spritePics.at(scene).clipDesp > 0)
if (spritePics[scene].clipDesp > 0)
{
spritePics.at(scene).clipDesp -= 2;
spritePics[scene].clipDesp -= 2;
}
else if (spritePics.at(scene).clipHeight > 0)
else if (spritePics[scene].clipHeight > 0)
{
spritePics.at(scene).clipHeight -= 2;
if (spritePics.at(scene).clipHeight < 0)
spritePics[scene].clipHeight -= 2;
if (spritePics[scene].clipHeight < 0)
{
spritePics.at(scene).clipHeight = 0;
spritePics[scene].clipHeight = 0;
}
spritePics.at(scene).coverSprite->setPosY(spritePics.at(scene).coverSprite->getPosY() + 2);
spritePics[scene].coverSprite->setPosY(spritePics[scene].coverSprite->getPosY() + 2);
}
spritePics.at(scene).coverSprite->setSpriteClip(0, spritePics.at(scene).clipDesp, spritePics.at(scene).coverSprite->getWidth(), spritePics.at(scene).clipHeight);
spritePics[scene].coverSprite->setSpriteClip(0, spritePics[scene].clipDesp, spritePics[scene].coverSprite->getWidth(), spritePics[scene].clipHeight);
}
}
// Comprueba si se ha de cambiar de escena
void Ending::checkChangeScene()
{
if (counter > scenes.at(scene).counterEnd)
if (counter > scenes[scene].counterEnd)
{
scene++;
counter = 0;
@@ -639,20 +639,20 @@ void Ending::switchPalette()
{
options->palette = p_zxarne;
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
spritePics[2].sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
spritePics[3].sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
spritePics[4].sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
}
else
{
options->palette = p_zxspectrum;
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1.png"));
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2.png"));
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3.png"));
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4.png"));
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5.png"));
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
spritePics[2].sprite->setTexture(resource->getTexture("ending3.png"));
spritePics[3].sprite->setTexture(resource->getTexture("ending4.png"));
spritePics[4].sprite->setTexture(resource->getTexture("ending5.png"));
}
}

View File

@@ -70,7 +70,7 @@ private:
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
int scene; // Escena actual
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
JA_Music music; // Musica que suena durante el final
JA_Music_t* music; // Musica que suena durante el final
// Actualiza el objeto
void update();

View File

@@ -288,14 +288,14 @@ void Ending2::iniSpriteList()
// Añade los valores
spriteList.push_back("bin");
spriteList.push_back("diskette");
spriteList.push_back("floppy");
spriteList.push_back("bird");
spriteList.push_back("chip");
spriteList.push_back("jeannine");
spriteList.push_back("spark");
spriteList.push_back("code");
spriteList.push_back("paco");
spriteList.push_back("printer");
spriteList.push_back("elsa");
spriteList.push_back("z80");
spriteList.push_back("bell");
@@ -304,9 +304,9 @@ void Ending2::iniSpriteList()
spriteList.push_back("amstrad_cs");
spriteList.push_back("breakout");
spriteList.push_back("arounder_fly");
spriteList.push_back("arounder_stop");
spriteList.push_back("arounder_walk");
spriteList.push_back("flying_arounder");
spriteList.push_back("stopped_arounder");
spriteList.push_back("walking_arounder");
spriteList.push_back("arounders_door");
spriteList.push_back("arounders_machine");
@@ -324,12 +324,12 @@ void Ending2::iniSpriteList()
spriteList.push_back("dimallas");
spriteList.push_back("guitar");
spriteList.push_back("jb_alien");
spriteList.push_back("jb_human");
spriteList.push_back("jailbattle_alien");
spriteList.push_back("jailbattle_human");
spriteList.push_back("jailer");
spriteList.push_back("jailer2");
spriteList.push_back("jailer3");
spriteList.push_back("jailer_#1");
spriteList.push_back("jailer_#2");
spriteList.push_back("jailer_#3");
spriteList.push_back("bry");
spriteList.push_back("upv_student");
@@ -469,13 +469,13 @@ void Ending2::placeSprites()
{
const int x = i % 2 == 0 ? firstCol : secondCol;
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
const int w = sprites[i]->getAnimationClip(0, 0).w;
const int h = sprites[i]->getAnimationClip(0, 0).h;
const int dx = -(w / 2);
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
sprites.at(i)->setRect({x + dx, y + dy, w, h});
sprites.at(i)->setVelY(despSpeed);
sprites[i]->setRect({x + dx, y + dy, w, h});
sprites[i]->setVelY(despSpeed);
}
// Recoloca el último sprite, que es el del jugador
@@ -497,14 +497,14 @@ void Ending2::createSpriteTexts()
for (int i = 0; i < (int)spriteList.size(); ++i)
{
// Calcula constantes
std::string txt = spriteList.at(i);
std::string txt = spriteList[i];
std::replace(txt.begin(), txt.end(), '_', ' ');
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
const int w = text->lenght(txt, 1);
const int h = text->getCharacterSize();
const int x = i % 2 == 0 ? firstCol : secondCol;
const int dx = -(w / 2);
const int y = sprites.at(i)->getPosY() + sprites.at(i)->getHeight() + distSpriteText;
const int y = sprites[i]->getPosY() + sprites[i]->getHeight() + distSpriteText;
// Cambia la posición del último sprite
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
@@ -536,7 +536,7 @@ void Ending2::createTexts()
for (int i = 0; i < (int)list.size(); ++i)
{
// Calcula constantes
const int w = text->lenght(list.at(i), 1);
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
@@ -547,7 +547,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i));
text->write(0, 0, list[i]);
// Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
@@ -565,7 +565,7 @@ void Ending2::createTexts()
for (int i = 0; i < (int)list.size(); ++i)
{
// Calcula constantes
const int w = text->lenght(list.at(i), 1);
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
@@ -576,7 +576,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i));
text->write(0, 0, list[i]);
// Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
@@ -624,7 +624,7 @@ void Ending2::updateFinalFade()
for (auto t : texts)
{
t->getTexture()->setColor(colors.at(index).r, colors.at(index).g, colors.at(index).b);
t->getTexture()->setColor(colors[index].r, colors[index].g, colors[index].b);
}
}

View File

@@ -39,7 +39,7 @@ private:
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
JA_Music music; // Musica que suena durante el final
JA_Music_t* music; // Musica que suena durante el final
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
std::vector<color_t> colors; // Vector con los colores para el fade
int maxSpriteWidth; // El valor de ancho del sprite mas ancho

View File

@@ -47,7 +47,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
ticksSpeed = 15;
board.lives = 9;
#ifdef DEBUG
board.lives = 0;
board.lives = 9;
#endif
board.items = 0;
board.rooms = 1;
@@ -146,7 +146,7 @@ void Game::checkEventHandler()
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
case SDL_SCANCODE_P:
case SDL_SCANCODE_H:
switchPause();
break;
@@ -256,8 +256,8 @@ void Game::render()
{
// Prepara para dibujar el frame
screen->start();
screen->clean(room->getBGColor());
// Dibuja los elementos del juego en orden
room->renderMap();
room->renderEnemies();
room->renderItems();

View File

@@ -43,13 +43,13 @@ private:
Stats *stats; // Objeto encargado de gestionar las estadísticas
// Variables
JA_Music music; // Musica que suena durante el juego
JA_Music_t* music; // Musica que suena durante el juego
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
section_t section; // Seccion actual dentro del juego
std::string currentRoom; // Fichero de la habitación actual
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador
JA_Sound_t* deathSound; // Sonido a reproducir cuando muere el jugador
board_t board; // Estructura con los datos del marcador
bool paused; // Indica si el juego se encuentra en pausa
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador

View File

@@ -198,13 +198,13 @@ void GameOver::updateColor()
// const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
color = colors.at(index);
color = colors[index];
}
else
{
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
const int index = (colors.size() - 1) * step;
color = colors.at(index);
color = colors[index];
}
}

View File

@@ -40,7 +40,7 @@ private:
int endSection; // Contador: cuando acaba la sección
int iniFade; // Contador: cuando emiepza el fade
int fadeLenght; // Contador: duración del fade
JA_Music music; // Musica que suena durante el juego
JA_Music_t* music; // Musica que suena durante el juego
// Actualiza el objeto
void update();

View File

@@ -36,16 +36,8 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
ticks = 0;
ticksSpeed = 15;
loadCounter = 0;
lineCounter = 0;
loadingFirstPart = true;
// Ls lineas que tapan la primera textura
for (int i = 0; i < 192; ++i)
{
lines[i].x1 = 0;
lines[i].x2 = 257;
lines[i].y = i;
}
loadRect = {0, 0, 51, 1};
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
for (int i = 0; i < 192; ++i)
@@ -154,25 +146,24 @@ void Intro::updateLoad()
{
// Cada 5 pasos el loadCounter se incrementa en uno
const int numSteps = 5;
const int step = 51;
loadCounter = counter / numSteps;
if (loadCounter < 192)
{
const int step = 256 / numSteps;
lines[lineIndex[loadCounter]].x1 = step * (counter % numSteps);
// Elimina por completo la linea anterior
if (loadCounter > 0)
{
lines[lineIndex[loadCounter - 1]].x1 = 256;
loadRect.x = step * (counter % numSteps);
loadRect.y = lineIndex[loadCounter];
sprite1->setSpriteClip(loadRect);
sprite1->setRect(loadRect);
}
}
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
else if (loadCounter == 192)
{
loadingFirstPart = false;
loadCounter = 0;
loadRect = {0, 0, 16, 8};
sprite2->setRect(loadRect);
sprite2->setSpriteClip(loadRect);
JA_PlayMusic(loadingSound3);
}
}
@@ -180,57 +171,36 @@ void Intro::updateLoad()
else
{
loadCounter += 2;
loadCounter = std::min(loadCounter, 768);
loadRect.x = (loadCounter * 8) % 256;
loadRect.y = (loadCounter / 32) * 8;
sprite2->setSpriteClip(loadRect);
sprite2->setRect(loadRect);
// Comprueba si ha terminado la intro
if (loadCounter >= 768)
{
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
JA_StopMusic();
}
}
}
// Gestiona el contador interno
void Intro::updateCounter()
{
if (preCounter >= 50)
{ // Si el contador previo ha llegado a 50, empieza a contar el contador normal
if (counter == 0)
(preCounter >= 50) ? counter++ : preCounter++;
if (counter == 1)
{
JA_PlayMusic(loadingSound2);
}
counter++;
}
else
{ // Actualiza el precontador
preCounter++;
}
}
// Dibuja la pantalla de carga
void Intro::renderLoad()
{
// Carga 1 - Blanco y negro
if (loadingFirstPart)
{
// Dibuja la textura de pantalla de carga en blanco y negro en pantalla
sprite1->render();
// Dibuja las 192 lineas negras sobre la textura
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
for (int i = 0; i < 192; ++i)
{
SDL_RenderDrawLine(renderer, lines[i].x1, lines[i].y, lines[i].x2, lines[i].y);
}
}
else
// Carga 2 - Color
{
sprite1->render();
SDL_Rect rect = {0, 0, 8, 8};
for (int i = 0; i < loadCounter; ++i)
{
rect.x = (i * 8) % 256;
rect.y = (i / 32) * 8;
sprite2->setRect(rect);
sprite2->setSpriteClip(rect);
sprite2->render();
}
}
loadingFirstPart ? sprite1->render() : sprite2->render();
}
// Actualiza las variables
@@ -253,14 +223,6 @@ void Intro::update()
// Actualiza las notificaciones
screen->updateNotifier();
// Comprueba si ha terminado la intro
if (loadCounter >= 768)
{
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
JA_StopMusic();
}
}
}
@@ -270,9 +232,6 @@ void Intro::render()
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean();
// Dibuja la pantalla de carga
renderLoad();

View File

@@ -38,13 +38,12 @@ private:
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
int loadCounter; // Contador para controlar las cargas
int lineCounter; // Contador para dibujar las lineas de carga
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
JA_Music loadingSound1; // Sonidos para imitar la carga tipo spectrum
JA_Music loadingSound2; // Sonidos para imitar la carga tipo spectrum
JA_Music loadingSound3; // Sonidos para imitar la carga tipo spectrum
h_line_t lines[192]; // Las 192 lineas que forman la pantalla de carga
JA_Music_t* loadingSound1; // Sonidos para imitar la carga tipo spectrum
JA_Music_t* loadingSound2; // Sonidos para imitar la carga tipo spectrum
JA_Music_t* loadingSound3; // Sonidos para imitar la carga tipo spectrum
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
SDL_Rect loadRect; // Rectangulo para dibujar la pantalla de carga
// Actualiza las variables
void update();

View File

@@ -36,7 +36,7 @@ Item::~Item()
void Item::render()
{
const int index = (counter / colorChangeSpeed) % color.size();
sprite->getTexture()->setColor(color.at(index).r, color.at(index).g, color.at(index).b);
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
sprite->render();
sprite->getTexture()->setColor(255, 255, 255);
}

View File

@@ -26,13 +26,13 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
if (i % 2 == 0)
{
sprite.at(i)->setPosX(256 + (i * 3));
sprite[i]->setPosX(256 + (i * 3));
}
else
{
sprite.at(i)->setPosX(-181 - (i * 3));
sprite[i]->setPosX(-181 - (i * 3));
}
sprite.at(i)->setPosY(83 + i);
sprite[i]->setPosY(83 + i);
}
// Inicializa variables
@@ -142,22 +142,22 @@ void Logo::updateJAILGAMES()
{
const int speed = 8;
const int dest = 37;
if (sprite.at(i)->getPosX() != 37)
if (sprite[i]->getPosX() != 37)
{
if (i % 2 == 0)
{
sprite.at(i)->incPosX(-speed);
if (sprite.at(i)->getPosX() < dest)
sprite[i]->incPosX(-speed);
if (sprite[i]->getPosX() < dest)
{
sprite.at(i)->setPosX(dest);
sprite[i]->setPosX(dest);
}
}
else
{
sprite.at(i)->incPosX(speed);
if (sprite.at(i)->getPosX() > dest)
sprite[i]->incPosX(speed);
if (sprite[i]->getPosX() > dest)
{
sprite.at(i)->setPosX(dest);
sprite[i]->setPosX(dest);
}
}
}
@@ -173,72 +173,72 @@ void Logo::updateTextureColors()
if (counter == ini + inc * 0)
{
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture2->setColor(color[0].r, color[0].g, color[0].b);
}
else if (counter == ini + inc * 1)
{
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == ini + inc * 2)
{
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == ini + inc * 3)
{
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == ini + inc * 4)
{
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == ini + inc * 5)
{
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == ini + inc * 6)
{
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture2->setColor(color[6].r, color[6].g, color[6].b);
}
else if (counter == ini + inc * 7)
{
texture2->setColor(color.at(7).r, color.at(7).g, color.at(7).b);
texture2->setColor(color[7].r, color[7].g, color[7].b);
}
else if (counter == initFade + inc * 0)
{
texture->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture->setColor(color[6].r, color[6].g, color[6].b);
texture2->setColor(color[6].r, color[6].g, color[6].b);
}
else if (counter == initFade + inc * 1)
{
texture->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture->setColor(color[5].r, color[5].g, color[5].b);
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == initFade + inc * 2)
{
texture->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture->setColor(color[4].r, color[4].g, color[4].b);
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == initFade + inc * 3)
{
texture->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture->setColor(color[3].r, color[3].g, color[3].b);
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == initFade + inc * 4)
{
texture->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture->setColor(color[2].r, color[2].g, color[2].b);
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == initFade + inc * 5)
{
texture->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture->setColor(color[1].r, color[1].g, color[1].b);
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == initFade + inc * 6)
{
texture->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture->setColor(color[0].r, color[0].g, color[0].b);
texture2->setColor(color[0].r, color[0].g, color[0].b);
}
}

View File

@@ -81,8 +81,8 @@ public:
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
int jumpIni; // Valor del eje Y en el que se inicia el salto
float maxVY; // Velocidad máxima que puede alcanzar al desplazarse en vertical
std::vector<JA_Sound> jumpSound; // Vecor con todos los sonidos del salto
std::vector<JA_Sound> fallSound; // Vecor con todos los sonidos de la caída
std::vector<JA_Sound_t*> jumpSound; // Vecor con todos los sonidos del salto
std::vector<JA_Sound_t*> fallSound; // Vecor con todos los sonidos de la caída
int jumpCounter; // Cuenta el tiempo de salto
int fallCounter; // Cuenta el tiempo de caida
bool alive; // Indica si el jugador esta vivo o no

View File

@@ -534,8 +534,9 @@ color_t Room::getBorderColor()
// Crea la textura con el mapeado de la habitación
void Room::fillMapTexture()
{
const color_t color = stringToColor(options->palette, bgColor);
SDL_SetRenderTarget(renderer, mapTexture);
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
@@ -548,13 +549,13 @@ void Room::fillMapTexture()
// Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1
// Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices)
const int index = (y * mapWidth) + x;
const bool a = (tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 19 * tileSetWidth);
const bool b = tileMap.at(index) > -1;
const bool a = (tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 19 * tileSetWidth);
const bool b = tileMap[index] > -1;
if (b && !a)
{
clip.x = (tileMap.at(index) % tileSetWidth) * tileSize;
clip.y = (tileMap.at(index) / tileSetWidth) * tileSize;
clip.x = (tileMap[index] % tileSetWidth) * tileSize;
clip.y = (tileMap[index] / tileSetWidth) * tileSize;
texture->render(renderer, x * tileSize, y * tileSize, &clip);
#ifdef DEBUG
@@ -763,37 +764,37 @@ tile_e Room::getTile(int index)
if (onRange)
{
// Las filas 0-8 son de tiles t_wall
if ((tileMap.at(index) >= 0) && (tileMap.at(index) < 9 * tileSetWidth))
if ((tileMap[index] >= 0) && (tileMap[index] < 9 * tileSetWidth))
{
return t_wall;
}
// Las filas 9-17 son de tiles t_passable
else if ((tileMap.at(index) >= 9 * tileSetWidth) && (tileMap.at(index) < 18 * tileSetWidth))
else if ((tileMap[index] >= 9 * tileSetWidth) && (tileMap[index] < 18 * tileSetWidth))
{
return t_passable;
}
// Las filas 18-20 es de tiles t_animated
else if ((tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 21 * tileSetWidth))
else if ((tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 21 * tileSetWidth))
{
return t_animated;
}
// La fila 21 es de tiles t_slope_r
else if ((tileMap.at(index) >= 21 * tileSetWidth) && (tileMap.at(index) < 22 * tileSetWidth))
else if ((tileMap[index] >= 21 * tileSetWidth) && (tileMap[index] < 22 * tileSetWidth))
{
return t_slope_r;
}
// La fila 22 es de tiles t_slope_l
else if ((tileMap.at(index) >= 22 * tileSetWidth) && (tileMap.at(index) < 23 * tileSetWidth))
else if ((tileMap[index] >= 22 * tileSetWidth) && (tileMap[index] < 23 * tileSetWidth))
{
return t_slope_l;
}
// La fila 23 es de tiles t_kill
else if ((tileMap.at(index) >= 23 * tileSetWidth) && (tileMap.at(index) < 24 * tileSetWidth))
else if ((tileMap[index] >= 23 * tileSetWidth) && (tileMap[index] < 24 * tileSetWidth))
{
return t_kill;
}
@@ -820,10 +821,10 @@ bool Room::itemCollision(SDL_Rect &rect)
{
for (int i = 0; i < (int)items.size(); ++i)
{
if (checkCollision(rect, items.at(i)->getCollider()))
if (checkCollision(rect, items[i]->getCollider()))
{
itemTracker->addItem(name, items.at(i)->getPos());
delete items.at(i);
itemTracker->addItem(name, items[i]->getPos());
delete items[i];
items.erase(items.begin() + i);
JA_PlaySound(itemSound);
*itemsPicked = *itemsPicked + 1;
@@ -955,14 +956,14 @@ void Room::setBottomSurfaces()
do
{
h_line_t line;
line.x1 = (tile.at(i) % mapWidth) * tileSize;
line.y = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
lastOne = i;
i++;
if (i <= (int)tile.size() - 1)
{
while (tile.at(i) == tile.at(i - 1) + 1)
while (tile[i] == tile[i - 1] + 1)
{
lastOne = i;
if (i == (int)tile.size() - 1)
@@ -973,11 +974,11 @@ void Room::setBottomSurfaces()
}
}
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
bottomSurfaces.push_back(line);
if (i <= (int)tile.size() - 1)
{
if (tile.at(i) == -1)
if (tile[i] == -1)
{ // Si el siguiente elemento es un separador, hay que saltarlo
i++;
}
@@ -1018,14 +1019,14 @@ void Room::setTopSurfaces()
do
{
h_line_t line;
line.x1 = (tile.at(i) % mapWidth) * tileSize;
line.y = (tile.at(i) / mapWidth) * tileSize;
line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = (tile[i] / mapWidth) * tileSize;
lastOne = i;
i++;
if (i <= (int)tile.size() - 1)
{
while (tile.at(i) == tile.at(i - 1) + 1)
while (tile[i] == tile[i - 1] + 1)
{
lastOne = i;
if (i == (int)tile.size() - 1)
@@ -1036,11 +1037,11 @@ void Room::setTopSurfaces()
}
}
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
topSurfaces.push_back(line);
if (i <= (int)tile.size() - 1)
{
if (tile.at(i) == -1)
if (tile[i] == -1)
{ // Si el siguiente elemento es un separador, hay que saltarlo
i++;
}
@@ -1080,9 +1081,9 @@ void Room::setLeftSurfaces()
do
{
v_line_t line;
line.x = (tile.at(i) % mapWidth) * tileSize;
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
while (tile.at(i) + mapWidth == tile.at(i + 1))
line.x = (tile[i] % mapWidth) * tileSize;
line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1])
{
if (i == (int)tile.size() - 1)
{
@@ -1090,7 +1091,7 @@ void Room::setLeftSurfaces()
}
i++;
}
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
leftSurfaces.push_back(line);
i++;
} while (i < (int)tile.size() - 1);
@@ -1128,9 +1129,9 @@ void Room::setRightSurfaces()
do
{
v_line_t line;
line.x = ((tile.at(i) % mapWidth) * tileSize) + tileSize - 1;
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
while (tile.at(i) + mapWidth == tile.at(i + 1))
line.x = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
line.y1 = ((tile[i] / mapWidth) * tileSize);
while (tile[i] + mapWidth == tile[i + 1])
{
if (i == (int)tile.size() - 1)
{
@@ -1138,7 +1139,7 @@ void Room::setRightSurfaces()
}
i++;
}
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
rightSurfaces.push_back(line);
i++;
} while (i < (int)tile.size() - 1);
@@ -1165,14 +1166,14 @@ void Room::setLeftSlopes()
while (found.size() > 0)
{
d_line_t line;
line.x1 = (found.at(0) % mapWidth) * tileSize;
line.y1 = (found.at(0) / mapWidth) * tileSize;
int lookingFor = found.at(0) + mapWidth + 1;
int lastOneFound = found.at(0);
line.x1 = (found[0] % mapWidth) * tileSize;
line.y1 = (found[0] / mapWidth) * tileSize;
int lookingFor = found[0] + mapWidth + 1;
int lastOneFound = found[0];
found.erase(found.begin());
for (int i = 0; i < (int)found.size(); ++i)
{
if (found.at(i) == lookingFor)
if (found[i] == lookingFor)
{
lastOneFound = lookingFor;
lookingFor += mapWidth + 1;
@@ -1206,14 +1207,14 @@ void Room::setRightSlopes()
while (found.size() > 0)
{
d_line_t line;
line.x1 = ((found.at(0) % mapWidth) * tileSize) + tileSize - 1;
line.y1 = (found.at(0) / mapWidth) * tileSize;
int lookingFor = found.at(0) + mapWidth - 1;
int lastOneFound = found.at(0);
line.x1 = ((found[0] % mapWidth) * tileSize) + tileSize - 1;
line.y1 = (found[0] / mapWidth) * tileSize;
int lookingFor = found[0] + mapWidth - 1;
int lastOneFound = found[0];
found.erase(found.begin());
for (int i = 0; i < (int)found.size(); ++i)
{
if (found.at(i) == lookingFor)
if (found[i] == lookingFor)
{
lastOneFound = lookingFor;
lookingFor += mapWidth - 1;
@@ -1256,14 +1257,14 @@ void Room::setAutoSurfaces()
do
{
h_line_t line;
line.x1 = (tile.at(i) % mapWidth) * tileSize;
line.y = (tile.at(i) / mapWidth) * tileSize;
line.x1 = (tile[i] % mapWidth) * tileSize;
line.y = (tile[i] / mapWidth) * tileSize;
lastOne = i;
i++;
if (i <= (int)tile.size() - 1)
{
while (tile.at(i) == tile.at(i - 1) + 1)
while (tile[i] == tile[i - 1] + 1)
{
lastOne = i;
if (i == (int)tile.size() - 1)
@@ -1274,11 +1275,11 @@ void Room::setAutoSurfaces()
}
}
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
autoSurfaces.push_back(line);
if (i <= (int)tile.size() - 1)
{
if (tile.at(i) == -1)
if (tile[i] == -1)
{ // Si el siguiente elemento es un separador, hay que saltarlo
i++;
}
@@ -1299,9 +1300,9 @@ void Room::setAnimatedTiles()
const int x = (i % mapWidth) * tileSize;
const int y = (i / mapWidth) * tileSize;
// TileMap.at(i) es el tile a poner
const int xc = (tileMap.at(i) % tileSetWidth) * tileSize;
const int yc = (tileMap.at(i) / tileSetWidth) * tileSize;
// TileMap[i] es el tile a poner
const int xc = (tileMap[i] % tileSetWidth) * tileSize;
const int yc = (tileMap[i] / tileSetWidth) * tileSize;
aTile_t at;
at.sprite = new Sprite(x, y, 8, 8, texture, renderer);
@@ -1532,7 +1533,7 @@ void Room::openTheJail()
// Abre las puertas
const int tileA = 16 + (13 * 32);
const int tileB = 16 + (14 * 32);
tileMap.at(tileA) = -1;
tileMap.at(tileB) = -1;
tileMap[tileA] = -1;
tileMap[tileB] = -1;
}
}

View File

@@ -104,7 +104,7 @@ private:
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
int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación
JA_Sound itemSound; // Sonido producido al coger un objeto
JA_Sound_t* itemSound; // Sonido producido al coger un objeto
std::vector<h_line_t> bottomSurfaces; // Lista con las superficies inferiores de la habitación
std::vector<h_line_t> topSurfaces; // Lista con las superficies superiores de la habitación
std::vector<v_line_t> leftSurfaces; // Lista con las superficies laterales de la parte izquierda de la habitación

View File

@@ -60,7 +60,7 @@ void Stats::addDeath(std::string name)
const int index = findByName(name, bufferList);
if (index != -1)
{
bufferList.at(index).died++;
bufferList[index].died++;
}
// En caso contrario crea la entrada
@@ -84,7 +84,7 @@ void Stats::addVisit(std::string name)
const int index = findByName(name, bufferList);
if (index != -1)
{
bufferList.at(index).visited++;
bufferList[index].visited++;
}
// En caso contrario crea la entrada
@@ -304,8 +304,8 @@ void Stats::updateListFromBuffer()
if (index != -1)
{ // Encontrado. Aumenta sus estadisticas
list.at(index).visited += buffer.visited;
list.at(index).died += buffer.died;
list[index].visited += buffer.visited;
list[index].died += buffer.died;
}
else
{ // En caso contrario crea la entrada

View File

@@ -30,7 +30,6 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
ticks = 0;
ticksSpeed = 15;
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
// longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
for (int i = 0; i < (int)longText.length(); ++i)
{
letter_t l;
@@ -39,9 +38,24 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
l.enabled = false;
letters.push_back(l);
}
letters.at(0).enabled = true;
letters[0].enabled = true;
marqueeSpeed = 3;
// Crea el cartel de PRESS ENTER
const std::string caption = "PRESS ENTER TO PLAY";
const color_t textColor = stringToColor(options->palette, "white");
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
// Crea la textura
pressEnterTexture = new Texture(renderer);
pressEnterTexture->createBlank(renderer, text->lenght(caption) + 2, text->getCharacterSize() + 2, SDL_TEXTUREACCESS_TARGET);
pressEnterTexture->setAsRenderTarget(renderer);
pressEnterTexture->setBlendMode(SDL_BLENDMODE_BLEND);
text->writeDX(TXT_COLOR | TXT_STROKE, 1, 1, caption, 1, textColor, 1, strokeColor);
// Crea el sprite
pressEnterSprite = new Sprite(128 - (pressEnterTexture->getWidth() / 2), 192 / 5 * 4, pressEnterTexture->getWidth(), pressEnterTexture->getHeight(), pressEnterTexture, renderer);
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
}
@@ -51,6 +65,8 @@ Title::~Title()
{
delete eventHandler;
delete sprite;
delete pressEnterSprite;
delete pressEnterTexture;
delete text;
}
@@ -70,6 +86,12 @@ void Title::checkEventHandler()
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
if (eventHandler->type == SDL_JOYBUTTONDOWN)
{
section.name = SECTION_PROG_GAME;
section.subsection = 0;
}
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
@@ -133,20 +155,20 @@ void Title::updateMarquee()
{
for (int i = 0; i < (int)letters.size(); ++i)
{
if (letters.at(i).enabled)
if (letters[i].enabled)
{
letters.at(i).x -= marqueeSpeed;
if (letters.at(i).x < -10)
letters[i].x -= marqueeSpeed;
if (letters[i].x < -10)
{
letters.at(i).enabled = false;
letters[i].enabled = false;
}
}
else
{
if (i > 0 && letters.at(i - 1).x < 256 && letters.at(i - 1).enabled)
if (i > 0 && letters[i - 1].x < 256 && letters[i - 1].enabled)
{
letters.at(i).enabled = true;
letters.at(i).x = letters.at(i - 1).x + text->lenght(letters.at(i - 1).letter) + 1;
letters[i].enabled = true;
letters[i].x = letters[i - 1].x + text->lenght(letters[i - 1].letter) + 1;
}
}
}
@@ -186,7 +208,7 @@ void Title::update()
screen->updateNotifier();
// Comprueba si ha terminado la marquesina y acaba con el titulo
if (letters.at(letters.size() - 1).x < -10)
if (letters[letters.size() - 1].x < -10)
{
section.name = SECTION_PROG_CREDITS;
section.subsection = 0;
@@ -200,27 +222,13 @@ void Title::render()
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean();
// Dibuja el fondo del titulo
sprite->render();
// Dibuja el texto de PRESS ENTER TO PLAY
// SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
// const SDL_Rect rect = {0, 192 / 5 * 4, 256, 8};
// SDL_RenderFillRect(renderer, &rect);
// if (counter % 80 < 60)
//{
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
//}
// Dibuja el texto de PRESS ENTER TO PLAY
if (counter % 80 < 60)
{
const color_t textColor = stringToColor(options->palette, "white");
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
pressEnterSprite->render();
}
// Dibuja la marquesina

View File

@@ -34,6 +34,8 @@ private:
Sprite *sprite; // Sprite para manejar la textura
Text *text; // Objeto para escribir texto en pantalla
options_t *options; // Puntero a las opciones del juego
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
// Variables
int counter; // Contador