Compare commits
138 Commits
v1.02
...
4a2d27dc59
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a2d27dc59 | |||
| 71be364141 | |||
| 16cc725cb3 | |||
| a05dbc7581 | |||
| 2db0b43d23 | |||
| d6c100379e | |||
| 22e8579337 | |||
| d0c0715640 | |||
| 38e0573a0e | |||
| f259fbb3a5 | |||
| 663e1ed32e | |||
| b1887fe6da | |||
| 3fcf3b23e0 | |||
| 284f7d5bad | |||
| adab0b420c | |||
| 4f9d8bec42 | |||
| 31e657d138 | |||
| 8b3d257baf | |||
| d1143b9dfe | |||
| 68ebff722e | |||
| 3be9d4459c | |||
| 76e928e21d | |||
| 9c6924d7bb | |||
| 5007bea835 | |||
| 5e7be1c2fb | |||
| faf2e69b63 | |||
| 4c3c844ccf | |||
| 48b8ae049a | |||
| c0d4eddde7 | |||
| f590101047 | |||
| c7fcbd0258 | |||
| b2061c86d2 | |||
| 510a6ca718 | |||
| ec8209265a | |||
| e963251fd9 | |||
| a2f1efd2a6 | |||
| 8959b7bcce | |||
| 4d8bb46a52 | |||
| 2abde36a5e | |||
| 0a083af712 | |||
| f322b1b81b | |||
| 13fe98edb3 | |||
| c90b49c8be | |||
| d3a5c0e54f | |||
| 254ff50ef3 | |||
| e551206351 | |||
| b22e830dac | |||
| a81d42cb25 | |||
| 3ea0025fb4 | |||
| d7c49a0578 | |||
| 4cbe55c2d4 | |||
| 564f316586 | |||
| 522ab8e726 | |||
| 4911282777 | |||
| 06ecabc676 | |||
| 5d89a3057e | |||
| 75228cc451 | |||
| 357eec20b1 | |||
| 62c1e2715e | |||
| 34fc2b6b06 | |||
| 6557dea2bb | |||
| 2caea7ba6e | |||
| d33d2e4a09 | |||
| d9174dcdb9 | |||
| 22f7204e08 | |||
| 06fab0d457 | |||
| f180f88068 | |||
| 4109d6c938 | |||
| 9c2264ca75 | |||
| c59739c7ba | |||
| 4a430c0d5b | |||
| 5a7f637f4b | |||
| c63298b555 | |||
| 82aa91bead | |||
| f4129e109a | |||
| 5e8714697d | |||
| dd4355051f | |||
| 160b212a43 | |||
| 69d3b076d7 | |||
| 3817a01712 | |||
| ba19dcb904 | |||
| b035b92ff4 | |||
| 8c425f5698 | |||
| d382bb6403 | |||
| da64a5e082 | |||
| 7070dac482 | |||
| ea5360ea74 | |||
| 3aa4440390 | |||
| ce105e252e | |||
| 1aac5b7719 | |||
| a8b467290f | |||
| 706ad6f9c0 | |||
| 54d428ed96 | |||
| c71adfbac4 | |||
| c955543d31 | |||
| fae8e2d82c | |||
| ff7b825cbb | |||
| 09ed0105e9 | |||
| 07ae93fd3a | |||
| 72fb30b927 | |||
| 8d37f31a08 | |||
| e6fb412c4d | |||
| 10c29eb547 | |||
| 1f9e36dc93 | |||
| c114884de1 | |||
| d6a366555d | |||
| fd0d8a05fe | |||
| 79d610a7d9 | |||
| 9060e1c92a | |||
| 0d586c0827 | |||
| fd0bebf533 | |||
| 2665b93b70 | |||
| c35be7d21c | |||
| bc84968b23 | |||
| 1b49097f80 | |||
| 859e3f3b44 | |||
| 3fa7657c79 | |||
| e90c61a416 | |||
| d003b51de4 | |||
| 8d381010c8 | |||
| 2216c9632e | |||
| fdc8797d2b | |||
| 90bdad7d51 | |||
| d50b193d9f | |||
| ee885d5ca7 | |||
| bb3a0f263b | |||
| 85d6c48f42 | |||
| 896dd9daef | |||
| dc8c0c9e4f | |||
| 7af0dda1a0 | |||
| 0adf8c63f4 | |||
| d33f691743 | |||
| a304f50e93 | |||
| 496bf5c05c | |||
| 26a6bd6b1f | |||
| c48dce8634 | |||
| a0de547370 | |||
| 5af554fecd |
7
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
.vscode
|
.vscode
|
||||||
*config.txt
|
*data/config/config.txt
|
||||||
|
*stats.txt
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
thumbs.db
|
thumbs.db
|
||||||
*.exe
|
*.exe
|
||||||
@@ -9,4 +10,6 @@ thumbs.db
|
|||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.zip
|
*.zip
|
||||||
*.app
|
*.app
|
||||||
*_debug
|
*_debug*
|
||||||
|
sync_jail_engine.sh
|
||||||
|
jaildoctors_dilemma*
|
||||||
89
Makefile
@@ -1,8 +1,8 @@
|
|||||||
executable = jaildoctors_dilemma
|
executable = jaildoctors_dilemma
|
||||||
source = source/*.cpp source/common/*.cpp
|
source = source/*.cpp source/jail_engine/*.cpp
|
||||||
appName = JailDoctor's Dilemma
|
appName = JailDoctor's Dilemma
|
||||||
releaseFolder = jdd_release
|
releaseFolder = jdd_release
|
||||||
version = v1.02
|
version = v1.08
|
||||||
|
|
||||||
# Release names
|
# Release names
|
||||||
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
||||||
@@ -12,34 +12,33 @@ linuxRelease = $(executable)-$(version)-linux.tar.gz
|
|||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
powershell if (Test-Path data\config) {Remove-Item data\config -Recurse -Force}
|
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 "$(executable).exe"
|
||||||
powershell if (-not (Test-Path data\config)) {New-Item data\config -ItemType Directory}
|
strip -s -R .comment -R .gnu.version "$(executable).exe" --strip-unneeded
|
||||||
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o $(executable).exe
|
|
||||||
strip -s -R .comment -R .gnu.version $(executable).exe --strip-unneeded
|
windows_debug:
|
||||||
|
@echo off
|
||||||
|
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
|
||||||
|
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
|
||||||
|
|
||||||
windows_release:
|
windows_release:
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
# Remove data
|
# Create release folder
|
||||||
powershell if (Test-Path data\config) {Remove-Item data\config -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
||||||
powershell if (Test-Path $(releaseFolder)) {Remove-Item $(releaseFolder) -Recurse -Force}
|
powershell if (-not (Test-Path "$(releaseFolder)")) {New-Item "$(releaseFolder)" -ItemType Directory}
|
||||||
|
|
||||||
# Create folders
|
# Prepare data folder
|
||||||
powershell if (-not (Test-Path data\config)) {New-Item data\config -ItemType Directory}
|
|
||||||
powershell if (-not (Test-Path $(releaseFolder))) {New-Item $(releaseFolder) -ItemType Directory}
|
|
||||||
|
|
||||||
# Copy data
|
|
||||||
powershell Copy-Item -Path "data" -Destination "$(releaseFolder)" -recurse -Force
|
powershell Copy-Item -Path "data" -Destination "$(releaseFolder)" -recurse -Force
|
||||||
powershell Copy-Item "LICENSE" -Destination "$(releaseFolder)"
|
|
||||||
powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
|
|
||||||
powershell Copy-Item "release/SDL2.dll" -Destination "$(releaseFolder)"
|
|
||||||
|
|
||||||
# Remove data
|
|
||||||
powershell if (Test-Path "$(releaseFolder)\data\room\map.world") {Remove-Item "$(releaseFolder)\data\room\map.world" -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)\data\room\map.world") {Remove-Item "$(releaseFolder)\data\room\map.world" -Recurse -Force}
|
||||||
powershell if (Test-Path "$(releaseFolder)\data\room\standard.tsx") {Remove-Item "$(releaseFolder)\data\room\standard.tsx" -Recurse -Force}
|
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.txt" -Destination "$(releaseFolder)"
|
||||||
|
powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
|
||||||
|
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
|
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"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
||||||
|
|
||||||
# Create ZIP
|
# Create ZIP
|
||||||
@@ -47,16 +46,16 @@ windows_release:
|
|||||||
powershell Compress-Archive -Path "$(releaseFolder)"/* -DestinationPath $(windowsRelease)
|
powershell Compress-Archive -Path "$(releaseFolder)"/* -DestinationPath $(windowsRelease)
|
||||||
|
|
||||||
# Remove folder
|
# Remove folder
|
||||||
powershell if (Test-Path $(releaseFolder)) {Remove-Item $(releaseFolder) -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
rm -rdf data/config
|
clang++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
||||||
mkdir -p data/config
|
|
||||||
clang++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o $(executable)_macos
|
macos_debug:
|
||||||
|
clang++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
# Remove data and possible data
|
# Remove data and possible data from previous builds
|
||||||
rm -rdf data/config
|
|
||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
rm -rdf Frameworks
|
rm -rdf Frameworks
|
||||||
rm -f tmp.dmg
|
rm -f tmp.dmg
|
||||||
@@ -64,7 +63,6 @@ macos_release:
|
|||||||
rm -f "$(macosAppleSiliconRelease)"
|
rm -f "$(macosAppleSiliconRelease)"
|
||||||
|
|
||||||
# Create folders
|
# Create folders
|
||||||
mkdir -p data/config
|
|
||||||
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Frameworks"
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Frameworks"
|
||||||
mkdir -p "$(releaseFolder)/$(appName).app/Contents/MacOS"
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/MacOS"
|
||||||
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Resources"
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Resources"
|
||||||
@@ -82,6 +80,11 @@ macos_release:
|
|||||||
# Copy files
|
# Copy files
|
||||||
cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources"
|
cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources"
|
||||||
cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents"
|
cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents"
|
||||||
|
cp LICENSE.txt "$(releaseFolder)"
|
||||||
|
cp README.md "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Create links
|
||||||
|
ln -s /Applications "$(releaseFolder)"/Applications
|
||||||
|
|
||||||
# Build INTEL
|
# 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
|
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
|
||||||
@@ -104,36 +107,36 @@ macos_release:
|
|||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
rm -rdf data/config
|
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
||||||
mkdir -p data/config
|
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
||||||
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o $(executable)_linux
|
|
||||||
strip -s -R .comment -R .gnu.version $(executable)_linux --strip-unneeded
|
linux_debug:
|
||||||
|
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
||||||
|
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
# Remove data
|
# Remove data
|
||||||
rm -rdf data/config
|
rm -rdf "$(releaseFolder)"
|
||||||
rm -rdf $(releaseFolder)
|
|
||||||
|
|
||||||
# Create folders
|
# Create folders
|
||||||
mkdir -p data/config
|
mkdir -p "$(releaseFolder)"
|
||||||
mkdir -p $(releaseFolder)
|
|
||||||
|
|
||||||
# Copy data
|
# Copy data
|
||||||
cp -R data $(releaseFolder)
|
cp -R data "$(releaseFolder)"
|
||||||
cp LICENSE $(releaseFolder)
|
cp LICENSE.txt "$(releaseFolder)"
|
||||||
cp README.md $(releaseFolder)
|
cp README.md "$(releaseFolder)"
|
||||||
|
|
||||||
# Delete data
|
# Delete data
|
||||||
rm -f "$(releaseFolder)/data/room/map.world"
|
rm -f "$(releaseFolder)/data/room/map.world"
|
||||||
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o $(releaseFolder)/$(executable)
|
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version $(releaseFolder)/$(executable) --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
||||||
|
|
||||||
# Pack files
|
# Pack files
|
||||||
rm -f $(linuxRelease)
|
rm -f "$(linuxRelease)"
|
||||||
cd $(releaseFolder) && tar -czvf ../$(linuxRelease) *
|
cd "$(releaseFolder)" && tar -czvf "../$(linuxRelease)" *
|
||||||
|
|
||||||
# Remove data
|
# Remove data
|
||||||
rm -rdf $(releaseFolder)
|
rm -rdf "$(releaseFolder)"
|
||||||
66
README.md
@@ -1,37 +1,87 @@
|
|||||||
# JailDoctor's Dilemma
|
# JailDoctor's Dilemma (v1.08)
|
||||||
|
|
||||||
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JailDoc es un Jailer destacado entre los Jailers. Tiene más proyectos empezados que nadie y es el que más ayuda a que los demas empiecen los suyos.
|
JailDoc es un Jailer destacado entre los Jailers. Tiene más proyectos empezados que nadie y es el que más ayuda a que los demas empiecen los suyos.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Un día, ocurrió algo. Alguien terminó un proyecto. Alguien liberó el *Puzzle Jail Facker*. Algún desaprensivo.
|
Un día, ocurrió algo. Alguien terminó un proyecto. Alguien liberó el *Puzzle Jail Facker*. Algún desaprensivo.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Esto hizo que JailDoc decidiera terminar y entregar uno de sus proyectos, pero, ¿cual? ¿JailBattle? ¿Sigmasuá? ¿Calculín Doom? Menudo dilema. JailDoc se arremangó y decidió finalizar y entregar todos sus proyectos inacabados. ¿Lo logrará?
|
Esto hizo que JailDoc decidiera terminar y entregar uno de sus proyectos, pero, ¿cual? ¿JailBattle? ¿Sigmasuá? ¿Calculín Doom? Menudo dilema. JailDoc se arremangó y decidió finalizar y entregar todos sus proyectos inacabados. ¿Lo logrará?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Jugabilidad
|
## Jugabilidad
|
||||||
|
|
||||||
Ayuda a JailDoc a recuperar las partes de su proyecto que estan desperdigadas por cualquier lugar del Universo Jailer. Hay mas de **150 piezas** desperdigadas por **60 pantallas**. Algunas son un paseo, pero en otras tendras que calcular muy bien tus movimientos si no quieres acabar como un arounder del montón.
|
Ayuda a JailDoc a recuperar las partes de su proyecto que estan desperdigadas por cualquier lugar del Universo Jailer. Hay mas de **150 piezas** desperdigadas por **60 pantallas**. Algunas son un paseo, pero en otras tendras que calcular muy bien tus movimientos si no quieres acabar como un arounder del montón.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Cuando consigas recuperar gran parte de las piezas desperdigadas, dirigete a la Jail a mostrar a los Jailers como se termina un proyecto. Ten en cuenta que Bry no te dejará entrar. Solo aquellos que han realizado un *Fire Effect* o un *Facedor de Tornejos* son dignos de tal privilegio.
|
Cuando consigas recuperar gran parte de las piezas desperdigadas, dirigete a la Jail a mostrar a los Jailers como se termina un proyecto. Ten en cuenta que Bry no te dejará entrar. Solo aquellos que han realizado un *Fire Effect* o un *Facedor de Tornejos* son dignos de tal privilegio.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Controles
|
## Controles
|
||||||
|
|
||||||
El juego permite tanto el uso del teclado como de un mando de control. Las teclas para manejar el juego son las siguientes:
|
El juego permite tanto el uso del teclado como de un mando de control. Las teclas para manejar el juego son las siguientes:
|
||||||
|
|
||||||
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar
|
|
||||||
- **Tecla M**: Activa o desactiva la música
|
|
||||||
- **Tecla P**: Pone en pausa el juego
|
- **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 ESC**: Sale del juego si estas jugando. Sale del programa en cualquier otra circunstancia
|
|
||||||
- **Tecla F**: Cambia a modo de pantalla completa o de ventana
|
- **Tecla M**: Activa o desactiva la música
|
||||||
- **Teclas F1 a F4**: Cambian el tamaño de la ventana
|
|
||||||
- **Tecla B**: Activa o desactiva el borde de colores de la pantalla cuando el programa se ejecuta en modo de ventana
|
- **Tecla P**: Pone en pausa el juego
|
||||||
|
|
||||||
|
- **Tecla ESC**: Sale del juego si estas jugando. Sale del programa en cualquier otra circunstancia
|
||||||
|
|
||||||
|
- **Tecla F**: Cambia a modo de pantalla completa o de ventana
|
||||||
|
|
||||||
|
- **Teclas F1 a F4**: Cambian el tamaño de la ventana
|
||||||
|
|
||||||
|
- **Tecla B**: Activa o desactiva el borde de colores de la pantalla cuando el programa se ejecuta en modo de ventana
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Datos del programa
|
||||||
|
El programa guarda automáticamente la configuración del modo de video y las estadísticas de juego en tu carpeta personal del sistema. Esta carpeta tiene una ubicación distinta en función del sistema operativo que utilices.
|
||||||
|
|
||||||
|
En **Windows** se encuentra en:
|
||||||
|
`C:\Users\<nombre_de_usuario>\AppData\Roaming\jaildoctors_dilemma`
|
||||||
|
|
||||||
|
En **MacOS** se encuentra en:
|
||||||
|
`~/Library/Application Support/jaildoctors_dilemma`
|
||||||
|
|
||||||
|
En **Linux** se encuentra en:
|
||||||
|
`~/.jaildoctors_dilemma`
|
||||||
|
|
||||||
|
La primera vez, el juego te pregunta por tu identificador online. Esta información se guarda para futuras partidas.
|
||||||
|
|
||||||
|
En la carpeta está el fichero de configuración `config.txt` donde se puede modificar la configuración para conectarse al servicio online y los ficheros `stats.csv` y `stats_buffer.csv` con información de las estadisticas de juego.
|
||||||
|
|
||||||
## Agradecimientos
|
## Agradecimientos
|
||||||
|
|
||||||
Agradecimientos como siempre a todos los Jailers por motivarme a hacer el juego y ayudarme en los momentos de duda a la hora de escribir el código. Y, como siempre, en especial a JailDoc por su unidad de Jail_Audio y cualquier otro código/ayuda/enseñanzas que haya necesitado para terminar el programa.
|
Agradecimientos como siempre a todos los Jailers por motivarme a hacer el juego y ayudarme en los momentos de duda a la hora de escribir el código. Y, como siempre, en especial a JailDoc por su unidad de Jail_Audio y cualquier otro código/ayuda/enseñanzas que haya necesitado para terminar el programa.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Si no me he descontado, este es el cuarto juego que consigo crear.
|
Si no me he descontado, este es el cuarto juego que consigo crear.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*13 de noviembre de 2022, JailDesigner*
|
*13 de noviembre de 2022, JailDesigner*
|
||||||
|
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
|
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B |
|
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
|
Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 323 B |
|
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
@@ -3,7 +3,7 @@ frameHeight=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=8
|
speed=4
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3
|
frames=0,1,2,3,4,5,6,7
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 139 B |
|
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 129 B |
BIN
data/notifications/notify.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
@@ -9,8 +9,8 @@ roomLeft=0
|
|||||||
roomRight=02.room
|
roomRight=02.room
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jailer.png
|
tileSetFile=jailer_#1.png
|
||||||
animation=jailer.ani
|
animation=jailer_#1.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=1
|
x=1
|
||||||
@@ -25,8 +25,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jailer3.png
|
tileSetFile=jailer_#3.png
|
||||||
animation=jailer3.ani
|
animation=jailer_#3.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=4
|
x=4
|
||||||
@@ -41,8 +41,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jailer.png
|
tileSetFile=jailer_#1.png
|
||||||
animation=jailer.ani
|
animation=jailer_#1.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=7
|
x=7
|
||||||
@@ -57,8 +57,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jailer2.png
|
tileSetFile=jailer_#2.png
|
||||||
animation=jailer2.ani
|
animation=jailer_#2.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=10
|
x=10
|
||||||
@@ -73,8 +73,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jailer.png
|
tileSetFile=jailer_#1.png
|
||||||
animation=jailer.ani
|
animation=jailer_#1.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=13
|
x=13
|
||||||
@@ -89,8 +89,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=printer.png
|
tileSetFile=elsa.png
|
||||||
animation=printer.ani
|
animation=elsa.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=3
|
x=3
|
||||||
@@ -105,8 +105,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=printer.png
|
tileSetFile=elsa.png
|
||||||
animation=printer.ani
|
animation=elsa.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=6
|
x=6
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,
|
168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,43,43,43,43,43,43,43,43,43,43,43,43,43,43,166,
|
||||||
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
211,181,211,213,211,181,211,212,213,211,181,211,211,212,211,213,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=ROAD TO THE JAIL
|
name=ROAD TO THE JAIL
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=cyan
|
border=blue
|
||||||
tileMapFile=02.tmx
|
tileMapFile=02.tmx
|
||||||
tileSetFile=standard.png
|
tileSetFile=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
|
|||||||
@@ -3,22 +3,22 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,43,43,43,43,43,
|
||||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
43,166,166,167,168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,166,185,167,166,166,166,185,25,25,25,25,
|
||||||
43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
43,43,211,212,212,211,181,211,213,211,181,211,212,213,211,181,211,211,211,211,212,213,211,181,211,213,181,211,135,0,0,0,
|
||||||
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,0,0,0,
|
||||||
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
43,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,
|
||||||
34,34,304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
|
34,34,304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,0,413,413,413,413,0,0,0,0,413,413,413,413,413,0,0,0,0,413,413,413,413,413,413,413,0,0,0,25,25,
|
34,34,0,413,413,413,413,0,0,0,0,413,304,413,413,413,0,0,0,0,413,304,413,413,413,413,304,0,0,0,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
|
||||||
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,
|
||||||
34,34,389,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
|
34,34,413,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,513,190,189,190,537,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,524,189,191,548,0,0,0,0,
|
||||||
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,190,25,25
|
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,191,25,25
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
</map>
|
</map>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=bright_green
|
|||||||
itemColor2=green
|
itemColor2=green
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=15
|
x=15
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
|
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
|
||||||
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,387,25,
|
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,25,
|
||||||
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
|
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
|
||||||
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
|
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -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,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,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,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>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
</map>
|
</map>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=red
|
|||||||
itemColor2=magenta
|
itemColor2=magenta
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=9
|
x=9
|
||||||
@@ -27,8 +27,8 @@ color=green
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=1
|
x=1
|
||||||
|
|||||||
@@ -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,0,0,0,0,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,
|
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,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,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,
|
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,
|
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,0,0,
|
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,0,
|
0,0,0,0,0,0,0,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,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,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,
|
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,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
|
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
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ animation=tuno.ani
|
|||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=28
|
x=28
|
||||||
y=8
|
y=6
|
||||||
vx=0
|
vx=0
|
||||||
vy=0.4
|
vy=-0.4
|
||||||
x1=28
|
x1=28
|
||||||
y1=2
|
y1=2
|
||||||
x2=28
|
x2=28
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ flip=true
|
|||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=bat.png
|
tileSetFile=bat.png
|
||||||
animation=bat.ani
|
animation=bat.ani
|
||||||
width=9
|
width=8
|
||||||
height=7
|
height=7
|
||||||
x=14
|
x=14
|
||||||
y=2
|
y=2
|
||||||
@@ -46,7 +46,7 @@ color=bright_blue
|
|||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=bat.png
|
tileSetFile=bat.png
|
||||||
animation=bat.ani
|
animation=bat.ani
|
||||||
width=9
|
width=8
|
||||||
height=7
|
height=7
|
||||||
x=10
|
x=10
|
||||||
y=10
|
y=10
|
||||||
@@ -62,7 +62,7 @@ color=cyan
|
|||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=bat.png
|
tileSetFile=bat.png
|
||||||
animation=bat.ani
|
animation=bat.ani
|
||||||
width=9
|
width=8
|
||||||
height=7
|
height=7
|
||||||
x=15
|
x=15
|
||||||
y=1
|
y=1
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=yellow
|
|||||||
itemColor2=red
|
itemColor2=red
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=5
|
x=5
|
||||||
@@ -27,8 +27,8 @@ color=green
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=12
|
x=12
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
5,5,5,5,5,5,5,5,5,5,5,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
5,5,5,5,5,5,5,5,0,0,0,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||||
5,5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
5,5,5,5,5,5,5,0,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,173,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
557,557,557,557,557,557,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
|
5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
|
||||||
5,5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
5,5,5,5,5,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
|
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,0,
|
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,188,
|
||||||
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
|
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
|
||||||
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
|
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
|
||||||
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,
|
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ roomLeft=26.room
|
|||||||
roomRight=0
|
roomRight=0
|
||||||
|
|
||||||
#[enemy]
|
#[enemy]
|
||||||
#tileSetFile=diskette.png
|
#tileSetFile=floppy.png
|
||||||
#animation=diskette.ani
|
#animation=floppy.ani
|
||||||
#width=16
|
#width=16
|
||||||
#height=16
|
#height=16
|
||||||
#x=2
|
#x=2
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,41,235,235,0,0,235,235,41,89,90,89,
|
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,94,41,235,235,0,0,235,235,41,89,90,89,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,
|
89,94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,215,0,0,0,0,0,0,0,0,214,89,90,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,
|
214,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,89,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,214,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
|
||||||
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
|
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
|
||||||
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
|
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
|
||||||
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=green
|
|||||||
itemColor2=red
|
itemColor2=red
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=20
|
x=20
|
||||||
|
|||||||
@@ -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,
|
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,
|
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,
|
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,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,
|
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
|
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
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name=STATIC
|
name=BE CAREFUL WITH THE FUSE
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=bright_cyan
|
border=bright_cyan
|
||||||
tileMapFile=36.tmx
|
tileMapFile=36.tmx
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ roomLeft=39.room
|
|||||||
roomRight=37.room
|
roomRight=37.room
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_stop.png
|
tileSetFile=stopped_arounder.png
|
||||||
animation=arounder_stop.ani
|
animation=stopped_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=8
|
height=8
|
||||||
x=9
|
x=9
|
||||||
@@ -25,8 +25,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_stop.png
|
tileSetFile=stopped_arounder.png
|
||||||
animation=arounder_stop.ani
|
animation=stopped_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=8
|
height=8
|
||||||
x=18
|
x=18
|
||||||
@@ -41,8 +41,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=12
|
x=12
|
||||||
@@ -75,8 +75,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_fly.png
|
tileSetFile=flying_arounder.png
|
||||||
animation=arounder_fly.ani
|
animation=flying_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=7
|
height=7
|
||||||
x=3
|
x=3
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ color=white
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_fly.png
|
tileSetFile=flying_arounder.png
|
||||||
animation=arounder_fly.ani
|
animation=flying_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=7
|
height=7
|
||||||
x=9
|
x=9
|
||||||
@@ -44,8 +44,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_fly.png
|
tileSetFile=flying_arounder.png
|
||||||
animation=arounder_fly.ani
|
animation=flying_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=7
|
height=7
|
||||||
x=15
|
x=15
|
||||||
@@ -61,8 +61,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_fly.png
|
tileSetFile=flying_arounder.png
|
||||||
animation=arounder_fly.ani
|
animation=flying_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=7
|
height=7
|
||||||
x=22
|
x=22
|
||||||
@@ -78,8 +78,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_fly.png
|
tileSetFile=flying_arounder.png
|
||||||
animation=arounder_fly.ani
|
animation=flying_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=7
|
height=7
|
||||||
x=16
|
x=16
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ color=red
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=10
|
x=10
|
||||||
@@ -42,8 +42,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=15
|
x=15
|
||||||
@@ -59,8 +59,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=20
|
x=20
|
||||||
@@ -76,8 +76,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=14
|
x=14
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ color=bright_cyan
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_stop.png
|
tileSetFile=stopped_arounder.png
|
||||||
animation=arounder_stop.ani
|
animation=stopped_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=8
|
height=8
|
||||||
x=8
|
x=8
|
||||||
@@ -41,8 +41,8 @@ color=bright_cyan
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_stop.png
|
tileSetFile=stopped_arounder.png
|
||||||
animation=arounder_stop.ani
|
animation=stopped_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=8
|
height=8
|
||||||
x=11
|
x=11
|
||||||
@@ -57,8 +57,8 @@ color=bright_cyan
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_stop.png
|
tileSetFile=stopped_arounder.png
|
||||||
animation=arounder_stop.ani
|
animation=stopped_arounder.ani
|
||||||
width=7
|
width=7
|
||||||
height=8
|
height=8
|
||||||
x=24
|
x=24
|
||||||
@@ -73,8 +73,8 @@ color=bright_cyan
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=12
|
x=12
|
||||||
@@ -90,8 +90,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=14
|
x=14
|
||||||
@@ -107,8 +107,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=arounder_walk.png
|
tileSetFile=walking_arounder.png
|
||||||
animation=arounder_walk.ani
|
animation=walking_arounder.ani
|
||||||
width=5
|
width=5
|
||||||
height=8
|
height=8
|
||||||
x=14
|
x=14
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=P.A.C.O. ON THE GO
|
name=P.A.C.O. ON THE GO
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=black
|
border=blue
|
||||||
tileMapFile=42.tmx
|
tileMapFile=42.tmx
|
||||||
tileSetFile=standard.png
|
tileSetFile=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
@@ -23,7 +23,7 @@ x1=10
|
|||||||
y1=2
|
y1=2
|
||||||
x2=10
|
x2=10
|
||||||
y2=11
|
y2=11
|
||||||
color=green
|
color=magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,421,62,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,421,62,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,305,0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,306,0,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ itemColor1=red
|
|||||||
itemColor2=magenta
|
itemColor2=magenta
|
||||||
autoSurface=left
|
autoSurface=left
|
||||||
|
|
||||||
|
[enemy]
|
||||||
|
tileSetFile=batman_fire.png
|
||||||
|
animation=batman_fire.ani
|
||||||
|
width=16
|
||||||
|
height=16
|
||||||
|
x=10
|
||||||
|
y=13
|
||||||
|
vx=1.3
|
||||||
|
vy=0
|
||||||
|
x1=0
|
||||||
|
y1=13
|
||||||
|
x2=29
|
||||||
|
y2=13
|
||||||
|
color=cyan
|
||||||
|
flip=true
|
||||||
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=heavy.png
|
tileSetFile=heavy.png
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=red
|
|||||||
itemColor2=yellow
|
itemColor2=yellow
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_alien.png
|
tileSetFile=jailbattle_alien.png
|
||||||
animation=jb_alien.ani
|
animation=jailbattle_alien.ani
|
||||||
width=13
|
width=13
|
||||||
height=15
|
height=15
|
||||||
x=10
|
x=10
|
||||||
@@ -28,8 +28,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_alien.png
|
tileSetFile=jailbattle_alien.png
|
||||||
animation=jb_alien.ani
|
animation=jailbattle_alien.ani
|
||||||
width=13
|
width=13
|
||||||
height=15
|
height=15
|
||||||
x=25
|
x=25
|
||||||
@@ -45,8 +45,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_human.png
|
tileSetFile=jailbattle_human.png
|
||||||
animation=jb_human.ani
|
animation=jailbattle_human.ani
|
||||||
width=11
|
width=11
|
||||||
height=13
|
height=13
|
||||||
x=7
|
x=7
|
||||||
@@ -62,8 +62,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_human.png
|
tileSetFile=jailbattle_human.png
|
||||||
animation=jb_human.ani
|
animation=jailbattle_human.ani
|
||||||
width=11
|
width=11
|
||||||
height=13
|
height=13
|
||||||
x=18
|
x=18
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ itemColor1=white
|
|||||||
itemColor2=green
|
itemColor2=green
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_human.png
|
tileSetFile=jailbattle_human.png
|
||||||
animation=jb_human.ani
|
animation=jailbattle_human.ani
|
||||||
width=11
|
width=11
|
||||||
height=13
|
height=13
|
||||||
x=17
|
x=17
|
||||||
@@ -28,8 +28,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_human.png
|
tileSetFile=jailbattle_human.png
|
||||||
animation=jb_human.ani
|
animation=jailbattle_human.ani
|
||||||
width=11
|
width=11
|
||||||
height=13
|
height=13
|
||||||
x=2
|
x=2
|
||||||
@@ -45,8 +45,8 @@ flip=true
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=jb_alien.png
|
tileSetFile=jailbattle_alien.png
|
||||||
animation=jb_alien.ani
|
animation=jailbattle_alien.ani
|
||||||
width=11
|
width=11
|
||||||
height=13
|
height=13
|
||||||
x=24
|
x=24
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ roomLeft=0
|
|||||||
roomRight=49.room
|
roomRight=49.room
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=7
|
x=7
|
||||||
@@ -25,8 +25,8 @@ color=magenta
|
|||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=diskette.png
|
tileSetFile=floppy.png
|
||||||
animation=diskette.ani
|
animation=floppy.ani
|
||||||
width=16
|
width=16
|
||||||
height=16
|
height=16
|
||||||
x=20
|
x=20
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
|
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
||||||
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name=P.A.C.O WORKSHOP
|
name=P.A.C.O. WORKSHOP
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=yellow
|
border=yellow
|
||||||
tileMapFile=53.tmx
|
tileMapFile=53.tmx
|
||||||
|
|||||||
BIN
data/sound/notify.wav
Normal file
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 6.5 KiB |
@@ -23,11 +23,11 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.4.3</string>
|
<string>1.0.8</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0.0</string>
|
<string>1.0.8</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
BIN
release/libgcc_s_seh-1.dll
Normal file
BIN
release/libstdc++-6.dll
Normal file
BIN
release/libwinpthread-1.dll
Normal file
267
source/cheevos.cpp
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
#include "cheevos.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Cheevos::Cheevos(Screen *screen, options_t *options, string file)
|
||||||
|
{
|
||||||
|
// Copia la dirección de los objetos
|
||||||
|
this->options = options;
|
||||||
|
this->screen = screen;
|
||||||
|
this->file = file;
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
init();
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
enabled = true;
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
loadFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Cheevos::~Cheevos()
|
||||||
|
{
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
saveToFile();
|
||||||
|
|
||||||
|
cheevos.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void Cheevos::init()
|
||||||
|
{
|
||||||
|
cheevos_t c;
|
||||||
|
c.completed = false;
|
||||||
|
c.valid = true;
|
||||||
|
c.icon = 2;
|
||||||
|
|
||||||
|
c.id = 1;
|
||||||
|
c.caption = "SHINY THINGS";
|
||||||
|
c.description = "Get 25\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 2;
|
||||||
|
c.caption = "HALF THE WORK";
|
||||||
|
c.description = "Get 50\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 3;
|
||||||
|
c.caption = "GETTING THERE";
|
||||||
|
c.description = "Get 75\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 4;
|
||||||
|
c.caption = "THE COLLECTOR";
|
||||||
|
c.description = "Get 100\% of the items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 5;
|
||||||
|
c.caption = "WANDERING AROUND";
|
||||||
|
c.description = "Visit 20 rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 6;
|
||||||
|
c.caption = "I GOT LOST";
|
||||||
|
c.description = "Visit 40 rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 7;
|
||||||
|
c.caption = "I LIKE TO EXPLORE";
|
||||||
|
c.description = "Visit all rooms";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 8;
|
||||||
|
c.caption = "FINISH THE GAME";
|
||||||
|
c.description = "Complete the game";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 9;
|
||||||
|
c.caption = "I WAS SUCKED BY A HOLE";
|
||||||
|
c.description = "Complete the game without entering the jail";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 10;
|
||||||
|
c.caption = "MY LITTLE PROJECTS";
|
||||||
|
c.description = "Complete the game with all items";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 11;
|
||||||
|
c.caption = "I LIKE MY MULTICOLOURED FRIENDS";
|
||||||
|
c.description = "Complete the game without dying";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
|
||||||
|
c.id = 12;
|
||||||
|
c.caption = "SHIT PROJECTS DONE FAST";
|
||||||
|
c.description = "Complete the game in under 30 minutes";
|
||||||
|
cheevos.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el indice
|
||||||
|
int Cheevos::find(int id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
if (cheevos[i].id == id)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void Cheevos::unlock(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cheevos[index].valid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cheevos[index].completed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheevos[index].completed = true;
|
||||||
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
|
||||||
|
saveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void Cheevos::invalidate(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cheevos[index].valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Habilita o deshabilita los logros
|
||||||
|
void Cheevos::enable(bool value)
|
||||||
|
{
|
||||||
|
enabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void Cheevos::loadFromFile()
|
||||||
|
{
|
||||||
|
// Open file for reading in binary
|
||||||
|
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "r+b");
|
||||||
|
|
||||||
|
// El fichero no existe
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Warning: Unable to open file! SDL Error: " << SDL_GetError() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea el fichero en modo escritura
|
||||||
|
file = SDL_RWFromFile(this->file.c_str(), "w+b");
|
||||||
|
|
||||||
|
if (file != NULL)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "New file created!" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda la información
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Error: Unable to create file! SDL Error: " << SDL_GetError() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// El fichero existe
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Carga los datos
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Reading file...!" << endl;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWread(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
void Cheevos::saveToFile()
|
||||||
|
{
|
||||||
|
// Abre el fichero en modo escritura
|
||||||
|
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "w+b");
|
||||||
|
if (file != NULL)
|
||||||
|
{
|
||||||
|
// Guarda la información
|
||||||
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Error: Unable to save file! " << SDL_GetError() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lista los logros
|
||||||
|
vector<cheevos_t> Cheevos::list()
|
||||||
|
{
|
||||||
|
return cheevos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve el número total de logros desbloqueados
|
||||||
|
int Cheevos::unlocked()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (auto cheevo : cheevos)
|
||||||
|
{
|
||||||
|
if (cheevo.completed)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve el número total de logros
|
||||||
|
int Cheevos::count()
|
||||||
|
{
|
||||||
|
return cheevos.size();
|
||||||
|
}
|
||||||
73
source/cheevos.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "jail_engine/screen.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef CHEEVOS_H
|
||||||
|
#define CHEEVOS_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
struct cheevos_t
|
||||||
|
{
|
||||||
|
int id; // Identificador del logro
|
||||||
|
string caption; // Texto con el nombre del logro
|
||||||
|
string description; // Texto que describe el logro
|
||||||
|
int icon; // Indice del icono a utilizar en la notificación
|
||||||
|
bool completed; // Indica si se ha obtenido el logro
|
||||||
|
bool valid; // Indica si se puede obtener el logro
|
||||||
|
};
|
||||||
|
|
||||||
|
class Cheevos
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Punteros y objetos
|
||||||
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
vector<cheevos_t> cheevos; // Listado de logros
|
||||||
|
bool enabled; // Indica si los logros se pueden obtener
|
||||||
|
string file; // Fichero done leer/almacenar el estado de los logros
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void init();
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el indice
|
||||||
|
int find(int id);
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void loadFromFile();
|
||||||
|
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
void saveToFile();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Cheevos(Screen *screen, options_t *options, string file);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Cheevos();
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void unlock(int id);
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void invalidate(int id);
|
||||||
|
|
||||||
|
// Habilita o deshabilita los logros
|
||||||
|
void enable(bool value);
|
||||||
|
|
||||||
|
// Lista los logros
|
||||||
|
vector<cheevos_t> list();
|
||||||
|
|
||||||
|
// Devuelve el número total de logros desbloqueados
|
||||||
|
int unlocked();
|
||||||
|
|
||||||
|
// Devuelve el número total de logros
|
||||||
|
int count();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "utils.h"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
|
||||||
#define SCREEN_H
|
|
||||||
|
|
||||||
#define FILTER_NEAREST 0
|
|
||||||
#define FILTER_LINEAL 1
|
|
||||||
|
|
||||||
struct anchor_t
|
|
||||||
{
|
|
||||||
int left; // Parte izquierda de la pantalla de juego
|
|
||||||
int right; // Parte drecha de la pantalla de juego
|
|
||||||
int center; // Parte central horizontal de la pantalla de juego
|
|
||||||
int top; // Parte superior de la pantalla de juego
|
|
||||||
int bottom; // Parte infoerior de la pantalla de juego
|
|
||||||
int middle; // Parte central vertical de la pantalla de juego
|
|
||||||
};
|
|
||||||
|
|
||||||
// Clase Screen
|
|
||||||
class Screen
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Objetos y punteros
|
|
||||||
SDL_Window *window; // Ventana de la aplicación
|
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa
|
|
||||||
options_t *options; // Variable con todas las opciones del programa
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
int screenWidth; // Ancho de la pantalla o ventana
|
|
||||||
int screenHeight; // Alto de la pantalla o ventana
|
|
||||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
|
||||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
|
||||||
anchor_t anchor; // Variable con los anclajes de la pantalla
|
|
||||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
|
||||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
|
||||||
|
|
||||||
// Variables - Efectos
|
|
||||||
bool fade; // Indica si esta activo el efecto de fade
|
|
||||||
int fadeCounter; // Temporizador para el efecto de fade
|
|
||||||
int fadeLenght; // Duración del fade
|
|
||||||
bool spectrumFade; // Indica si esta activo el efecto de fade spectrum
|
|
||||||
int spectrumFadeCounter; // Temporizador para el efecto de fade spectrum
|
|
||||||
int spectrumFadeLenght; // Duración del fade spectrum
|
|
||||||
std::vector<color_t> spectrumColor; // Colores para el fade spectrum
|
|
||||||
|
|
||||||
// Inicializa las variables para el fade
|
|
||||||
void iniFade();
|
|
||||||
|
|
||||||
// Actualiza el fade
|
|
||||||
void updateFade();
|
|
||||||
|
|
||||||
// Dibuja el fade
|
|
||||||
void renderFade();
|
|
||||||
|
|
||||||
// Inicializa las variables para el fade spectrum
|
|
||||||
void iniSpectrumFade();
|
|
||||||
|
|
||||||
// Actualiza el spectrum fade
|
|
||||||
void updateSpectrumFade();
|
|
||||||
|
|
||||||
// Dibuja el spectrum fade
|
|
||||||
void renderSpectrumFade();
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, int gameInternalResX, int gameInternalResY);
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
void clean(color_t color = {0x00, 0x00, 0x00});
|
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
|
||||||
void start();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
void blit();
|
|
||||||
|
|
||||||
// Establece el modo de video
|
|
||||||
void setVideoMode(int fullScreenMode);
|
|
||||||
|
|
||||||
// Camibia entre pantalla completa y ventana
|
|
||||||
void switchVideoMode();
|
|
||||||
|
|
||||||
// Cambia el tamaño de la ventana
|
|
||||||
void setWindowSize(int size);
|
|
||||||
|
|
||||||
// Cambia el color del borde
|
|
||||||
void setBorderColor(color_t color);
|
|
||||||
|
|
||||||
// Cambia el tipo de mezcla
|
|
||||||
void setBlendMode(SDL_BlendMode blendMode);
|
|
||||||
|
|
||||||
// Establece el tamaño del borde
|
|
||||||
void setBorderSize(float s);
|
|
||||||
|
|
||||||
// Establece si se ha de ver el borde en el modo ventana
|
|
||||||
void setBorderEnabled(bool value);
|
|
||||||
|
|
||||||
// Cambia entre borde visible y no visible
|
|
||||||
void switchBorder();
|
|
||||||
|
|
||||||
// Activa el fade
|
|
||||||
void setFade();
|
|
||||||
|
|
||||||
// Comprueba si ha terminado el fade
|
|
||||||
bool fadeEnded();
|
|
||||||
|
|
||||||
// Activa el spectrum fade
|
|
||||||
void setspectrumFade();
|
|
||||||
|
|
||||||
// Comprueba si ha terminado el spectrum fade
|
|
||||||
bool spectrumFadeEnded();
|
|
||||||
|
|
||||||
// Actualiza los efectos
|
|
||||||
void updateFX();
|
|
||||||
|
|
||||||
// Dibuja los efectos
|
|
||||||
void renderFX();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "texture.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifndef UTILS_H
|
|
||||||
#define UTILS_H
|
|
||||||
|
|
||||||
// Estructura para definir un circulo
|
|
||||||
struct circle_t
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int r;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para definir una linea horizontal
|
|
||||||
struct h_line_t
|
|
||||||
{
|
|
||||||
int x1, x2, y;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para definir una linea vertical
|
|
||||||
struct v_line_t
|
|
||||||
{
|
|
||||||
int x, y1, y2;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para definir una linea diagonal
|
|
||||||
struct d_line_t
|
|
||||||
{
|
|
||||||
int x1, y1, x2, y2;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para definir una linea
|
|
||||||
struct line_t
|
|
||||||
{
|
|
||||||
int x1, y1, x2, y2;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para definir un color
|
|
||||||
struct color_t
|
|
||||||
{
|
|
||||||
Uint8 r;
|
|
||||||
Uint8 g;
|
|
||||||
Uint8 b;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Tipos de paleta
|
|
||||||
enum palette_e
|
|
||||||
{
|
|
||||||
p_zxspectrum,
|
|
||||||
p_zxarne
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para saber la seccion y subseccion del programa
|
|
||||||
struct section_t
|
|
||||||
{
|
|
||||||
Uint8 name;
|
|
||||||
Uint8 subsection;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura para albergar trucos
|
|
||||||
struct cheat_t
|
|
||||||
{
|
|
||||||
bool infiniteLives; // Indica si el jugador dispone de vidas infinitas
|
|
||||||
bool invincible; // Indica si el jugador puede morir
|
|
||||||
bool jailEnabled; // Indica si la Jail está abierta
|
|
||||||
bool altSkin; // Indicxa si se usa una skin diferente para el jugador
|
|
||||||
};
|
|
||||||
|
|
||||||
// Estructura con todas las opciones de configuración del programa
|
|
||||||
struct options_t
|
|
||||||
{
|
|
||||||
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
|
||||||
int windowSize; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
|
||||||
Uint32 filter; // Filtro usado para el escalado de la imagen
|
|
||||||
bool vSync; // Indica si se quiere usar vsync o no
|
|
||||||
int screenWidth; // Ancho de la pantalla o ventana
|
|
||||||
int screenHeight; // Alto de la pantalla o ventana
|
|
||||||
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
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
// Calcula el cuadrado de la distancia entre dos puntos
|
|
||||||
double distanceSquared(int x1, int y1, int x2, int y2);
|
|
||||||
|
|
||||||
// Detector de colisiones entre dos circulos
|
|
||||||
bool checkCollision(circle_t &a, circle_t &b);
|
|
||||||
|
|
||||||
// Detector de colisiones entre un circulo y un rectangulo
|
|
||||||
bool checkCollision(circle_t &a, SDL_Rect &b);
|
|
||||||
|
|
||||||
// Detector de colisiones entre un dos rectangulos
|
|
||||||
bool checkCollision(SDL_Rect &a, SDL_Rect &b);
|
|
||||||
|
|
||||||
// Detector de colisiones entre un punto y un rectangulo
|
|
||||||
bool checkCollision(SDL_Point &p, SDL_Rect &r);
|
|
||||||
|
|
||||||
// Detector de colisiones entre una linea horizontal y un rectangulo
|
|
||||||
bool checkCollision(h_line_t &l, SDL_Rect &r);
|
|
||||||
|
|
||||||
// Detector de colisiones entre una linea vertical y un rectangulo
|
|
||||||
bool checkCollision(v_line_t &l, SDL_Rect &r);
|
|
||||||
|
|
||||||
// Detector de colisiones entre una linea horizontal y un punto
|
|
||||||
bool checkCollision(h_line_t &l, SDL_Point &p);
|
|
||||||
|
|
||||||
// Detector de colisiones entre dos lineas
|
|
||||||
SDL_Point checkCollision(line_t &l1, line_t &l2);
|
|
||||||
|
|
||||||
// Detector de colisiones entre dos lineas
|
|
||||||
SDL_Point checkCollision(d_line_t &l1, v_line_t &l2);
|
|
||||||
|
|
||||||
// Detector de colisiones entre un punto y una linea diagonal
|
|
||||||
bool checkCollision(SDL_Point &p, d_line_t &l);
|
|
||||||
|
|
||||||
// Normaliza una linea diagonal
|
|
||||||
void normalizeLine(d_line_t &l);
|
|
||||||
|
|
||||||
// Devuelve un color_t a partir de un string
|
|
||||||
color_t stringToColor(palette_e pal, std::string str);
|
|
||||||
|
|
||||||
// Convierte una cadena en un valor booleano
|
|
||||||
bool stringToBool(std::string str);
|
|
||||||
|
|
||||||
// Convierte un valor booleano en una cadena
|
|
||||||
std::string boolToString(bool value);
|
|
||||||
|
|
||||||
// Compara dos colores
|
|
||||||
bool colorAreEqual(color_t color1, color_t color2);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/utils.h"
|
#include "jail_engine/utils.h"
|
||||||
|
|
||||||
#ifndef CONST_H
|
#ifndef CONST_H
|
||||||
#define CONST_H
|
#define CONST_H
|
||||||
@@ -57,7 +57,8 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
|
|||||||
#define SECTION_PROG_GAME_OVER 6
|
#define SECTION_PROG_GAME_OVER 6
|
||||||
#define SECTION_PROG_ENDING 7
|
#define SECTION_PROG_ENDING 7
|
||||||
#define SECTION_PROG_ENDING2 8
|
#define SECTION_PROG_ENDING2 8
|
||||||
#define SECTION_PROG_QUIT 9
|
#define SECTION_PROG_ENTER_ID 9
|
||||||
|
#define SECTION_PROG_QUIT 10
|
||||||
|
|
||||||
// Subsecciones
|
// Subsecciones
|
||||||
#define SUBSECTION_LOGO_TO_INTRO 0
|
#define SUBSECTION_LOGO_TO_INTRO 0
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,8 +22,8 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
counterEnabled = true;
|
counterEnabled = true;
|
||||||
subCounter = 0;
|
subCounter = 0;
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section->name = SECTION_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
sprite->setRect({194, 174, 8, 8});
|
sprite->setRect({194, 174, 8, 8});
|
||||||
@@ -35,7 +37,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
|
||||||
@@ -46,7 +48,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND);
|
||||||
@@ -74,65 +76,71 @@ void Credits::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Credits::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
switchPalette();
|
{
|
||||||
break;
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
void Credits::iniTexts()
|
void Credits::iniTexts()
|
||||||
{
|
{
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef GAME_CONSOLE
|
||||||
texts.clear();
|
texts.clear();
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||||
@@ -145,12 +153,12 @@ void Credits::iniTexts()
|
|||||||
|
|
||||||
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"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({"M TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"P TO PAUSE THE GAME", stringToColor(options->palette, "white")});
|
texts.push_back({"H TO PAUSE THE GAME", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
texts.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
texts.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"B TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
texts.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
@@ -161,6 +169,36 @@ void Credits::iniTexts()
|
|||||||
|
|
||||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
#else
|
||||||
|
texts.clear();
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"B TO JUMP", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"START TO PAUSE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"SELECT TO EXIT", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
|
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
@@ -186,7 +224,7 @@ void Credits::fillTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el corazón
|
// Escribe el corazón
|
||||||
const int textLenght = text->lenght(texts.at(22).label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
const int textLenght = text->lenght(texts[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||||
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
||||||
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
||||||
|
|
||||||
@@ -245,25 +283,31 @@ void Credits::updateCounter()
|
|||||||
// Comprueba si ha terminado la sección
|
// Comprueba si ha terminado la sección
|
||||||
if (counter > 1200)
|
if (counter > 1200)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_DEMO;
|
section->name = SECTION_PROG_DEMO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Credits::update()
|
void Credits::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
updateCounter();
|
updateCounter();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
|
|
||||||
// Actualiza el sprite con el brillo
|
// Actualiza el sprite con el brillo
|
||||||
if (counter > 770)
|
if (counter > 770)
|
||||||
{
|
{
|
||||||
@@ -287,7 +331,7 @@ void Credits::render()
|
|||||||
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
|
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
|
||||||
|
|
||||||
// Dibuja la textura que cubre el texto
|
// Dibuja la textura que cubre el texto
|
||||||
const int offset = std::min(counter / 8, 192 / 2);
|
const int offset = min(counter / 8, 192 / 2);
|
||||||
SDL_Rect srcRect = {0, 0, 256, 192 - (offset * 2)};
|
SDL_Rect srcRect = {0, 0, 256, 192 - (offset * 2)};
|
||||||
SDL_Rect dstRect = {0, offset * 2, 256, 192 - (offset * 2)};
|
SDL_Rect dstRect = {0, offset * 2, 256, 192 - (offset * 2)};
|
||||||
SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
|
SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
|
||||||
@@ -301,28 +345,18 @@ void Credits::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Credits::run()
|
void Credits::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_CREDITS)
|
while (section->name == SECTION_PROG_CREDITS)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
void Credits::switchPalette()
|
void Credits::switchPalette()
|
||||||
{
|
{
|
||||||
if (options->palette == p_zxspectrum)
|
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||||
{
|
|
||||||
options->palette = p_zxarne;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options->palette = p_zxspectrum;
|
|
||||||
}
|
|
||||||
|
|
||||||
fillTexture();
|
fillTexture();
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/texture.h"
|
#include "jail_engine/text.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/texture.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef CREDITS_H
|
#ifndef CREDITS_H
|
||||||
#define CREDITS_H
|
#define CREDITS_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Credits
|
class Credits
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct captions_t
|
struct captions_t
|
||||||
{
|
{
|
||||||
std::string label; // Texto a escribir
|
string label; // Texto a escribir
|
||||||
color_t color; // Color del texto
|
color_t color; // Color del texto
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
@@ -30,21 +33,22 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
bool counterEnabled; // Indica si esta activo el contador
|
bool counterEnabled; // Indica si esta activo el contador
|
||||||
int subCounter; // Contador secundario
|
int subCounter; // Contador secundario
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
vector<captions_t> texts; // Vector con los textos
|
||||||
std::vector<captions_t> texts; // Vector con los textos
|
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -55,6 +59,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
void updateCounter();
|
void updateCounter();
|
||||||
|
|
||||||
@@ -69,13 +76,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Credits();
|
~Credits();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
147
source/demo.cpp
@@ -1,7 +1,7 @@
|
|||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug)
|
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -15,15 +15,17 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
rooms.push_back("44.room");
|
rooms.push_back("44.room");
|
||||||
|
|
||||||
roomIndex = 0;
|
roomIndex = 0;
|
||||||
currentRoom = rooms.at(roomIndex);
|
currentRoom = rooms[roomIndex];
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->debug = debug;
|
this->resource = resource;
|
||||||
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
this->debug = debug;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
@@ -40,12 +42,12 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
board.lives = 9;
|
board.lives = 9;
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.jailEnabled = options->cheat.jailEnabled;
|
board.jailEnabled = false;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
section.name = SECTION_PROG_DEMO;
|
section->name = SECTION_PROG_DEMO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Demo::~Demo()
|
Demo::~Demo()
|
||||||
@@ -67,92 +69,91 @@ void Demo::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Comprueba las entradas
|
||||||
section_t Demo::run()
|
void Demo::checkInput()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_DEMO)
|
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle para el juego
|
||||||
|
void Demo::run()
|
||||||
|
{
|
||||||
|
while (section->name == SECTION_PROG_DEMO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void Demo::update()
|
void Demo::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba los eventos de la cola
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza los objetos
|
// Actualiza los objetos
|
||||||
room->update();
|
room->update();
|
||||||
scoreboard->update();
|
scoreboard->update();
|
||||||
screen->updateFX();
|
screen->updateFX();
|
||||||
checkRoomChange();
|
checkRoomChange();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +162,8 @@ void Demo::render()
|
|||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen->start();
|
||||||
screen->clean(room->getBGColor());
|
|
||||||
|
|
||||||
|
// Dibuja los elementos del juego en orden
|
||||||
room->renderMap();
|
room->renderMap();
|
||||||
room->renderEnemies();
|
room->renderEnemies();
|
||||||
room->renderItems();
|
room->renderItems();
|
||||||
@@ -189,9 +190,9 @@ void Demo::renderRoomName()
|
|||||||
// Recarga todas las texturas
|
// Recarga todas las texturas
|
||||||
void Demo::reLoadTextures()
|
void Demo::reLoadTextures()
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "** RELOAD REQUESTED" << std::endl;
|
cout << "** RELOAD REQUESTED" << endl;
|
||||||
}
|
}
|
||||||
room->reLoadTexture();
|
room->reLoadTexture();
|
||||||
scoreboard->reLoadTexture();
|
scoreboard->reLoadTexture();
|
||||||
@@ -219,7 +220,7 @@ void Demo::switchPalette()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
bool Demo::changeRoom(std::string file)
|
bool Demo::changeRoom(string file)
|
||||||
{
|
{
|
||||||
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
||||||
if (file != "0")
|
if (file != "0")
|
||||||
@@ -252,12 +253,12 @@ void Demo::checkRoomChange()
|
|||||||
roomIndex++;
|
roomIndex++;
|
||||||
if (roomIndex == (int)rooms.size())
|
if (roomIndex == (int)rooms.size())
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changeRoom(rooms.at(roomIndex));
|
changeRoom(rooms[roomIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/debug.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/input.h"
|
#include "jail_engine/debug.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/text.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "item_tracker.h"
|
#include "item_tracker.h"
|
||||||
#include "room_tracker.h"
|
#include "room_tracker.h"
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
#ifndef DEMO_H
|
#ifndef DEMO_H
|
||||||
#define DEMO_H
|
#define DEMO_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Demo
|
class Demo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -29,22 +32,23 @@ private:
|
|||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
string currentRoom; // Fichero de la habitación actual
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
board_t board; // Estructura con los datos del marcador
|
||||||
board_t board; // Estructura con los datos del marcador
|
int counter; // Contador para el modo demo
|
||||||
int counter; // Contador para el modo demo
|
int roomTime; // Tiempo que se muestra cada habitacion
|
||||||
int roomTime; // Tiempo que se muestra cada habitacion
|
int roomIndex; // Indice para el vector de habitaciones
|
||||||
int roomIndex; // Indice para el vector de habitaciones
|
vector<string> rooms; // Listado con los mapas de la demo
|
||||||
std::vector<std::string> rooms; // Listado con los mapas de la demo
|
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void update();
|
void update();
|
||||||
@@ -55,6 +59,9 @@ private:
|
|||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void renderRoomName();
|
void renderRoomName();
|
||||||
|
|
||||||
@@ -65,7 +72,7 @@ private:
|
|||||||
void switchPalette();
|
void switchPalette();
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
bool changeRoom(std::string file);
|
bool changeRoom(string file);
|
||||||
|
|
||||||
// Comprueba si se ha de cambiar de habitación
|
// Comprueba si se ha de cambiar de habitación
|
||||||
void checkRoomChange();
|
void checkRoomChange();
|
||||||
@@ -75,13 +82,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug);
|
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Demo();
|
~Demo();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,28 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/debug.h"
|
#include "jail_engine/debug.h"
|
||||||
#include "common/input.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/movingsprite.h"
|
#include "jail_engine/movingsprite.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/text.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "credits.h"
|
#include "credits.h"
|
||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
#include "ending.h"
|
||||||
|
#include "ending2.h"
|
||||||
|
#include "enter_id.h"
|
||||||
|
#include "game_over.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include "game_over.h"
|
|
||||||
#include "ending.h"
|
|
||||||
#include "ending2.h"
|
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
#define DIRECTOR_H
|
#define DIRECTOR_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Director
|
class Director
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -39,19 +42,24 @@ private:
|
|||||||
Intro *intro; // Objeto para gestionar la introducción del juego
|
Intro *intro; // Objeto para gestionar la introducción del juego
|
||||||
Credits *credits; // Objeto para gestionar los creditos del juego
|
Credits *credits; // Objeto para gestionar los creditos del juego
|
||||||
Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego
|
Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego
|
||||||
|
EnterID *enterID; // Objeto para gestionar la sección donde se solicita el ID online al usuario
|
||||||
Ending *ending; // Objeto para gestionar el final del juego
|
Ending *ending; // Objeto para gestionar el final del juego
|
||||||
Ending2 *ending2; // Objeto para gestionar el final del juego
|
Ending2 *ending2; // Objeto para gestionar el final del juego
|
||||||
GameOver *gameOver; // Objeto para gestionar el final de la partida
|
GameOver *gameOver; // Objeto para gestionar el final de la partida
|
||||||
Debug *debug; // Objeto para getsionar la información de debug
|
Debug *debug; // Objeto para getsionar la información de debug
|
||||||
struct options_t *options; // Variable con todas las opciones del programa
|
struct options_t *options; // Variable con todas las opciones del programa
|
||||||
|
section_t *section; // Sección y subsección actual del programa;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music music; // Musica del titulo
|
JA_Music_t *music; // Musica del titulo
|
||||||
std::string executablePath; // Path del ejecutable
|
string executablePath; // Path del ejecutable
|
||||||
section_t section; // Sección y subsección actual del programa;
|
string systemFolder; // Carpeta del sistema donde guardar datos
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
void iniOptions();
|
void initOptions();
|
||||||
|
|
||||||
|
// Inicializa los servicios online
|
||||||
|
void initOnline();
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void checkProgramArguments(int argc, char *argv[]);
|
void checkProgramArguments(int argc, char *argv[]);
|
||||||
@@ -62,11 +70,14 @@ private:
|
|||||||
// Guarda el fichero de configuración
|
// Guarda el fichero de configuración
|
||||||
bool saveConfig();
|
bool saveConfig();
|
||||||
|
|
||||||
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
|
void createSystemFolder(string folder);
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void loadResources(section_t section);
|
void loadResources(section_t *section);
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setOptions(options_t *options, std::string var, std::string value);
|
bool setOptions(options_t *options, string var, string value);
|
||||||
|
|
||||||
// Inicializa jail_audio
|
// Inicializa jail_audio
|
||||||
void initJailAudio();
|
void initJailAudio();
|
||||||
@@ -80,15 +91,6 @@ private:
|
|||||||
// Crea el indice de ficheros
|
// Crea el indice de ficheros
|
||||||
bool setFileList();
|
bool setFileList();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSubsection();
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSection();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setSection(section_t section);
|
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void runLogo();
|
void runLogo();
|
||||||
|
|
||||||
@@ -104,6 +106,9 @@ private:
|
|||||||
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
||||||
void runDemo();
|
void runDemo();
|
||||||
|
|
||||||
|
// Ejecuta la seccion en la que se solicita al usuario su ID online
|
||||||
|
void runEnterID();
|
||||||
|
|
||||||
// Ejecuta la seccion del final del juego
|
// Ejecuta la seccion del final del juego
|
||||||
void runEnding();
|
void runEnding();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include "ending.h"
|
#include "ending.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -19,8 +21,8 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
|||||||
counter = -1;
|
counter = -1;
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
coverCounter = 0;
|
coverCounter = 0;
|
||||||
section.name = SECTION_PROG_ENDING;
|
section->name = SECTION_PROG_ENDING;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
scene = 0;
|
scene = 0;
|
||||||
@@ -43,7 +45,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
|||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "Error: canvasTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
cout << "Error: canvasTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND);
|
||||||
@@ -83,14 +85,17 @@ Ending::~Ending()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Ending::update()
|
void Ending::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
updateCounters();
|
updateCounters();
|
||||||
@@ -103,6 +108,9 @@ void Ending::update()
|
|||||||
|
|
||||||
// Actualiza el volumen de la musica
|
// Actualiza el volumen de la musica
|
||||||
updateMusicVolume();
|
updateMusicVolume();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,23 +124,23 @@ void Ending::render()
|
|||||||
screen->clean(stringToColor(options->palette, "black"));
|
screen->clean(stringToColor(options->palette, "black"));
|
||||||
|
|
||||||
// Dibuja las imagenes de la escena
|
// Dibuja las imagenes de la escena
|
||||||
spritePics.at(scene).sprite->render();
|
spritePics[scene].sprite->render();
|
||||||
spritePics.at(scene).coverSprite->render();
|
spritePics[scene].coverSprite->render();
|
||||||
|
|
||||||
// Dibuja los textos de la escena
|
// Dibuja los textos de la escena
|
||||||
for (auto ti : scenes.at(scene).textIndex)
|
for (auto ti : scenes[scene].textIndex)
|
||||||
{
|
{
|
||||||
if (counter > ti.trigger)
|
if (counter > ti.trigger)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).sprite->render();
|
spriteTexts[ti.index].sprite->render();
|
||||||
spriteTexts.at(ti.index).coverSprite->render();
|
spriteTexts[ti.index].coverSprite->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la cortinilla de cambio de escena
|
// Dibuja la cortinilla de cambio de escena
|
||||||
renderCoverTexture();
|
renderCoverTexture();
|
||||||
|
|
||||||
// text->write(0, 0, std::to_string(counter));
|
// text->write(0, 0, to_string(counter));
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
@@ -147,57 +155,45 @@ void Ending::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Ending::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_LOGO;
|
||||||
break;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +201,7 @@ void Ending::checkEventHandler()
|
|||||||
void Ending::iniTexts()
|
void Ending::iniTexts()
|
||||||
{
|
{
|
||||||
// Vector con los textos
|
// Vector con los textos
|
||||||
std::vector<textAndPos_t> texts;
|
vector<textAndPos_t> texts;
|
||||||
|
|
||||||
// Escena #0
|
// Escena #0
|
||||||
texts.push_back({"HE FINALLY MANAGED", 32});
|
texts.push_back({"HE FINALLY MANAGED", 32});
|
||||||
@@ -311,7 +307,7 @@ void Ending::iniTexts()
|
|||||||
void Ending::iniPics()
|
void Ending::iniPics()
|
||||||
{
|
{
|
||||||
// Vector con las rutas y la posición
|
// Vector con las rutas y la posición
|
||||||
std::vector<textAndPos_t> pics;
|
vector<textAndPos_t> pics;
|
||||||
|
|
||||||
if (options->palette == p_zxspectrum)
|
if (options->palette == p_zxspectrum)
|
||||||
{
|
{
|
||||||
@@ -479,11 +475,11 @@ void Ending::iniScenes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending::run()
|
void Ending::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING)
|
while (section->name == SECTION_PROG_ENDING)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -491,8 +487,6 @@ section_t Ending::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -508,7 +502,7 @@ void Ending::updateCounters()
|
|||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter > scenes.at(scene).counterEnd - 100)
|
if (counter > scenes[scene].counterEnd - 100)
|
||||||
{
|
{
|
||||||
coverCounter++;
|
coverCounter++;
|
||||||
}
|
}
|
||||||
@@ -519,20 +513,20 @@ void Ending::updateSpriteCovers()
|
|||||||
{ // Actualiza la cortinilla de los textos
|
{ // Actualiza la cortinilla de los textos
|
||||||
if (counter % 4 == 0)
|
if (counter % 4 == 0)
|
||||||
{
|
{
|
||||||
for (auto ti : scenes.at(scene).textIndex)
|
for (auto ti : scenes[scene].textIndex)
|
||||||
{
|
{
|
||||||
if (counter > ti.trigger)
|
if (counter > ti.trigger)
|
||||||
{
|
{
|
||||||
if (spriteTexts.at(ti.index).clipDesp > 0)
|
if (spriteTexts[ti.index].clipDesp > 0)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).clipDesp -= 2;
|
spriteTexts[ti.index].clipDesp -= 2;
|
||||||
}
|
}
|
||||||
else if (spriteTexts.at(ti.index).clipHeight > 0)
|
else if (spriteTexts[ti.index].clipHeight > 0)
|
||||||
{
|
{
|
||||||
spriteTexts.at(ti.index).clipHeight -= 2;
|
spriteTexts[ti.index].clipHeight -= 2;
|
||||||
spriteTexts.at(ti.index).coverSprite->setPosY(spriteTexts.at(ti.index).coverSprite->getPosY() + 2);
|
spriteTexts[ti.index].coverSprite->setPosY(spriteTexts[ti.index].coverSprite->getPosY() + 2);
|
||||||
}
|
}
|
||||||
spriteTexts.at(ti.index).coverSprite->setSpriteClip(0, spriteTexts.at(ti.index).clipDesp, spriteTexts.at(ti.index).coverSprite->getWidth(), spriteTexts.at(ti.index).clipHeight);
|
spriteTexts[ti.index].coverSprite->setSpriteClip(0, spriteTexts[ti.index].clipDesp, spriteTexts[ti.index].coverSprite->getWidth(), spriteTexts[ti.index].clipHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,27 +534,27 @@ void Ending::updateSpriteCovers()
|
|||||||
// Actualiza la cortinilla de las imagenes
|
// Actualiza la cortinilla de las imagenes
|
||||||
if (counter % 2 == 0)
|
if (counter % 2 == 0)
|
||||||
{
|
{
|
||||||
if (spritePics.at(scene).clipDesp > 0)
|
if (spritePics[scene].clipDesp > 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipDesp -= 2;
|
spritePics[scene].clipDesp -= 2;
|
||||||
}
|
}
|
||||||
else if (spritePics.at(scene).clipHeight > 0)
|
else if (spritePics[scene].clipHeight > 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipHeight -= 2;
|
spritePics[scene].clipHeight -= 2;
|
||||||
if (spritePics.at(scene).clipHeight < 0)
|
if (spritePics[scene].clipHeight < 0)
|
||||||
{
|
{
|
||||||
spritePics.at(scene).clipHeight = 0;
|
spritePics[scene].clipHeight = 0;
|
||||||
}
|
}
|
||||||
spritePics.at(scene).coverSprite->setPosY(spritePics.at(scene).coverSprite->getPosY() + 2);
|
spritePics[scene].coverSprite->setPosY(spritePics[scene].coverSprite->getPosY() + 2);
|
||||||
}
|
}
|
||||||
spritePics.at(scene).coverSprite->setSpriteClip(0, spritePics.at(scene).clipDesp, spritePics.at(scene).coverSprite->getWidth(), spritePics.at(scene).clipHeight);
|
spritePics[scene].coverSprite->setSpriteClip(0, spritePics[scene].clipDesp, spritePics[scene].coverSprite->getWidth(), spritePics[scene].clipHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se ha de cambiar de escena
|
// Comprueba si se ha de cambiar de escena
|
||||||
void Ending::checkChangeScene()
|
void Ending::checkChangeScene()
|
||||||
{
|
{
|
||||||
if (counter > scenes.at(scene).counterEnd)
|
if (counter > scenes[scene].counterEnd)
|
||||||
{
|
{
|
||||||
scene++;
|
scene++;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -568,7 +562,7 @@ void Ending::checkChangeScene()
|
|||||||
if (scene == 5)
|
if (scene == 5)
|
||||||
{
|
{
|
||||||
// Termina el bucle
|
// Termina el bucle
|
||||||
section.name = SECTION_PROG_ENDING2;
|
section->name = SECTION_PROG_ENDING2;
|
||||||
|
|
||||||
// Mantiene los valores anteriores
|
// Mantiene los valores anteriores
|
||||||
scene = 4;
|
scene = 4;
|
||||||
@@ -611,7 +605,7 @@ void Ending::renderCoverTexture()
|
|||||||
{
|
{
|
||||||
if (coverCounter > 0)
|
if (coverCounter > 0)
|
||||||
{ // Dibuja la textura que cubre el texto
|
{ // Dibuja la textura que cubre el texto
|
||||||
const int offset = std::min(coverCounter, 100);
|
const int offset = min(coverCounter, 100);
|
||||||
SDL_Rect srcRect = {0, 200 - (coverCounter * 2), 256, offset * 2};
|
SDL_Rect srcRect = {0, 200 - (coverCounter * 2), 256, offset * 2};
|
||||||
SDL_Rect dstRect = {0, 0, 256, offset * 2};
|
SDL_Rect dstRect = {0, 0, 256, offset * 2};
|
||||||
SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
|
SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
|
||||||
@@ -636,20 +630,20 @@ void Ending::switchPalette()
|
|||||||
{
|
{
|
||||||
options->palette = p_zxarne;
|
options->palette = p_zxarne;
|
||||||
|
|
||||||
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
||||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
||||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
spritePics[2].sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
||||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
spritePics[3].sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
||||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
spritePics[4].sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options->palette = p_zxspectrum;
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1.png"));
|
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
|
||||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2.png"));
|
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
|
||||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3.png"));
|
spritePics[2].sprite->setTexture(resource->getTexture("ending3.png"));
|
||||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4.png"));
|
spritePics[3].sprite->setTexture(resource->getTexture("ending4.png"));
|
||||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5.png"));
|
spritePics[4].sprite->setTexture(resource->getTexture("ending5.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/texture.h"
|
#include "jail_engine/text.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/texture.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
#ifndef ENDING_H
|
#ifndef ENDING_H
|
||||||
#define ENDING_H
|
#define ENDING_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Ending
|
class Ending
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -32,8 +35,8 @@ private:
|
|||||||
|
|
||||||
struct textAndPos_t // Estructura con un texto y su posición en el eje Y
|
struct textAndPos_t // Estructura con un texto y su posición en el eje Y
|
||||||
{
|
{
|
||||||
std::string caption; // Texto
|
string caption; // Texto
|
||||||
int pos; // Posición
|
int pos; // Posición
|
||||||
};
|
};
|
||||||
|
|
||||||
struct asdhk
|
struct asdhk
|
||||||
@@ -44,9 +47,9 @@ private:
|
|||||||
|
|
||||||
struct scene_t // Estructura para crear cada una de las escenas del final
|
struct scene_t // Estructura para crear cada una de las escenas del final
|
||||||
{
|
{
|
||||||
std::vector<asdhk> textIndex; // Indices del vector de textos a mostrar y su disparador
|
vector<asdhk> textIndex; // Indices del vector de textos a mostrar y su disparador
|
||||||
int pictureIndex; // Indice del vector de imagenes a mostrar
|
int pictureIndex; // Indice del vector de imagenes a mostrar
|
||||||
int counterEnd; // Valor del contador en el que finaliza la escena
|
int counterEnd; // Valor del contador en el que finaliza la escena
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
@@ -54,23 +57,24 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int coverCounter; // Contador para la cortinilla
|
int coverCounter; // Contador para la cortinilla
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
||||||
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
||||||
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
int scene; // Escena actual
|
||||||
int scene; // Escena actual
|
vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
||||||
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
JA_Music music; // Musica que suena durante el final
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -81,6 +85,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
void iniTexts();
|
void iniTexts();
|
||||||
|
|
||||||
@@ -113,13 +120,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending();
|
~Ending();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -21,8 +23,8 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
postCounter = 0;
|
postCounter = 0;
|
||||||
postCounterEnabled = false;
|
postCounterEnabled = false;
|
||||||
section.name = SECTION_PROG_ENDING2;
|
section->name = SECTION_PROG_ENDING2;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
distSpriteText = 8;
|
distSpriteText = 8;
|
||||||
@@ -32,7 +34,7 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
secondCol = GAMECANVAS_THIRD_QUARTER_X - (GAMECANVAS_WIDTH / 16);
|
secondCol = GAMECANVAS_THIRD_QUARTER_X - (GAMECANVAS_WIDTH / 16);
|
||||||
|
|
||||||
// Inicializa el vector de colores
|
// Inicializa el vector de colores
|
||||||
const std::vector<std::string> colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
const vector<string> colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
||||||
for (auto cl : colorList)
|
for (auto cl : colorList)
|
||||||
{
|
{
|
||||||
colors.push_back(stringToColor(options->palette, cl));
|
colors.push_back(stringToColor(options->palette, cl));
|
||||||
@@ -73,14 +75,17 @@ Ending2::~Ending2()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Ending2::update()
|
void Ending2::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
updateCounters();
|
updateCounters();
|
||||||
@@ -102,6 +107,9 @@ void Ending2::update()
|
|||||||
|
|
||||||
// Actualiza el volumen de la musica
|
// Actualiza el volumen de la musica
|
||||||
updateMusicVolume();
|
updateMusicVolume();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +131,7 @@ void Ending2::render()
|
|||||||
// Dibuja los sprites con el texto del final
|
// Dibuja los sprites con el texto del final
|
||||||
renderTexts();
|
renderTexts();
|
||||||
|
|
||||||
const std::string txt = std::to_string(postCounter);
|
const string txt = to_string(postCounter);
|
||||||
// text->write(0, 192 - 8, txt);
|
// text->write(0, 192 - 8, txt);
|
||||||
|
|
||||||
// Dibuja la cuadricula
|
// Dibuja la cuadricula
|
||||||
@@ -181,66 +189,54 @@ void Ending2::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Comprueba las teclas que se han pulsado
|
}
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
// Comprueba las entradas
|
||||||
switch (eventHandler->key.keysym.scancode)
|
void Ending2::checkInput()
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
break;
|
{
|
||||||
|
section->name = SECTION_PROG_LOGO;
|
||||||
case SDL_SCANCODE_B:
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
screen->switchBorder();
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F:
|
screen->switchBorder();
|
||||||
screen->switchVideoMode();
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F1:
|
screen->switchVideoMode();
|
||||||
screen->setWindowSize(1);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F2:
|
screen->decWindowSize();
|
||||||
screen->setWindowSize(2);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F3:
|
screen->incWindowSize();
|
||||||
screen->setWindowSize(3);
|
}
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
case SDL_SCANCODE_F4:
|
switchPalette();
|
||||||
screen->setWindowSize(4);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending2::run()
|
void Ending2::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING2)
|
while (section->name == SECTION_PROG_ENDING2)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -248,8 +244,6 @@ section_t Ending2::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -272,8 +266,8 @@ void Ending2::updateCounters()
|
|||||||
|
|
||||||
if (postCounter > 600)
|
if (postCounter > 600)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,14 +279,14 @@ void Ending2::iniSpriteList()
|
|||||||
|
|
||||||
// Añade los valores
|
// Añade los valores
|
||||||
spriteList.push_back("bin");
|
spriteList.push_back("bin");
|
||||||
spriteList.push_back("diskette");
|
spriteList.push_back("floppy");
|
||||||
spriteList.push_back("bird");
|
spriteList.push_back("bird");
|
||||||
spriteList.push_back("chip");
|
spriteList.push_back("chip");
|
||||||
spriteList.push_back("jeannine");
|
spriteList.push_back("jeannine");
|
||||||
spriteList.push_back("spark");
|
spriteList.push_back("spark");
|
||||||
spriteList.push_back("code");
|
spriteList.push_back("code");
|
||||||
spriteList.push_back("paco");
|
spriteList.push_back("paco");
|
||||||
spriteList.push_back("printer");
|
spriteList.push_back("elsa");
|
||||||
spriteList.push_back("z80");
|
spriteList.push_back("z80");
|
||||||
|
|
||||||
spriteList.push_back("bell");
|
spriteList.push_back("bell");
|
||||||
@@ -301,9 +295,9 @@ void Ending2::iniSpriteList()
|
|||||||
spriteList.push_back("amstrad_cs");
|
spriteList.push_back("amstrad_cs");
|
||||||
spriteList.push_back("breakout");
|
spriteList.push_back("breakout");
|
||||||
|
|
||||||
spriteList.push_back("arounder_fly");
|
spriteList.push_back("flying_arounder");
|
||||||
spriteList.push_back("arounder_stop");
|
spriteList.push_back("stopped_arounder");
|
||||||
spriteList.push_back("arounder_walk");
|
spriteList.push_back("walking_arounder");
|
||||||
spriteList.push_back("arounders_door");
|
spriteList.push_back("arounders_door");
|
||||||
spriteList.push_back("arounders_machine");
|
spriteList.push_back("arounders_machine");
|
||||||
|
|
||||||
@@ -321,12 +315,12 @@ void Ending2::iniSpriteList()
|
|||||||
spriteList.push_back("dimallas");
|
spriteList.push_back("dimallas");
|
||||||
spriteList.push_back("guitar");
|
spriteList.push_back("guitar");
|
||||||
|
|
||||||
spriteList.push_back("jb_alien");
|
spriteList.push_back("jailbattle_alien");
|
||||||
spriteList.push_back("jb_human");
|
spriteList.push_back("jailbattle_human");
|
||||||
|
|
||||||
spriteList.push_back("jailer");
|
spriteList.push_back("jailer_#1");
|
||||||
spriteList.push_back("jailer2");
|
spriteList.push_back("jailer_#2");
|
||||||
spriteList.push_back("jailer3");
|
spriteList.push_back("jailer_#3");
|
||||||
spriteList.push_back("bry");
|
spriteList.push_back("bry");
|
||||||
spriteList.push_back("upv_student");
|
spriteList.push_back("upv_student");
|
||||||
|
|
||||||
@@ -369,8 +363,8 @@ void Ending2::loadSprites()
|
|||||||
for (auto sl : spriteList)
|
for (auto sl : spriteList)
|
||||||
{
|
{
|
||||||
sprites.push_back(new AnimatedSprite(renderer, resource->getAnimation(sl + ".ani")));
|
sprites.push_back(new AnimatedSprite(renderer, resource->getAnimation(sl + ".ani")));
|
||||||
maxSpriteWidth = std::max(sprites.back()->getAnimationClip(0, 0).w, maxSpriteWidth);
|
maxSpriteWidth = max(sprites.back()->getAnimationClip(0, 0).w, maxSpriteWidth);
|
||||||
maxSpriteHeight = std::max(sprites.back()->getAnimationClip(0, 0).h, maxSpriteHeight);
|
maxSpriteHeight = max(sprites.back()->getAnimationClip(0, 0).h, maxSpriteHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,13 +460,13 @@ void Ending2::placeSprites()
|
|||||||
{
|
{
|
||||||
const int x = i % 2 == 0 ? firstCol : secondCol;
|
const int x = i % 2 == 0 ? firstCol : secondCol;
|
||||||
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
|
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
|
||||||
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
|
const int w = sprites[i]->getAnimationClip(0, 0).w;
|
||||||
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
|
const int h = sprites[i]->getAnimationClip(0, 0).h;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
|
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
|
||||||
|
|
||||||
sprites.at(i)->setRect({x + dx, y + dy, w, h});
|
sprites[i]->setRect({x + dx, y + dy, w, h});
|
||||||
sprites.at(i)->setVelY(despSpeed);
|
sprites[i]->setVelY(despSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recoloca el último sprite, que es el del jugador
|
// Recoloca el último sprite, que es el del jugador
|
||||||
@@ -494,14 +488,14 @@ void Ending2::createSpriteTexts()
|
|||||||
for (int i = 0; i < (int)spriteList.size(); ++i)
|
for (int i = 0; i < (int)spriteList.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
std::string txt = spriteList.at(i);
|
string txt = spriteList[i];
|
||||||
std::replace(txt.begin(), txt.end(), '_', ' ');
|
replace(txt.begin(), txt.end(), '_', ' ');
|
||||||
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
|
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
|
||||||
const int w = text->lenght(txt, 1);
|
const int w = text->lenght(txt, 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = i % 2 == 0 ? firstCol : secondCol;
|
const int x = i % 2 == 0 ? firstCol : secondCol;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
const int y = sprites.at(i)->getPosY() + sprites.at(i)->getHeight() + distSpriteText;
|
const int y = sprites[i]->getPosY() + sprites[i]->getHeight() + distSpriteText;
|
||||||
|
|
||||||
// Cambia la posición del último sprite
|
// Cambia la posición del último sprite
|
||||||
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
|
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
|
||||||
@@ -526,14 +520,14 @@ void Ending2::createTexts()
|
|||||||
deleteTexts();
|
deleteTexts();
|
||||||
|
|
||||||
// Crea los primeros textos
|
// Crea los primeros textos
|
||||||
std::vector<std::string> list;
|
vector<string> list;
|
||||||
list.push_back("STARRING");
|
list.push_back("STARRING");
|
||||||
|
|
||||||
// Crea los sprites de texto a partir de la lista
|
// Crea los sprites de texto a partir de la lista
|
||||||
for (int i = 0; i < (int)list.size(); ++i)
|
for (int i = 0; i < (int)list.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
const int w = text->lenght(list.at(i), 1);
|
const int w = text->lenght(list[i], 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = GAMECANVAS_CENTER_X;
|
const int x = GAMECANVAS_CENTER_X;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
@@ -544,7 +538,7 @@ void Ending2::createTexts()
|
|||||||
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
text->write(0, 0, list.at(i));
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
||||||
@@ -562,7 +556,7 @@ void Ending2::createTexts()
|
|||||||
for (int i = 0; i < (int)list.size(); ++i)
|
for (int i = 0; i < (int)list.size(); ++i)
|
||||||
{
|
{
|
||||||
// Calcula constantes
|
// Calcula constantes
|
||||||
const int w = text->lenght(list.at(i), 1);
|
const int w = text->lenght(list[i], 1);
|
||||||
const int h = text->getCharacterSize();
|
const int h = text->getCharacterSize();
|
||||||
const int x = GAMECANVAS_CENTER_X;
|
const int x = GAMECANVAS_CENTER_X;
|
||||||
const int dx = -(w / 2);
|
const int dx = -(w / 2);
|
||||||
@@ -573,7 +567,7 @@ void Ending2::createTexts()
|
|||||||
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
|
||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
text->write(0, 0, list.at(i));
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
|
||||||
@@ -616,12 +610,12 @@ void Ending2::deleteTexts()
|
|||||||
void Ending2::updateFinalFade()
|
void Ending2::updateFinalFade()
|
||||||
{
|
{
|
||||||
// La variable step va de 0 a 40 en el tramo de postCounter que va de 500 a 540. Al dividirlo por 40, va de 0.0f a 1.0f
|
// La variable step va de 0 a 40 en el tramo de postCounter que va de 500 a 540. Al dividirlo por 40, va de 0.0f a 1.0f
|
||||||
const float step = std::min(std::max(postCounter, 500) - 500, 40) / 40.0f;
|
const float step = min(max(postCounter, 500) - 500, 40) / 40.0f;
|
||||||
const int index = (colors.size() - 1) * step;
|
const int index = (colors.size() - 1) * step;
|
||||||
|
|
||||||
for (auto t : texts)
|
for (auto t : texts)
|
||||||
{
|
{
|
||||||
t->getTexture()->setColor(colors.at(index).r, colors.at(index).g, colors.at(index).b);
|
t->getTexture()->setColor(colors[index].r, colors[index].g, colors[index].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/texture.h"
|
#include "jail_engine/text.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/texture.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -16,39 +17,42 @@
|
|||||||
#ifndef ENDING2_H
|
#ifndef ENDING2_H
|
||||||
#define ENDING2_H
|
#define ENDING2_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Ending2
|
class Ending2
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
options_t *options; // Puntero a las opciones del juego
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
options_t *options; // Puntero a las opciones del juego
|
||||||
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
||||||
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
|
vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
||||||
|
vector<MovingSprite *> texts; // Vector con los sprites de texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
bool counterEnabled; // Indica si está el contador habilitado
|
bool counterEnabled; // Indica si está el contador habilitado
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int postCounter; // Contador posterior
|
int postCounter; // Contador posterior
|
||||||
bool postCounterEnabled; // Indica si está habilitado el contador
|
bool postCounterEnabled; // Indica si está habilitado el contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
JA_Music music; // Musica que suena durante el final
|
vector<string> spriteList; // Lista con todos los sprites a dibujar
|
||||||
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
vector<color_t> colors; // Vector con los colores para el fade
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
||||||
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
int maxSpriteHeight; // El valor de alto del sprite mas alto
|
||||||
int maxSpriteHeight; // El valor de alto del sprite mas alto
|
int distSpriteText; // Distancia entre el sprite y el texto que lo acompaña
|
||||||
int distSpriteText; // Distancia entre el sprite y el texto que lo acompaña
|
int distSpriteSprite; // Distancia entre dos sprites de la misma columna
|
||||||
int distSpriteSprite; // Distancia entre dos sprites de la misma columna
|
float despSpeed; // Velocidad de desplazamiento de los sprites
|
||||||
float despSpeed; // Velocidad de desplazamiento de los sprites
|
int firstCol; // Primera columna por donde desfilan los sprites
|
||||||
int firstCol; // Primera columna por donde desfilan los sprites
|
int secondCol; // Segunda columna por donde desfilan los sprites
|
||||||
int secondCol; // Segunda columna por donde desfilan los sprites
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -59,6 +63,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
void updateCounters();
|
void updateCounters();
|
||||||
|
|
||||||
@@ -115,13 +122,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending2();
|
~Ending2();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Enemy::Enemy(enemy_t enemy)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite->setCurrentFrame(std::min(enemy.frame, sprite->getNumFrames() - 1));
|
sprite->setCurrentFrame(min(enemy.frame, sprite->getNumFrames() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef ENEMY_H
|
#ifndef ENEMY_H
|
||||||
#define ENEMY_H
|
#define ENEMY_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// Estructura para pasar los datos de un enemigo
|
// Estructura para pasar los datos de un enemigo
|
||||||
struct enemy_t
|
struct enemy_t
|
||||||
{
|
{
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
animatedSprite_t *animation; // Puntero a las animaciones del enemigo
|
animatedSprite_t *animation; // Puntero a las animaciones del enemigo
|
||||||
std::string animationString; // Ruta al fichero con la animación
|
string animationString; // Ruta al fichero con la animación
|
||||||
int w; // Anchura del enemigo
|
int w; // Anchura del enemigo
|
||||||
int h; // Altura del enemigo
|
int h; // Altura del enemigo
|
||||||
float x; // Posición inicial en el eje X
|
float x; // Posición inicial en el eje X
|
||||||
@@ -28,7 +30,7 @@ struct enemy_t
|
|||||||
bool flip; // Indica si el enemigo hace flip al terminar su ruta
|
bool flip; // Indica si el enemigo hace flip al terminar su ruta
|
||||||
bool mirror; // Indica si el enemigo está volteado verticalmente
|
bool mirror; // Indica si el enemigo está volteado verticalmente
|
||||||
int frame; // Frame inicial para la animación del enemigo
|
int frame; // Frame inicial para la animación del enemigo
|
||||||
std::string color; // Color del enemigo
|
string color; // Color del enemigo
|
||||||
palette_e palette; // Paleta de colores
|
palette_e palette; // Paleta de colores
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,16 +41,16 @@ private:
|
|||||||
AnimatedSprite *sprite; // Sprite del enemigo
|
AnimatedSprite *sprite; // Sprite del enemigo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
color_t color; // Color del enemigo
|
color_t color; // Color del enemigo
|
||||||
std::string colorString; // Color del enemigo en formato texto
|
string colorString; // Color del enemigo en formato texto
|
||||||
palette_e palette; // Paleta de colores
|
palette_e palette; // Paleta de colores
|
||||||
int x1; // Limite izquierdo de la ruta en el eje X
|
int x1; // Limite izquierdo de la ruta en el eje X
|
||||||
int x2; // Limite derecho de la ruta en el eje X
|
int x2; // Limite derecho de la ruta en el eje X
|
||||||
int y1; // Limite superior de la ruta en el eje Y
|
int y1; // Limite superior de la ruta en el eje Y
|
||||||
int y2; // Limite inferior de la ruta en el eje Y
|
int y2; // Limite inferior de la ruta en el eje Y
|
||||||
SDL_Rect collider; // Caja de colisión
|
SDL_Rect collider; // Caja de colisión
|
||||||
bool doFlip; // Indica si el enemigo hace flip al terminar su ruta
|
bool doFlip; // Indica si el enemigo hace flip al terminar su ruta
|
||||||
bool mirror; // Indica si el enemigo se dibuja volteado verticalmente
|
bool mirror; // Indica si el enemigo se dibuja volteado verticalmente
|
||||||
|
|
||||||
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
||||||
void checkPath();
|
void checkPath();
|
||||||
|
|||||||
317
source/enter_id.cpp
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
#include "jail_engine/jail_audio.h"
|
||||||
|
#include "jail_engine/jscore.h"
|
||||||
|
#include "const.h"
|
||||||
|
#include "enter_id.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section)
|
||||||
|
{
|
||||||
|
// Copia la dirección de los objetos
|
||||||
|
this->renderer = renderer;
|
||||||
|
this->screen = screen;
|
||||||
|
this->asset = asset;
|
||||||
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
|
// Reserva memoria para los punteros
|
||||||
|
eventHandler = new SDL_Event();
|
||||||
|
texture = new Texture(renderer, asset->get("smb2.png"));
|
||||||
|
text = new Text(asset->get("smb2.txt"), texture, renderer);
|
||||||
|
|
||||||
|
// Crea la textura para el texto que se escribe en pantalla
|
||||||
|
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||||
|
if (textTexture == nullptr)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
counter = 0;
|
||||||
|
ticks = 0;
|
||||||
|
ticksSpeed = 15;
|
||||||
|
pos = 0;
|
||||||
|
name[pos] = 0;
|
||||||
|
maxLenght = 15;
|
||||||
|
|
||||||
|
if (options->online.enabled && options->online.jailerID == "")
|
||||||
|
{
|
||||||
|
this->section->name = SECTION_PROG_ENTER_ID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
fillTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
EnterID::~EnterID()
|
||||||
|
{
|
||||||
|
delete eventHandler;
|
||||||
|
delete text;
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle para el logo del juego
|
||||||
|
void EnterID::run()
|
||||||
|
{
|
||||||
|
// Detiene la música
|
||||||
|
JA_StopMusic();
|
||||||
|
|
||||||
|
while (section->name == SECTION_PROG_ENTER_ID)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
void EnterID::checkEventHandler()
|
||||||
|
{
|
||||||
|
// Comprueba los eventos que hay en la cola
|
||||||
|
while (SDL_PollEvent(eventHandler) != 0)
|
||||||
|
{
|
||||||
|
// Evento de salida de la aplicación
|
||||||
|
if (eventHandler->type == SDL_QUIT)
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// El ENTER solo se comprueba cuando se suelta, para no saltarse la siguiente sección
|
||||||
|
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
|
||||||
|
{
|
||||||
|
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
|
||||||
|
{
|
||||||
|
options->online.jailerID = (string)name;
|
||||||
|
endSection();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba las teclas que se han pulsado
|
||||||
|
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||||
|
{
|
||||||
|
if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
|
||||||
|
{ // Si pulsa una letra
|
||||||
|
if (pos < maxLenght)
|
||||||
|
{
|
||||||
|
name[pos++] = eventHandler->key.keysym.scancode + 61;
|
||||||
|
name[pos] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9)
|
||||||
|
{ // Si pulsa un número
|
||||||
|
if (pos < maxLenght)
|
||||||
|
{ // En ascii el '0' va antes del '1', pero en scancode el '0' va despues de '9'
|
||||||
|
name[pos++] = eventHandler->key.keysym.scancode + 19;
|
||||||
|
name[pos] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0)
|
||||||
|
{
|
||||||
|
if (pos < maxLenght)
|
||||||
|
{
|
||||||
|
name[pos++] = 48;
|
||||||
|
name[pos] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE)
|
||||||
|
{
|
||||||
|
if (pos > 0)
|
||||||
|
{
|
||||||
|
name[--pos] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F1)
|
||||||
|
{
|
||||||
|
screen->setWindowSize(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F2)
|
||||||
|
{
|
||||||
|
screen->setWindowSize(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F3)
|
||||||
|
{
|
||||||
|
screen->setWindowSize(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F4)
|
||||||
|
{
|
||||||
|
screen->setWindowSize(4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F5)
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void EnterID::update()
|
||||||
|
{
|
||||||
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
|
{
|
||||||
|
// Actualiza el contador de ticks
|
||||||
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
|
// Actualiza el contador
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
// Actualiza el cursor
|
||||||
|
cursor = (counter % 20 >= 10) ? " " : "_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void EnterID::render()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean();
|
||||||
|
|
||||||
|
// Dibuja la textura con el texto en pantalla
|
||||||
|
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
|
||||||
|
|
||||||
|
// Escribe el jailerID
|
||||||
|
const string jailerID = (string)name + cursor;
|
||||||
|
const color_t color = stringToColor(options->palette, "white");
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, (16 * 8 + 1), jailerID, 1, color);
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los textos
|
||||||
|
void EnterID::iniTexts()
|
||||||
|
{
|
||||||
|
texts.clear();
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"FOR THE ONLINE SERVICE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"PLEASE ENTER AN ID OR", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
void EnterID::fillTexture()
|
||||||
|
{
|
||||||
|
// Inicializa los textos
|
||||||
|
iniTexts();
|
||||||
|
|
||||||
|
// Rellena la textura de texto
|
||||||
|
SDL_SetRenderTarget(renderer, textTexture);
|
||||||
|
color_t c = stringToColor(options->palette, "black");
|
||||||
|
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
const int size = text->getCharacterSize();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (auto t : texts)
|
||||||
|
{
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, i * size, t.label, 1, t.color);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cambia la paleta
|
||||||
|
void EnterID::switchPalette()
|
||||||
|
{
|
||||||
|
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||||
|
fillTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los servicios online
|
||||||
|
void EnterID::initOnline()
|
||||||
|
{
|
||||||
|
if (options->online.sessionEnabled)
|
||||||
|
{ // Si ya ha iniciado la sesión, que no continue
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options->online.jailerID == "")
|
||||||
|
{ // Jailer ID no definido
|
||||||
|
|
||||||
|
options->online.enabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Jailer ID iniciado
|
||||||
|
|
||||||
|
options->online.enabled = options->online.sessionEnabled = true;
|
||||||
|
jscore::init(options->online.server, options->online.port);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
const string caption = "IS LOGGED IN (DEBUG)";
|
||||||
|
#else
|
||||||
|
const string caption = "IS LOGGED IN";
|
||||||
|
#endif
|
||||||
|
screen->showNotification(options->online.jailerID, caption, 12);
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << caption << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Termina la sección
|
||||||
|
void EnterID::endSection()
|
||||||
|
{
|
||||||
|
initOnline();
|
||||||
|
section->name = (section->subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
|
}
|
||||||
82
source/enter_id.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "jail_engine/asset.h"
|
||||||
|
#include "jail_engine/screen.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
|
#include "jail_engine/text.h"
|
||||||
|
#include "jail_engine/texture.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef ENTER_ID_H
|
||||||
|
#define ENTER_ID_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class EnterID
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
struct captions_t
|
||||||
|
{
|
||||||
|
string label; // Texto a escribir
|
||||||
|
color_t color; // Color del texto
|
||||||
|
};
|
||||||
|
|
||||||
|
// Punteros y objetos
|
||||||
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
|
Texture *texture; // Textura para la fuente para el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
int counter; // Contador
|
||||||
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
|
vector<captions_t> texts; // Vector con los textos
|
||||||
|
string cursor; // Contiene el caracter que se muestra como cursor
|
||||||
|
|
||||||
|
char name[15];
|
||||||
|
int pos;
|
||||||
|
int maxLenght; // Tamaño máximo del jailerID
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Inicializa los textos
|
||||||
|
void iniTexts();
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
void fillTexture();
|
||||||
|
|
||||||
|
// Cambia la paleta
|
||||||
|
void switchPalette();
|
||||||
|
|
||||||
|
// Inicializa los servicios online
|
||||||
|
void initOnline();
|
||||||
|
|
||||||
|
// Termina la sección
|
||||||
|
void endSection();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~EnterID();
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
void run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
406
source/game.cpp
@@ -2,15 +2,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug)
|
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
|
||||||
board.iniClock = SDL_GetTicks();
|
|
||||||
currentRoom = "03.room";
|
|
||||||
const int x = 25;
|
|
||||||
const int y = 13;
|
|
||||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -19,32 +12,65 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->input = input;
|
this->input = input;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
|
// Inicia algunas variables
|
||||||
|
board.iniClock = SDL_GetTicks();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
currentRoom = "48.room";
|
currentRoom = "03.room";
|
||||||
const int x1 = 18;
|
const int x = 25;
|
||||||
const int y1 = 13;
|
const int y = 13;
|
||||||
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
|
debug->setEnabled(false);
|
||||||
|
#else
|
||||||
|
currentRoom = "03.room";
|
||||||
|
const int x = 25;
|
||||||
|
const int y = 13;
|
||||||
|
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
|
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"));
|
||||||
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
roomTracker = new RoomTracker();
|
roomTracker = new RoomTracker();
|
||||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, false, debug);
|
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, false, debug);
|
||||||
const std::string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
const string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
||||||
const std::string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
const string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
||||||
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
||||||
this->player = new Player(player);
|
this->player = new Player(player);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
||||||
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
||||||
|
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
||||||
|
|
||||||
|
// Crea la textura para poner el nombre de la habitación
|
||||||
|
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
|
||||||
|
if (roomNameTexture == nullptr)
|
||||||
|
{
|
||||||
|
if (options->console)
|
||||||
|
{
|
||||||
|
cout << "Error: roomNameTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el blend mode de la textura
|
||||||
|
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
|
// Establece el destino de la textura
|
||||||
|
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
fillRoomNameTexture();
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
board.lives = 9;
|
board.lives = 9;
|
||||||
|
#ifdef DEBUG
|
||||||
|
board.lives = 9;
|
||||||
|
#endif
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
@@ -55,14 +81,19 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
blackScreen = false;
|
blackScreen = false;
|
||||||
blackScreenCounter = 0;
|
blackScreenCounter = 0;
|
||||||
totalItems = getTotalItems();
|
totalItems = getTotalItems();
|
||||||
|
initStats();
|
||||||
|
stats->addVisit(room->getName());
|
||||||
|
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
|
||||||
|
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
|
||||||
|
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game()
|
Game::~Game()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
|
delete cheevos;
|
||||||
delete scoreboard;
|
delete scoreboard;
|
||||||
delete itemTracker;
|
delete itemTracker;
|
||||||
delete roomTracker;
|
delete roomTracker;
|
||||||
@@ -70,6 +101,9 @@ Game::~Game()
|
|||||||
delete player;
|
delete player;
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
delete text;
|
delete text;
|
||||||
|
delete stats;
|
||||||
|
|
||||||
|
SDL_DestroyTexture(roomNameTexture);
|
||||||
|
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
JA_DeleteSound(deathSound);
|
JA_DeleteSound(deathSound);
|
||||||
@@ -84,18 +118,20 @@ void Game::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
if (eventHandler->type == SDL_RENDER_DEVICE_RESET || eventHandler->type == SDL_RENDER_TARGETS_RESET)
|
||||||
|
{
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
break;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
debug->switchEnabled();
|
debug->switchEnabled();
|
||||||
@@ -123,51 +159,23 @@ void Game::checkEventHandler()
|
|||||||
case SDL_SCANCODE_D:
|
case SDL_SCANCODE_D:
|
||||||
goToRoom(BORDER_RIGHT);
|
goToRoom(BORDER_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F6:
|
||||||
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F7:
|
||||||
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F8:
|
||||||
|
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F9:
|
||||||
|
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 5);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case SDL_SCANCODE_M:
|
|
||||||
board.music = !board.music;
|
|
||||||
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_P:
|
|
||||||
switchPause();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -175,8 +183,57 @@ void Game::checkEventHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba el teclado
|
||||||
|
void Game::checkInput()
|
||||||
|
{
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_switch_music, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
board.music = !board.music;
|
||||||
|
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
reLoadTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
if (!board.music)
|
if (!board.music)
|
||||||
@@ -184,28 +241,29 @@ section_t Game::run()
|
|||||||
JA_PauseMusic();
|
JA_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_GAME)
|
while (section->name == SECTION_PROG_GAME)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void Game::update()
|
void Game::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba los eventos de la cola
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba el teclado
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug->clear();
|
debug->clear();
|
||||||
@@ -220,11 +278,16 @@ void Game::update()
|
|||||||
checkIfPlayerIsAlive();
|
checkIfPlayerIsAlive();
|
||||||
checkGameOver();
|
checkGameOver();
|
||||||
checkEndGame();
|
checkEndGame();
|
||||||
|
checkRestoringJail();
|
||||||
|
checkSomeCheevos();
|
||||||
scoreboard->update();
|
scoreboard->update();
|
||||||
input->update();
|
input->update();
|
||||||
|
|
||||||
updateBlackScreen();
|
updateBlackScreen();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
updateDebugInfo();
|
updateDebugInfo();
|
||||||
#endif
|
#endif
|
||||||
@@ -236,8 +299,8 @@ void Game::render()
|
|||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen->start();
|
||||||
screen->clean(room->getBGColor());
|
|
||||||
|
|
||||||
|
// Dibuja los elementos del juego en orden
|
||||||
room->renderMap();
|
room->renderMap();
|
||||||
room->renderEnemies();
|
room->renderEnemies();
|
||||||
room->renderItems();
|
room->renderItems();
|
||||||
@@ -259,9 +322,9 @@ void Game::render()
|
|||||||
// Pasa la información de debug
|
// Pasa la información de debug
|
||||||
void Game::updateDebugInfo()
|
void Game::updateDebugInfo()
|
||||||
{
|
{
|
||||||
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
|
debug->add("X = " + to_string((int)player->x) + ", Y = " + to_string((int)player->y));
|
||||||
debug->add("VX = " + std::to_string(player->vx).substr(0, 4) + ", VY = " + std::to_string(player->vy).substr(0, 4));
|
debug->add("VX = " + to_string(player->vx).substr(0, 4) + ", VY = " + to_string(player->vy).substr(0, 4));
|
||||||
debug->add("STATE = " + std::to_string(player->state));
|
debug->add("STATE = " + to_string(player->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
@@ -297,17 +360,12 @@ void Game::renderDebugInfo()
|
|||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void Game::renderRoomName()
|
void Game::renderRoomName()
|
||||||
{
|
{
|
||||||
// Texto en el centro de la pantalla
|
// Dibuja la textura con el nombre de la habitación
|
||||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
|
||||||
color_t color = stringToColor(options->palette, "white");
|
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
|
||||||
|
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
bool Game::changeRoom(std::string file)
|
bool Game::changeRoom(string file)
|
||||||
{
|
{
|
||||||
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
||||||
if (file == "0")
|
if (file == "0")
|
||||||
@@ -325,12 +383,20 @@ bool Game::changeRoom(std::string file)
|
|||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
fillRoomNameTexture();
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
if (roomTracker->addRoom(file))
|
if (roomTracker->addRoom(file))
|
||||||
{ // Incrementa el contador de habitaciones visitadas
|
{
|
||||||
|
// Incrementa el contador de habitaciones visitadas
|
||||||
board.rooms++;
|
board.rooms++;
|
||||||
|
options->stats.rooms = board.rooms;
|
||||||
|
|
||||||
|
// Actualiza las estadisticas
|
||||||
|
stats->addVisit(room->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pasa la nueva habitación al jugador
|
// Pasa la nueva habitación al jugador
|
||||||
@@ -347,7 +413,7 @@ void Game::checkPlayerOnBorder()
|
|||||||
{
|
{
|
||||||
if (player->getOnBorder())
|
if (player->getOnBorder())
|
||||||
{
|
{
|
||||||
const std::string roomName = room->getRoom(player->getBorder());
|
const string roomName = room->getRoom(player->getBorder());
|
||||||
if (changeRoom(roomName))
|
if (changeRoom(roomName))
|
||||||
{
|
{
|
||||||
player->switchBorders();
|
player->switchBorders();
|
||||||
@@ -388,7 +454,7 @@ void Game::checkGameOver()
|
|||||||
{
|
{
|
||||||
if (board.lives < 0 && blackScreenCounter > 17)
|
if (board.lives < 0 && blackScreenCounter > 17)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_GAME_OVER;
|
section->name = SECTION_PROG_GAME_OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,6 +472,12 @@ void Game::killPlayer()
|
|||||||
board.lives--;
|
board.lives--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualiza las estadisticas
|
||||||
|
stats->addDeath(room->getName());
|
||||||
|
|
||||||
|
// Invalida el logro de pasarse el juego sin morir
|
||||||
|
cheevos->invalidate(11);
|
||||||
|
|
||||||
// Destruye la habitacion y el jugador
|
// Destruye la habitacion y el jugador
|
||||||
delete room;
|
delete room;
|
||||||
delete this->player;
|
delete this->player;
|
||||||
@@ -418,8 +490,8 @@ void Game::killPlayer()
|
|||||||
|
|
||||||
// Crea la nueva habitación y el nuevo jugador
|
// Crea la nueva habitación y el nuevo jugador
|
||||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
||||||
const std::string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
const string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
||||||
const std::string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
const string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
||||||
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
||||||
this->player = new Player(player);
|
this->player = new Player(player);
|
||||||
|
|
||||||
@@ -433,7 +505,7 @@ void Game::reLoadTextures()
|
|||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "** RELOAD REQUESTED" << std::endl;
|
cout << "** RELOAD REQUESTED" << endl;
|
||||||
}
|
}
|
||||||
player->reLoadTexture();
|
player->reLoadTexture();
|
||||||
room->reLoadTexture();
|
room->reLoadTexture();
|
||||||
@@ -446,7 +518,7 @@ void Game::switchPalette()
|
|||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "** PALETTE SWITCH REQUESTED" << std::endl;
|
cout << "** PALETTE SWITCH REQUESTED" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica la variable
|
// Modifica la variable
|
||||||
@@ -511,24 +583,21 @@ void Game::setScoreBoardColor()
|
|||||||
// Comprueba si ha finalizado el juego
|
// Comprueba si ha finalizado el juego
|
||||||
bool Game::checkEndGame()
|
bool Game::checkEndGame()
|
||||||
{
|
{
|
||||||
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
||||||
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
|
|
||||||
if (haveTheItems)
|
if (haveTheItems)
|
||||||
{
|
{
|
||||||
board.jailEnabled = true;
|
board.jailEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnTheRoom && haveTheItems && isOnTheDoor)
|
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENDING;
|
// Comprueba los logros de completar el juego
|
||||||
return true;
|
checkEndGameCheevos();
|
||||||
}
|
|
||||||
|
|
||||||
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor)
|
section->name = SECTION_PROG_ENDING;
|
||||||
{
|
|
||||||
section.name = SECTION_PROG_ENDING;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +608,7 @@ bool Game::checkEndGame()
|
|||||||
int Game::getTotalItems()
|
int Game::getTotalItems()
|
||||||
{
|
{
|
||||||
int items = 0;
|
int items = 0;
|
||||||
std::vector<res_room_t> *rooms = new std::vector<res_room_t>;
|
vector<res_room_t> *rooms = new vector<res_room_t>;
|
||||||
rooms = resource->getAllRooms();
|
rooms = resource->getAllRooms();
|
||||||
|
|
||||||
for (auto room : *rooms)
|
for (auto room : *rooms)
|
||||||
@@ -553,7 +622,7 @@ int Game::getTotalItems()
|
|||||||
// Va a la habitación designada
|
// Va a la habitación designada
|
||||||
void Game::goToRoom(int border)
|
void Game::goToRoom(int border)
|
||||||
{
|
{
|
||||||
const std::string roomName = room->getRoom(border);
|
const string roomName = room->getRoom(border);
|
||||||
if (changeRoom(roomName))
|
if (changeRoom(roomName))
|
||||||
{
|
{
|
||||||
currentRoom = roomName;
|
currentRoom = roomName;
|
||||||
@@ -578,3 +647,136 @@ void Game::switchPause()
|
|||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Da vidas al jugador cuando está en la Jail
|
||||||
|
void Game::checkRestoringJail()
|
||||||
|
{
|
||||||
|
if (room->getName() != "THE JAIL" || board.lives == 9)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
if (!paused)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Incrementa el numero de vidas
|
||||||
|
if (counter == 100)
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
board.lives++;
|
||||||
|
JA_PlaySound(deathSound);
|
||||||
|
|
||||||
|
// Invalida el logro de completar el juego sin entrar a la jail
|
||||||
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f);
|
||||||
|
if (!haveTheItems)
|
||||||
|
{
|
||||||
|
cheevos->invalidate(9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa el diccionario de las estadísticas
|
||||||
|
void Game::initStats()
|
||||||
|
{
|
||||||
|
vector<res_room_t> *rooms = new vector<res_room_t>;
|
||||||
|
rooms = resource->getAllRooms();
|
||||||
|
|
||||||
|
for (auto room : *rooms)
|
||||||
|
{
|
||||||
|
stats->addDictionary(room.room->number, room.room->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
stats->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea la textura con el nombre de la habitación
|
||||||
|
void Game::fillRoomNameTexture()
|
||||||
|
{
|
||||||
|
// Pone la textura como destino de renderizado
|
||||||
|
SDL_SetRenderTarget(renderer, roomNameTexture);
|
||||||
|
|
||||||
|
// Rellena la textura de color
|
||||||
|
const color_t color = stringToColor(options->palette, "white");
|
||||||
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// Escribe el texto en la textura
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
|
||||||
|
|
||||||
|
// Deja el renderizador por defecto
|
||||||
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba algunos logros
|
||||||
|
void Game::checkSomeCheevos()
|
||||||
|
{
|
||||||
|
// Logros sobre la cantidad de items
|
||||||
|
if (board.items == totalItems)
|
||||||
|
{
|
||||||
|
cheevos->unlock(4);
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.75f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.5f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.25f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logros sobre las habitaciones visitadas
|
||||||
|
if (board.rooms >= 60)
|
||||||
|
{
|
||||||
|
cheevos->unlock(7);
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 40)
|
||||||
|
{
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 20)
|
||||||
|
{
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void Game::checkEndGameCheevos()
|
||||||
|
{
|
||||||
|
// "Complete the game"
|
||||||
|
cheevos->unlock(8);
|
||||||
|
|
||||||
|
// "Complete the game without entering the jail"
|
||||||
|
cheevos->unlock(9);
|
||||||
|
|
||||||
|
// "Complete the game with all items"
|
||||||
|
if (board.items == totalItems)
|
||||||
|
{
|
||||||
|
cheevos->unlock(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Complete the game without dying"
|
||||||
|
cheevos->unlock(11);
|
||||||
|
|
||||||
|
// "Complete the game in under 30 minutes"
|
||||||
|
if (scoreboard->getMinutes() < 30)
|
||||||
|
{
|
||||||
|
cheevos->unlock(12);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,58 +1,66 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "cheevos.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/debug.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/input.h"
|
#include "jail_engine/debug.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/text.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "item_tracker.h"
|
#include "item_tracker.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "room_tracker.h"
|
#include "room_tracker.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "scoreboard.h"
|
#include "scoreboard.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
#define GAME_H
|
#define GAME_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Screen *screen; // Objeto encargado de manejar el renderizador
|
Screen *screen; // Objeto encargado de manejar el renderizador
|
||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Player *player; // Objeto con el jugador
|
Player *player; // Objeto con el jugador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
|
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
Resource *resource; // Objeto con los recursos
|
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Resource *resource; // Objeto con los recursos
|
||||||
options_t *options; // Puntero a las opciones del juego
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
||||||
|
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music music; // Musica que suena durante el juego
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
string currentRoom; // Fichero de la habitación actual
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
|
||||||
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
||||||
JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador
|
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
|
||||||
board_t board; // Estructura con los datos del marcador
|
board_t board; // Estructura con los datos del marcador
|
||||||
bool paused; // Indica si el juego se encuentra en pausa
|
bool paused; // Indica si el juego se encuentra en pausa
|
||||||
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
||||||
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
||||||
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
||||||
|
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void update();
|
void update();
|
||||||
@@ -75,7 +83,10 @@ private:
|
|||||||
void renderRoomName();
|
void renderRoomName();
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
bool changeRoom(std::string file);
|
bool changeRoom(string file);
|
||||||
|
|
||||||
|
// Comprueba el teclado
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
||||||
void checkPlayerOnBorder();
|
void checkPlayerOnBorder();
|
||||||
@@ -125,15 +136,30 @@ private:
|
|||||||
// Pone el juego en pausa
|
// Pone el juego en pausa
|
||||||
void switchPause();
|
void switchPause();
|
||||||
|
|
||||||
|
// Da vidas al jugador cuando está en la Jail
|
||||||
|
void checkRestoringJail();
|
||||||
|
|
||||||
|
// Inicializa el diccionario de las estadísticas
|
||||||
|
void initStats();
|
||||||
|
|
||||||
|
// Pone el nombre de la habitación en la textura
|
||||||
|
void fillRoomNameTexture();
|
||||||
|
|
||||||
|
// Comprueba algunos logros
|
||||||
|
void checkSomeCheevos();
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void checkEndGameCheevos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include "game_over.h"
|
#include "game_over.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,20 +22,20 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_GAME_OVER;
|
section->name = SECTION_PROG_GAME_OVER;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
endSection = 400;
|
endSection = 400;
|
||||||
iniFade = 310;
|
iniFade = 310;
|
||||||
fadeLenght = 20;
|
fadeLenght = 20;
|
||||||
playerSprite->setPosX(GAMECANVAS_CENTER_X + 10);
|
playerSprite->setPosX(GAMECANVAS_CENTER_X + 10);
|
||||||
playerSprite->setPosY(GAMECANVAS_CENTER_Y + 10);
|
playerSprite->setPosY(30);
|
||||||
tvSprite->setPosX(GAMECANVAS_CENTER_X - tvSprite->getAnimationClip(0, 0).w - 10);
|
tvSprite->setPosX(GAMECANVAS_CENTER_X - tvSprite->getAnimationClip(0, 0).w - 10);
|
||||||
tvSprite->setPosY(GAMECANVAS_CENTER_Y + 10);
|
tvSprite->setPosY(30);
|
||||||
|
|
||||||
// Inicializa el vector de colores
|
// Inicializa el vector de colores
|
||||||
const std::vector<std::string> colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
const vector<string> colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
||||||
for (auto cl : colorList)
|
for (auto cl : colorList)
|
||||||
{
|
{
|
||||||
colors.push_back(stringToColor(options->palette, cl));
|
colors.push_back(stringToColor(options->palette, cl));
|
||||||
@@ -55,14 +57,17 @@ GameOver::~GameOver()
|
|||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void GameOver::update()
|
void GameOver::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
updateColor();
|
updateColor();
|
||||||
@@ -73,12 +78,17 @@ void GameOver::update()
|
|||||||
// Actualiza los dos sprites
|
// Actualiza los dos sprites
|
||||||
playerSprite->update();
|
playerSprite->update();
|
||||||
tvSprite->update();
|
tvSprite->update();
|
||||||
|
|
||||||
|
// Actualiza las notificaciones
|
||||||
|
screen->updateNotifier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el final en pantalla
|
// Dibuja el final en pantalla
|
||||||
void GameOver::render()
|
void GameOver::render()
|
||||||
{
|
{
|
||||||
|
const int y = 32;
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
@@ -86,12 +96,22 @@ void GameOver::render()
|
|||||||
screen->clean();
|
screen->clean();
|
||||||
|
|
||||||
// Escribe el texto de GAME OVER
|
// Escribe el texto de GAME OVER
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - 20, "G A M E O V E R", 1, color);
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y, "G A M E O V E R", 1, color);
|
||||||
|
|
||||||
// Dibuja los sprites
|
// Dibuja los sprites
|
||||||
|
playerSprite->setPosY(y + 30);
|
||||||
|
tvSprite->setPosY(y + 30);
|
||||||
renderSprites();
|
renderSprites();
|
||||||
|
|
||||||
// text->write(0, 0, std::to_string(counter));
|
// Escribe el texto con las habitaciones y los items
|
||||||
|
const string itemsTxt = to_string(options->stats.items / 100) + to_string((options->stats.items % 100) / 10) + to_string(options->stats.items % 10);
|
||||||
|
const string roomsTxt = to_string(options->stats.rooms / 100) + to_string((options->stats.rooms % 100) / 10) + to_string(options->stats.rooms % 10);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 80, "ITEMS: " + itemsTxt, 1, color);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 90, "ROOMS: " + roomsTxt, 1, color);
|
||||||
|
|
||||||
|
// Escribe el texto con "Tu peor pesadilla"
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 110, "YOUR WORST NIGHTMARE IS", 1, color);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 120, options->stats.worstNightmare, 1, color);
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
@@ -106,71 +126,56 @@ void GameOver::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
|
||||||
screen->switchBorder();
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
screen->switchVideoMode();
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
|
||||||
screen->setWindowSize(1);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
|
||||||
screen->setWindowSize(2);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
|
||||||
screen->setWindowSize(3);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
|
||||||
screen->setWindowSize(4);
|
|
||||||
resource->reLoadTextures();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
switchPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Comprueba las entradas
|
||||||
section_t GameOver::run()
|
void GameOver::checkInput()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_GAME_OVER)
|
|
||||||
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchBorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->switchVideoMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->decWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
screen->incWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
switchPalette();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
void GameOver::run()
|
||||||
|
{
|
||||||
|
while (section->name == SECTION_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
@@ -180,16 +185,15 @@ void GameOver::updateColor()
|
|||||||
|
|
||||||
if (counter < half)
|
if (counter < half)
|
||||||
{
|
{
|
||||||
//const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
const float step = min(counter, fadeLenght) / (float)fadeLenght;
|
||||||
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
|
||||||
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
||||||
color = colors.at(index);
|
color = colors[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
const float step = min(max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
||||||
const int index = (colors.size() - 1) * step;
|
const int index = (colors.size() - 1) * step;
|
||||||
color = colors.at(index);
|
color = colors[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,8 +229,8 @@ void GameOver::updateCounters()
|
|||||||
// Comprueba si ha terminado la sección
|
// Comprueba si ha terminado la sección
|
||||||
else if (counter == endSection)
|
else if (counter == endSection)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/animatedsprite.h"
|
#include "jail_engine/animatedsprite.h"
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/text.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/texture.h"
|
#include "jail_engine/text.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/texture.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef GAME_OVER_H
|
#ifndef GAME_OVER_H
|
||||||
#define GAME_OVER_H
|
#define GAME_OVER_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class GameOver
|
class GameOver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -23,24 +26,25 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
AnimatedSprite *playerSprite; // Sprite con el jugador
|
AnimatedSprite *playerSprite; // Sprite con el jugador
|
||||||
AnimatedSprite *tvSprite; // Sprite con el televisor
|
AnimatedSprite *tvSprite; // Sprite con el televisor
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
vector<color_t> colors; // Vector con los colores para el fade
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
color_t color; // Color usado para el texto y los sprites
|
||||||
color_t color; // Color usado para el texto y los sprites
|
int endSection; // Contador: cuando acaba la sección
|
||||||
int endSection; // Contador: cuando acaba la sección
|
int iniFade; // Contador: cuando emiepza el fade
|
||||||
int iniFade; // Contador: cuando emiepza el fade
|
int fadeLenght; // Contador: duración del fade
|
||||||
int fadeLenght; // Contador: duración del fade
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
JA_Music music; // Musica que suena durante el juego
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -51,6 +55,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
void updateColor();
|
void updateColor();
|
||||||
|
|
||||||
@@ -65,13 +72,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameOver();
|
~GameOver();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
245
source/intro.cpp
@@ -1,14 +1,16 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -31,21 +33,13 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
preCounter = 0;
|
preCounter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_INTRO;
|
section->name = SECTION_PROG_INTRO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
loadCounter = 0;
|
loadCounter = 0;
|
||||||
lineCounter = 0;
|
|
||||||
loadingFirstPart = true;
|
loadingFirstPart = true;
|
||||||
|
loadRect = {0, 0, 51, 1};
|
||||||
// Ls lineas que tapan la primera textura
|
|
||||||
for (int i = 0; i < 192; ++i)
|
|
||||||
{
|
|
||||||
lines[i].x1 = 0;
|
|
||||||
lines[i].x2 = 257;
|
|
||||||
lines[i].y = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
||||||
for (int i = 0; i < 192; ++i)
|
for (int i = 0; i < 192; ++i)
|
||||||
@@ -90,89 +84,79 @@ void Intro::checkEventHandler()
|
|||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Intro::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_ESCAPE:
|
|
||||||
section.name = SECTION_PROG_QUIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
screen->switchBorder();
|
{
|
||||||
resource->reLoadTextures();
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F:
|
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
screen->switchVideoMode();
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchBorder();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
resource->reLoadTextures();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
resource->reLoadTextures();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
resource->reLoadTextures();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
resource->reLoadTextures();
|
switchPalette();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
switchPalette();
|
{
|
||||||
break;
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
default:
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestiona el contador de carga
|
// Gestiona el contador de carga
|
||||||
void Intro::updateLoad()
|
void Intro::updateLoad()
|
||||||
{
|
{
|
||||||
// Primera parte de la carga, la parte en blanco ynegro
|
// Primera parte de la carga, la parte en blanco y negro
|
||||||
if (loadingFirstPart)
|
if (loadingFirstPart)
|
||||||
{
|
{
|
||||||
// Cada 5 pasos el loadCounter se incrementa en uno
|
// Cada 5 pasos el loadCounter se incrementa en uno
|
||||||
const int numSteps = 5;
|
const int numSteps = 5;
|
||||||
|
const int step = 51;
|
||||||
loadCounter = counter / numSteps;
|
loadCounter = counter / numSteps;
|
||||||
|
|
||||||
if (loadCounter < 192)
|
if (loadCounter < 192)
|
||||||
{
|
{
|
||||||
const int step = 256 / numSteps;
|
loadRect.x = step * (counter % numSteps);
|
||||||
lines[lineIndex[loadCounter]].x1 = step * (counter % numSteps);
|
loadRect.y = lineIndex[loadCounter];
|
||||||
|
sprite1->setSpriteClip(loadRect);
|
||||||
// Elimina por completo la linea anterior
|
sprite1->setRect(loadRect);
|
||||||
if (loadCounter > 0)
|
|
||||||
{
|
|
||||||
lines[lineIndex[loadCounter - 1]].x1 = 256;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
|
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
|
||||||
else if (loadCounter == 192)
|
else if (loadCounter == 192)
|
||||||
{
|
{
|
||||||
loadingFirstPart = false;
|
loadingFirstPart = false;
|
||||||
loadCounter = 0;
|
loadCounter = 0;
|
||||||
|
loadRect = {0, 0, 16, 8};
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
JA_PlayMusic(loadingSound3);
|
JA_PlayMusic(loadingSound3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,70 +164,52 @@ void Intro::updateLoad()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadCounter += 2;
|
loadCounter += 2;
|
||||||
loadCounter = std::min(loadCounter, 768);
|
loadRect.x = (loadCounter * 8) % 256;
|
||||||
|
loadRect.y = (loadCounter / 32) * 8;
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la intro
|
||||||
|
if (loadCounter >= 768)
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
section->subsection = 0;
|
||||||
|
JA_StopMusic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
void Intro::updateCounter()
|
void Intro::updateCounter()
|
||||||
{
|
{
|
||||||
if (preCounter >= 50)
|
(preCounter >= 50) ? counter++ : preCounter++;
|
||||||
{ // Si el contador previo ha llegado a 50, empieza a contar el contador normal
|
|
||||||
if (counter == 0)
|
if (counter == 1)
|
||||||
{
|
{
|
||||||
JA_PlayMusic(loadingSound2);
|
JA_PlayMusic(loadingSound2);
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Actualiza el precontador
|
|
||||||
preCounter++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
void Intro::renderLoad()
|
void Intro::renderLoad()
|
||||||
{
|
{
|
||||||
// Carga 1 - Blanco y negro
|
loadingFirstPart ? sprite1->render() : sprite2->render();
|
||||||
if (loadingFirstPart)
|
|
||||||
{
|
|
||||||
// Dibuja la textura de pantalla de carga en blanco y negro en pantalla
|
|
||||||
sprite1->render();
|
|
||||||
|
|
||||||
// Dibuja las 192 lineas negras sobre la textura
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
||||||
for (int i = 0; i < 192; ++i)
|
|
||||||
{
|
|
||||||
SDL_RenderDrawLine(renderer, lines[i].x1, lines[i].y, lines[i].x2, lines[i].y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// Carga 2 - Color
|
|
||||||
{
|
|
||||||
sprite1->render();
|
|
||||||
SDL_Rect rect = {0, 0, 8, 8};
|
|
||||||
for (int i = 0; i < loadCounter; ++i)
|
|
||||||
{
|
|
||||||
rect.x = (i * 8) % 256;
|
|
||||||
rect.y = (i / 32) * 8;
|
|
||||||
sprite2->setRect(rect);
|
|
||||||
sprite2->setSpriteClip(rect);
|
|
||||||
sprite2->render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Intro::update()
|
void Intro::update()
|
||||||
{
|
{
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba las entradas
|
||||||
checkEventHandler();
|
checkInput();
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
updateCounter();
|
updateCounter();
|
||||||
@@ -251,13 +217,8 @@ void Intro::update()
|
|||||||
// Gestiona el contador de carga
|
// Gestiona el contador de carga
|
||||||
updateLoad();
|
updateLoad();
|
||||||
|
|
||||||
// Comprueba si ha terminado la intro
|
// Actualiza las notificaciones
|
||||||
if (loadCounter >= 768)
|
screen->updateNotifier();
|
||||||
{
|
|
||||||
section.name = SECTION_PROG_TITLE;
|
|
||||||
section.subsection = 0;
|
|
||||||
JA_StopMusic();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,9 +228,6 @@ void Intro::render()
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean();
|
|
||||||
|
|
||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
renderLoad();
|
renderLoad();
|
||||||
|
|
||||||
@@ -278,20 +236,24 @@ void Intro::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Intro::run()
|
void Intro::run()
|
||||||
{
|
{
|
||||||
// Inicia el sonido de carga
|
// Inicia el sonido de carga
|
||||||
JA_SetVolume(64);
|
JA_SetVolume(64);
|
||||||
JA_PlayMusic(loadingSound1);
|
JA_PlayMusic(loadingSound1);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_INTRO)
|
// Limpia la pantalla
|
||||||
|
screen->start();
|
||||||
|
screen->clean();
|
||||||
|
screen->blit();
|
||||||
|
|
||||||
|
while (section->name == SECTION_PROG_INTRO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
@@ -309,4 +271,45 @@ void Intro::switchPalette()
|
|||||||
sprite1->setTexture(resource->getTexture("loading_screen_bn.png"));
|
sprite1->setTexture(resource->getTexture("loading_screen_bn.png"));
|
||||||
sprite2->setTexture(resource->getTexture("loading_screen_color.png"));
|
sprite2->setTexture(resource->getTexture("loading_screen_color.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recreateLoadingScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reconstruye la pantalla de carga
|
||||||
|
void Intro::recreateLoadingScreen()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Primera parte de la carga, la parte en blanco y negro
|
||||||
|
if (loadingFirstPart)
|
||||||
|
{
|
||||||
|
const int numSteps = 5;
|
||||||
|
const int step = 51;
|
||||||
|
|
||||||
|
for (int i = 0; i <= counter; i++)
|
||||||
|
{
|
||||||
|
loadCounter = i / numSteps;
|
||||||
|
loadRect.x = step * (i % numSteps);
|
||||||
|
loadRect.y = lineIndex[loadCounter];
|
||||||
|
sprite1->setSpriteClip(loadRect);
|
||||||
|
sprite1->setRect(loadRect);
|
||||||
|
sprite1->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Segunda parte de la carga, la parte de los bloques en color
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= loadCounter; i++)
|
||||||
|
{
|
||||||
|
loadRect.x = (i * 8) % 256;
|
||||||
|
loadRect.y = (i / 32) * 8;
|
||||||
|
sprite2->setSpriteClip(loadRect);
|
||||||
|
sprite2->setRect(loadRect);
|
||||||
|
sprite2->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/jail_audio.h"
|
#include "jail_engine/input.h"
|
||||||
#include "common/resource.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "jail_engine/resource.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/sprite.h"
|
||||||
|
#include "jail_engine/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/text.h"
|
#include "jail_engine/text.h"
|
||||||
|
|
||||||
#ifndef INTRO_H
|
#ifndef INTRO_H
|
||||||
#define INTRO_H
|
#define INTRO_H
|
||||||
@@ -24,27 +25,27 @@ private:
|
|||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *loadingScreenTexture1; // Textura con la pantalla de carga en blanco y negro
|
Texture *loadingScreenTexture1; // Textura con la pantalla de carga en blanco y negro
|
||||||
Texture *loadingScreenTexture2; // Textura con la pantalla de carga en color
|
Texture *loadingScreenTexture2; // Textura con la pantalla de carga en color
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
||||||
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo para realizar una pausa inicial
|
int preCounter; // Contador previo para realizar una pausa inicial
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
int loadCounter; // Contador para controlar las cargas
|
||||||
int loadCounter; // Contador para controlar las cargas
|
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
|
||||||
int lineCounter; // Contador para dibujar las lineas de carga
|
JA_Music_t *loadingSound1; // Sonidos para imitar la carga tipo spectrum
|
||||||
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
|
JA_Music_t *loadingSound2; // Sonidos para imitar la carga tipo spectrum
|
||||||
JA_Music loadingSound1; // Sonidos para imitar la carga tipo spectrum
|
JA_Music_t *loadingSound3; // Sonidos para imitar la carga tipo spectrum
|
||||||
JA_Music loadingSound2; // Sonidos para imitar la carga tipo spectrum
|
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
|
||||||
JA_Music loadingSound3; // Sonidos para imitar la carga tipo spectrum
|
SDL_Rect loadRect; // Rectangulo para dibujar la pantalla de carga
|
||||||
h_line_t lines[192]; // Las 192 lineas que forman la pantalla de carga
|
|
||||||
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
|
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -55,6 +56,9 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Gestiona el contador interno
|
// Gestiona el contador interno
|
||||||
void updateCounter();
|
void updateCounter();
|
||||||
|
|
||||||
@@ -67,15 +71,18 @@ private:
|
|||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
void switchPalette();
|
void switchPalette();
|
||||||
|
|
||||||
|
// Reconstruye la pantalla de carga
|
||||||
|
void recreateLoadingScreen();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Item::~Item()
|
|||||||
void Item::render()
|
void Item::render()
|
||||||
{
|
{
|
||||||
const int index = (counter / colorChangeSpeed) % color.size();
|
const int index = (counter / colorChangeSpeed) % color.size();
|
||||||
sprite->getTexture()->setColor(color.at(index).r, color.at(index).g, color.at(index).b);
|
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
||||||
sprite->render();
|
sprite->render();
|
||||||
sprite->getTexture()->setColor(255, 255, 255);
|
sprite->getTexture()->setColor(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "jail_engine/asset.h"
|
||||||
#include "common/sprite.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "common/utils.h"
|
#include "jail_engine/utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef ITEM_H
|
#ifndef ITEM_H
|
||||||
#define ITEM_H
|
#define ITEM_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Texture *texture; // Textura con los graficos del item
|
Texture *texture; // Textura con los graficos del item
|
||||||
std::string tileSetFile; // Ruta al fichero con los graficos del item
|
string tileSetFile; // Ruta al fichero con los graficos del item
|
||||||
int x; // Posicion del item en pantalla
|
int x; // Posicion del item en pantalla
|
||||||
int y; // Posicion del item en pantalla
|
int y; // Posicion del item en pantalla
|
||||||
int tile; // Numero de tile dentro de la textura
|
int tile; // Numero de tile dentro de la textura
|
||||||
int counter; // Contador inicial. Es el que lo hace cambiar de color
|
int counter; // Contador inicial. Es el que lo hace cambiar de color
|
||||||
color_t color1; // Uno de los dos colores que se utiliza para el item
|
color_t color1; // Uno de los dos colores que se utiliza para el item
|
||||||
color_t color2; // Uno de los dos colores que se utiliza para el item
|
color_t color2; // Uno de los dos colores que se utiliza para el item
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
@@ -29,10 +31,10 @@ private:
|
|||||||
Sprite *sprite; // Sprite del objeto
|
Sprite *sprite; // Sprite del objeto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<color_t> color; // Vector con los colores del objeto
|
vector<color_t> color; // Vector con los colores del objeto
|
||||||
int counter; // Contador interno
|
int counter; // Contador interno
|
||||||
SDL_Rect collider; // Rectangulo de colisión
|
SDL_Rect collider; // Rectangulo de colisión
|
||||||
int colorChangeSpeed; // Cuanto mas alto, mas tarda en cambiar de color
|
int colorChangeSpeed; // Cuanto mas alto, mas tarda en cambiar de color
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ItemTracker::~ItemTracker()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el objeto ya ha sido cogido
|
// Comprueba si el objeto ya ha sido cogido
|
||||||
bool ItemTracker::hasBeenPicked(std::string name, SDL_Point pos)
|
bool ItemTracker::hasBeenPicked(string name, SDL_Point pos)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ bool ItemTracker::hasBeenPicked(std::string name, SDL_Point pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade el objeto a la lista de objetos cogidos
|
// Añade el objeto a la lista de objetos cogidos
|
||||||
void ItemTracker::addItem(std::string name, SDL_Point pos)
|
void ItemTracker::addItem(string name, SDL_Point pos)
|
||||||
{
|
{
|
||||||
// Comprueba si el objeto no ha sido recogido con anterioridad
|
// Comprueba si el objeto no ha sido recogido con anterioridad
|
||||||
if (!hasBeenPicked(name, pos))
|
if (!hasBeenPicked(name, pos))
|
||||||
@@ -50,7 +50,7 @@ void ItemTracker::addItem(std::string name, SDL_Point pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca una entrada en la lista por nombre
|
// Busca una entrada en la lista por nombre
|
||||||
int ItemTracker::findByName(std::string name)
|
int ItemTracker::findByName(string name)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ int ItemTracker::findByPos(int index, SDL_Point pos)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (auto l:list[index].pos)
|
for (auto l : list[index].pos)
|
||||||
{
|
{
|
||||||
if ((l.x == pos.x) && (l.y == pos.y))
|
if ((l.x == pos.x) && (l.y == pos.y))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/utils.h"
|
#include "jail_engine/utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef ITEM_TRACKER_H
|
#ifndef ITEM_TRACKER_H
|
||||||
#define ITEM_TRACKER_H
|
#define ITEM_TRACKER_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
struct item_tracker_t
|
struct item_tracker_t
|
||||||
{
|
{
|
||||||
std::string name; // Nombre de la habitación donde se encuentra el objeto
|
string name; // Nombre de la habitación donde se encuentra el objeto
|
||||||
std::vector<SDL_Point> pos; // Lista de objetos cogidos de la habitación
|
vector<SDL_Point> pos; // Lista de objetos cogidos de la habitación
|
||||||
};
|
};
|
||||||
|
|
||||||
class ItemTracker
|
class ItemTracker
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<item_tracker_t> list; // Lista con todos los objetos recogidos
|
vector<item_tracker_t> list; // Lista con todos los objetos recogidos
|
||||||
|
|
||||||
// Busca una entrada en la lista por nombre
|
// Busca una entrada en la lista por nombre
|
||||||
int findByName(std::string name);
|
int findByName(string name);
|
||||||
|
|
||||||
// Busca una entrada en la lista por posición
|
// Busca una entrada en la lista por posición
|
||||||
int findByPos(int index, SDL_Point pos);
|
int findByPos(int index, SDL_Point pos);
|
||||||
@@ -30,10 +32,10 @@ public:
|
|||||||
~ItemTracker();
|
~ItemTracker();
|
||||||
|
|
||||||
// Comprueba si el objeto ya ha sido cogido
|
// Comprueba si el objeto ya ha sido cogido
|
||||||
bool hasBeenPicked(std::string name, SDL_Point pos);
|
bool hasBeenPicked(string name, SDL_Point pos);
|
||||||
|
|
||||||
// Añade el objeto a la lista de objetos cogidos
|
// Añade el objeto a la lista de objetos cogidos
|
||||||
void addItem(std::string name, SDL_Point pos);
|
void addItem(string name, SDL_Point pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -222,121 +222,121 @@ int AnimatedSprite::getIndex(std::string name)
|
|||||||
// Calcula el frame correspondiente a la animación
|
// Calcula el frame correspondiente a la animación
|
||||||
void AnimatedSprite::animate()
|
void AnimatedSprite::animate()
|
||||||
{
|
{
|
||||||
if (!enabled || animation.at(currentAnimation).speed == 0)
|
if (!enabled || animation[currentAnimation].speed == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador
|
// Calcula el frame actual a partir del contador
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
// en función de la variable loop y coloca el nuevo frame
|
||||||
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size())
|
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
if (animation.at(currentAnimation).loop == -1)
|
if (animation[currentAnimation].loop == -1)
|
||||||
{ // Si no hay loop, deja el último frame
|
{ // Si no hay loop, deja el último frame
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size();
|
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
|
||||||
animation.at(currentAnimation).completed = true;
|
animation[currentAnimation].completed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Si hay loop, vuelve al frame indicado
|
{ // Si hay loop, vuelve al frame indicado
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// En caso contrario
|
// En caso contrario
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
// Incrementa el contador de la animacion
|
||||||
animation.at(currentAnimation).counter++;
|
animation[currentAnimation].counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el numero de frames de la animación actual
|
// Obtiene el numero de frames de la animación actual
|
||||||
int AnimatedSprite::getNumFrames()
|
int AnimatedSprite::getNumFrames()
|
||||||
{
|
{
|
||||||
return (int)animation.at(currentAnimation).frames.size();
|
return (int)animation[currentAnimation].frames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
// Establece el frame actual de la animación
|
||||||
void AnimatedSprite::setCurrentFrame(int num)
|
void AnimatedSprite::setCurrentFrame(int num)
|
||||||
{
|
{
|
||||||
// Descarta valores fuera de rango
|
// Descarta valores fuera de rango
|
||||||
if (num >= (int)animation.at(currentAnimation).frames.size())
|
if (num >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
// Cambia el valor de la variable
|
||||||
animation.at(currentAnimation).currentFrame = num;
|
animation[currentAnimation].currentFrame = num;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
|
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor del contador
|
// Establece el valor del contador
|
||||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = num;
|
animation[getIndex(name)].counter = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = speed;
|
animation[getIndex(name)].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||||
{
|
{
|
||||||
animation.at(index).counter = speed;
|
animation[index].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).loop = loop;
|
animation[getIndex(name)].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||||
{
|
{
|
||||||
animation.at(index).loop = loop;
|
animation[index].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).completed = value;
|
animation[getIndex(name)].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el valor de la variable
|
// OLD - Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||||
{
|
{
|
||||||
animation.at(index).completed = value;
|
animation[index].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
bool AnimatedSprite::animationIsCompleted()
|
bool AnimatedSprite::animationIsCompleted()
|
||||||
{
|
{
|
||||||
return animation.at(currentAnimation).completed;
|
return animation[currentAnimation].completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
||||||
{
|
{
|
||||||
return animation.at(getIndex(name)).frames.at(index);
|
return animation[getIndex(name)].frames[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
||||||
{
|
{
|
||||||
return animation.at(indexA).frames.at(indexF);
|
return animation[indexA].frames[indexF];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga la animación desde un vector
|
// Carga la animación desde un vector
|
||||||
@@ -484,9 +484,9 @@ void AnimatedSprite::setCurrentAnimation(std::string name)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +497,9 @@ void AnimatedSprite::setCurrentAnimation(int index)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ void AnimatedSprite::update()
|
|||||||
// Establece el rectangulo para un frame de una animación
|
// Establece el rectangulo para un frame de una animación
|
||||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
animation.at(index_animation).frames.push_back({x, y, w, h});
|
animation[index_animation].frames.push_back({x, y, w, h});
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el contador para todas las animaciones
|
// OLD - Establece el contador para todas las animaciones
|
||||||
@@ -528,7 +528,7 @@ void AnimatedSprite::setAnimationCounter(int value)
|
|||||||
// Reinicia la animación
|
// Reinicia la animación
|
||||||
void AnimatedSprite::resetAnimation()
|
void AnimatedSprite::resetAnimation()
|
||||||
{
|
{
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||