Compare commits
23 Commits
88041eba23
...
v2.1b
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c293a6b7f | |||
| a3599d2d3d | |||
| 7ab81eaf29 | |||
| 4f1a596e46 | |||
| b07baa4669 | |||
| cf357560b2 | |||
| 3d52c45f5c | |||
| 3276027044 | |||
| 8041595976 | |||
| fa53c1b01a | |||
| 20b362160e | |||
| 5cabbfc487 | |||
| 9f5e001c70 | |||
| 112c3afc76 | |||
| f4215384fe | |||
| 7796cee51a | |||
| f83154c062 | |||
| 9e73f7f97d | |||
| 742ca02573 | |||
| d77757853d | |||
| ca7ae7418e | |||
| f880bb7d74 | |||
| 9784b5517a |
15
.gitignore
vendored
@@ -1,6 +1,13 @@
|
|||||||
.vscode
|
.vscode
|
||||||
|
*config.txt
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
bin
|
thumbs.db
|
||||||
data/config.txt
|
*.exe
|
||||||
data/config.bin
|
*_macos
|
||||||
data/score.bin
|
*_linux
|
||||||
|
*.dmg
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
|
*.app
|
||||||
|
*config.bin
|
||||||
|
*score.bin
|
||||||
123
Makefile
@@ -1,17 +1,118 @@
|
|||||||
executable = coffee_crisis
|
executable = coffee_crisis
|
||||||
|
source = source/*.cpp source/common/*.cpp
|
||||||
|
appName = Coffee Crisis
|
||||||
|
releaseFolder = cc_release
|
||||||
|
version = v2.1b
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
if not exist bin\ (mkdir bin)
|
powershell if (Test-Path data\config\config.bin) {Remove-Item data\config\config.bin -Recurse -Force}
|
||||||
g++ -std=c++11 -Wall -O2 source/*.cpp -lmingw32 -lSDL2main -lSDL2 -o bin/$(executable).exe
|
powershell if (Test-Path data\config\score.bin) {Remove-Item data\config\score.bin -Recurse -Force}
|
||||||
|
g++ $(source) -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_release:
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
# Remove data
|
||||||
|
powershell if (Test-Path data\config\config.bin) {Remove-Item data\config\config.bin -Recurse -Force}
|
||||||
|
powershell if (Test-Path data\config\score.bin) {Remove-Item data\config\score.bin -Recurse -Force}
|
||||||
|
powershell if (Test-Path $(releaseFolder)) {Remove-Item $(releaseFolder) -Recurse -Force}
|
||||||
|
|
||||||
|
# Create folders
|
||||||
|
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 "LICENSE" -Destination "$(releaseFolder)"
|
||||||
|
powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
|
||||||
|
powershell Copy-Item "release/SDL2.dll" -Destination "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
g++ $(source) -D RELEASE -std=c++11 -Wall -Os -lmingw32 -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
|
||||||
|
|
||||||
|
# Create ZIP
|
||||||
|
powershell if (Test-Path $(executable)_win_$(version).zip) {Remove-Item $(executable)_win_$(version).zip}
|
||||||
|
powershell Compress-Archive -Path "$(releaseFolder)"/* -DestinationPath $(executable)_win_$(version).zip
|
||||||
|
|
||||||
|
# Remove folder
|
||||||
|
powershell if (Test-Path $(releaseFolder)) {Remove-Item $(releaseFolder) -Recurse -Force}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
mkdir -p bin
|
rm -f data/config/config.bin
|
||||||
g++ -std=c++11 -Wall -O2 -lSDL2 source/*.cpp -o bin/$(executable)_macos
|
rm -f data/config/score.bin
|
||||||
|
clang++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o $(executable)_macos -target arm64-apple-macos11
|
||||||
|
|
||||||
|
macos_release:
|
||||||
|
# Remove data
|
||||||
|
rm -f data/config/config.bin
|
||||||
|
rm -f data/config/score.bin
|
||||||
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Create folders
|
||||||
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Frameworks"
|
||||||
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/MacOS"
|
||||||
|
mkdir -p "$(releaseFolder)/$(appName).app/Contents/Resources"
|
||||||
|
mkdir -p Frameworks
|
||||||
|
|
||||||
|
# Copy folders
|
||||||
|
cp -R data "$(releaseFolder)/$(appName).app/Contents/Resources"
|
||||||
|
cp -R /Library/Frameworks/SDL2.framework "$(releaseFolder)/$(appName).app/Contents/Frameworks"
|
||||||
|
cp -R /Library/Frameworks/SDL2.framework Frameworks
|
||||||
|
|
||||||
|
# Copy files
|
||||||
|
cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources"
|
||||||
|
cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents"
|
||||||
|
|
||||||
|
# Build INTEL
|
||||||
|
clang++ $(source) -D RELEASE -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
|
||||||
|
|
||||||
|
# Build INTEL DMG
|
||||||
|
rm -f "$(executable)_macos_intel_$(version).dmg"
|
||||||
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
|
hdiutil convert tmp.dmg -format UDZO -o "$(executable)_macos_intel_$(version).dmg"
|
||||||
|
rm tmp.dmg
|
||||||
|
|
||||||
|
# Build APPLE SILICON
|
||||||
|
clang++ $(source) -D RELEASE -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 arm64-apple-macos11
|
||||||
|
|
||||||
|
# Build APPLE SILICON DMG
|
||||||
|
rm -f "$(executable)_macos_apple_silicon_$(version).dmg"
|
||||||
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
|
hdiutil convert tmp.dmg -format UDZO -o "$(executable)_macos_apple_silicon_$(version).dmg"
|
||||||
|
rm tmp.dmg
|
||||||
|
|
||||||
|
# Remove data
|
||||||
|
rm -rdf Frameworks
|
||||||
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
mkdir -p bin
|
rm -f data/config/config.bin
|
||||||
g++ source/*.cpp -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
rm -f data/config/score.bin
|
||||||
strip -s -R .comment -R .gnu.version bin/$(executable)_linux --strip-unneeded
|
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o $(executable)_linux
|
||||||
opendingux:
|
strip -s -R .comment -R .gnu.version $(executable)_linux --strip-unneeded
|
||||||
mkdir -p bin
|
|
||||||
/opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc -D GCWZERO -O2 -std=c++11 -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ source/*.cpp -o bin/$(executable)_opendingux
|
linux_release:
|
||||||
/opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./bin ./data ./media coffee_crisis.opk -all-root -noappend -no-exports -no-xattrs
|
# Remove data
|
||||||
|
rm -f data/config/config.bin
|
||||||
|
rm -f data/config/score.bin
|
||||||
|
rm -rdf $(releaseFolder)
|
||||||
|
|
||||||
|
# Create folders
|
||||||
|
mkdir -p $(releaseFolder)
|
||||||
|
|
||||||
|
# Copy data
|
||||||
|
cp -R data $(releaseFolder)
|
||||||
|
cp LICENSE $(releaseFolder)
|
||||||
|
cp README.md $(releaseFolder)
|
||||||
|
|
||||||
|
# Build
|
||||||
|
g++ $(source) -D RELEASE -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
|
||||||
|
|
||||||
|
# Pack files
|
||||||
|
cd $(releaseFolder) && tar -czvf ../$(executable)_linux_$(version).tar.gz *
|
||||||
|
|
||||||
|
# Remove data
|
||||||
|
rm -rdf $(releaseFolder)
|
||||||
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
data/gfx/menu_game_over_end.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
data/gfx/player_arounder_fire.png
Normal file
|
After Width: | Height: | Size: 887 B |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
data/gfx/player_bal1_fire.png
Normal file
|
After Width: | Height: | Size: 835 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -43,6 +43,8 @@ loop=0
|
|||||||
frames=20,21,22,23
|
frames=20,21,22,23
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=sideshoot
|
name=sideshoot
|
||||||
speed=5
|
speed=5
|
||||||
@@ -84,3 +86,91 @@ speed=5
|
|||||||
loop=0
|
loop=0
|
||||||
frames=44,45,46,47
|
frames=44,45,46,47
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk_pwr
|
||||||
|
speed=3
|
||||||
|
loop=0
|
||||||
|
frames=0,1,2,3
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand_pwr
|
||||||
|
speed=5
|
||||||
|
loop=0
|
||||||
|
frames=4,5,6,7
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk_1C_pwr
|
||||||
|
speed=3
|
||||||
|
loop=0
|
||||||
|
frames=8,9,10,11
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand_1C_pwr
|
||||||
|
speed=5
|
||||||
|
loop=0
|
||||||
|
frames=12,13,14,15
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk_2C_pwr
|
||||||
|
speed=3
|
||||||
|
loop=0
|
||||||
|
frames=16,17,18,19
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand_2C_pwr
|
||||||
|
speed=5
|
||||||
|
loop=0
|
||||||
|
frames=20,21,22,23
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=sideshoot_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=24,25,26,27
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=centershoot_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=28,29,30,31
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=sideshoot_1C_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=32,33,34,35
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=centershoot_1C_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=36,37,38,39
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=sideshoot_2C_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=40,41,42,43
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=centershoot_2C_pwr
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=44,45,46,47
|
||||||
|
[/animation]
|
||||||
9
data/gfx/player_fire.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frameWidth=28
|
||||||
|
frameHeight=32
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=5
|
||||||
|
loop=0
|
||||||
|
frames=0,1,2,3
|
||||||
|
[/animation]
|
||||||
@@ -61,54 +61,54 @@ frames=28,29,30,31
|
|||||||
name=sideshoot
|
name=sideshoot
|
||||||
speed=5
|
speed=5
|
||||||
loop=0
|
loop=0
|
||||||
frames=32,33,34,35
|
frames=16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=centershoot
|
name=centershoot
|
||||||
speed=5
|
speed=5
|
||||||
loop=0
|
loop=0
|
||||||
frames=36,37,38,39
|
frames=20,21,22,23
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=sideshoot_1C
|
name=sideshoot_1C
|
||||||
speed=5
|
speed=5
|
||||||
loop=0
|
loop=0
|
||||||
frames=40,41,42,43
|
frames=24,25,26,27
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=centershoot_1C
|
name=centershoot_1C
|
||||||
speed=5
|
speed=5
|
||||||
loop=0
|
loop=0
|
||||||
frames=44,45,46,47
|
frames=28,29,30,31
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=sideshoot_pwr
|
name=sideshoot_pwr
|
||||||
speed=5
|
speed=2
|
||||||
loop=0
|
loop=0
|
||||||
frames=48,49,50,51
|
frames=16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=centershoot_pwr
|
name=centershoot_pwr
|
||||||
speed=5
|
speed=2
|
||||||
loop=0
|
loop=0
|
||||||
frames=52,53,54,55
|
frames=20,21,22,23
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=sideshoot_1C_pwr
|
name=sideshoot_1C_pwr
|
||||||
speed=5
|
speed=2
|
||||||
loop=0
|
loop=0
|
||||||
frames=56,57,58,59
|
frames=24,25,26,27
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=centershoot_1C_pwr
|
name=centershoot_1C_pwr
|
||||||
speed=5
|
speed=2
|
||||||
loop=0
|
loop=0
|
||||||
frames=60,61,62,63
|
frames=28,29,30,31
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -115,14 +115,14 @@ D E M O
|
|||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
fases mes!
|
fases mes!
|
||||||
|
|
||||||
## 39 -
|
## 39 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Selecciona personatge
|
||||||
|
|
||||||
## 40 -
|
## 40 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Enrere
|
||||||
|
|
||||||
## 41 -
|
## 41 - MENU DE PAUSA
|
||||||
-
|
Menu de pausa
|
||||||
|
|
||||||
## 42 -
|
## 42 -
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -115,14 +115,14 @@ D E M O
|
|||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
stages left!
|
stages left!
|
||||||
|
|
||||||
## 39 -
|
## 39 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Select Player
|
||||||
|
|
||||||
## 40 -
|
## 40 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Back
|
||||||
|
|
||||||
## 41 -
|
## 41 - MENU DE PAUSA
|
||||||
-
|
Pause Menu
|
||||||
|
|
||||||
## 42 -
|
## 42 -
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -115,14 +115,14 @@ D E M O
|
|||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
fases mas!
|
fases mas!
|
||||||
|
|
||||||
## 39 -
|
## 39 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Selecciona jugador
|
||||||
|
|
||||||
## 40 -
|
## 40 - MENU SELECCION DE JUGADOR
|
||||||
-
|
Volver
|
||||||
|
|
||||||
## 41 -
|
## 41 - MENU DE PAUSA
|
||||||
-
|
Menu de pausa
|
||||||
|
|
||||||
## 42 -
|
## 42 -
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
font_png=smb2.png
|
font_png=smb2.png
|
||||||
font_txt=smb2.txt
|
font_txt=smb2.txt
|
||||||
|
|
||||||
sound_cancel=menu_cancel.wav
|
|
||||||
sound_accept=menu_select.wav
|
|
||||||
sound_move=menu_move.wav
|
sound_move=menu_move.wav
|
||||||
|
sound_accept=menu_select.wav
|
||||||
|
|
||||||
name=GAME OVER
|
name=GAME OVER
|
||||||
x=0
|
x=0
|
||||||
y=96
|
y=120
|
||||||
backgroundType=0
|
backgroundType=0
|
||||||
backgroundColor=0,0,0,255
|
backgroundColor=128,64,0,0
|
||||||
|
|
||||||
areElementsCenteredOnX=true
|
areElementsCenteredOnX=true
|
||||||
isCenteredOnX=true
|
isCenteredOnX=true
|
||||||
centerX=199
|
centerX=199
|
||||||
|
|
||||||
selector_color=84,110,122,0
|
selector_color=255,122,0,255
|
||||||
selector_text_color=255,122,0
|
selector_text_color=255,255,235
|
||||||
|
|
||||||
defaultActionWhenCancel=1
|
defaultActionWhenCancel=1
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
font_png=smb2.png
|
font_png=smb2.png
|
||||||
font_txt=smb2.txt
|
font_txt=smb2.txt
|
||||||
|
|
||||||
sound_cancel=menu_cancel.wav
|
|
||||||
sound_accept=menu_select.wav
|
|
||||||
sound_move=menu_move.wav
|
sound_move=menu_move.wav
|
||||||
|
sound_accept=menu_select.wav
|
||||||
|
|
||||||
name=OPTIONS
|
name=OPTIONS
|
||||||
x=0
|
x=0
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
font_png=smb2.png
|
font_png=smb2.png
|
||||||
font_txt=smb2.txt
|
font_txt=smb2.txt
|
||||||
|
|
||||||
sound_cancel=menu_cancel.wav
|
|
||||||
sound_accept=menu_select.wav
|
|
||||||
sound_move=menu_move.wav
|
sound_move=menu_move.wav
|
||||||
|
sound_accept=menu_select.wav
|
||||||
|
|
||||||
name=PAUSE
|
name=PAUSE
|
||||||
x=0
|
x=0
|
||||||
y=96
|
y=80
|
||||||
backgroundType=1
|
backgroundType=1
|
||||||
backgroundColor=41,57,65,240
|
backgroundColor=41,57,65,240
|
||||||
|
|
||||||
@@ -18,7 +17,13 @@ centerX=128
|
|||||||
selector_color=255,122,0,255
|
selector_color=255,122,0,255
|
||||||
selector_text_color=255,255,255
|
selector_text_color=255,255,255
|
||||||
|
|
||||||
defaultActionWhenCancel=0
|
defaultActionWhenCancel=1
|
||||||
|
|
||||||
|
[item]
|
||||||
|
text=PAUSE MENU
|
||||||
|
hPaddingDown=7
|
||||||
|
selectable=false
|
||||||
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=CONTINUE
|
text=CONTINUE
|
||||||
|
|||||||
40
data/menu/player_select.men
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
font_png=smb2.png
|
||||||
|
font_txt=smb2.txt
|
||||||
|
|
||||||
|
sound_move=menu_move.wav
|
||||||
|
sound_accept=menu_select.wav
|
||||||
|
|
||||||
|
name=PLAYER_SELECT
|
||||||
|
x=0
|
||||||
|
y=116
|
||||||
|
backgroundType=0
|
||||||
|
backgroundColor=48,48,64,192
|
||||||
|
|
||||||
|
areElementsCenteredOnX=true
|
||||||
|
isCenteredOnX=true
|
||||||
|
centerX=128
|
||||||
|
|
||||||
|
selector_color=229,28,35,0
|
||||||
|
selector_text_color=255,180,0
|
||||||
|
|
||||||
|
defaultActionWhenCancel=3
|
||||||
|
|
||||||
|
[item]
|
||||||
|
text=SELECT PLAYER
|
||||||
|
hPaddingDown=7
|
||||||
|
selectable=false
|
||||||
|
[/item]
|
||||||
|
|
||||||
|
[item]
|
||||||
|
text=BAL1
|
||||||
|
hPaddingDown=2
|
||||||
|
[/item]
|
||||||
|
|
||||||
|
[item]
|
||||||
|
text=AROUNDER
|
||||||
|
hPaddingDown=7
|
||||||
|
[/item]
|
||||||
|
|
||||||
|
[item]
|
||||||
|
text=BACK
|
||||||
|
[/item]
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
font_png=smb2.png
|
font_png=smb2.png
|
||||||
font_txt=smb2.txt
|
font_txt=smb2.txt
|
||||||
|
|
||||||
sound_cancel=menu_cancel.wav
|
|
||||||
sound_accept=menu_select.wav
|
|
||||||
sound_move=menu_move.wav
|
sound_move=menu_move.wav
|
||||||
|
sound_accept=menu_select.wav
|
||||||
|
|
||||||
name=TITLE
|
name=TITLE
|
||||||
x=0
|
x=0
|
||||||
|
|||||||
42
release/Info.plist
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>es</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>coffee_crisis</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>coffee_crisis</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>coffee_crisis</string>
|
||||||
|
<key>CFBundleIconName</key>
|
||||||
|
<string>coffee_crisis</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.jailgames.coffee_crisis</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>coffee_crisis</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0.0</string>
|
||||||
|
<key>CSResourcesFileMapped</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.12</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright 2022 JailDesigner</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
<key>SUPublicDSAKeyFile</key>
|
||||||
|
<string>dsa_pub.pem</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
BIN
release/SDL2.dll
Executable file
BIN
release/coffee_crisis.icns
Normal file
@@ -2,7 +2,7 @@
|
|||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
||||||
disable();
|
disable();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "utils.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "animatedsprite.h"
|
#include "common/utils.h"
|
||||||
#include <vector>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef BALLOON_H
|
#ifndef BALLOON_H
|
||||||
#define BALLOON_H
|
#define BALLOON_H
|
||||||
@@ -86,7 +86,7 @@ private:
|
|||||||
std::vector<float> h; // Vector con los valores de zoom para el alto del globo
|
std::vector<float> h; // Vector con los valores de zoom para el alto del globo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
AnimatedSprite *sprite; // Sprite del objeto globo
|
AnimatedSprite *sprite; // Sprite del objeto globo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -143,7 +143,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Balloon();
|
~Balloon();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer)
|
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "utils.h"
|
#include "common/sprite.h"
|
||||||
#include "sprite.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#ifndef BULLET_H
|
#ifndef BULLET_H
|
||||||
#define BULLET_H
|
#define BULLET_H
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
class Bullet
|
class Bullet
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
Sprite *sprite; // Sprite con los graficos y métodos de pintado
|
Sprite *sprite; // Sprite con los graficos y métodos de pintado
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -39,7 +39,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer);
|
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|||||||
15
source/common/Makefile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
executable = jaildoctors_dilemma
|
||||||
|
source = source/*.cpp source/common/*.cpp
|
||||||
|
|
||||||
|
windows:
|
||||||
|
@echo off
|
||||||
|
if not exist bin\ (mkdir bin)
|
||||||
|
g++ $(source) -std=c++11 -Wall -O2 -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o bin/$(executable).exe
|
||||||
|
strip -s -R .comment -R .gnu.version bin/$(executable).exe --strip-unneeded
|
||||||
|
macos:
|
||||||
|
mkdir -p bin
|
||||||
|
g++ $(source) -std=c++11 -Wall -O2 -lSDL2 -ffunction-sections -fdata-sections -o bin/$(executable)_macos
|
||||||
|
linux:
|
||||||
|
mkdir -p bin
|
||||||
|
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
||||||
|
strip -s -R .comment -R .gnu.version bin/$(executable)_linux --strip-unneeded
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "animatedsprite.h"
|
#include "animatedsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite::AnimatedSprite(LTexture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
@@ -88,6 +88,12 @@ void AnimatedSprite::animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene el numero de frames de la animación actual
|
||||||
|
int AnimatedSprite::getNumFrames()
|
||||||
|
{
|
||||||
|
return (int)animation.at(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)
|
||||||
{
|
{
|
||||||
@@ -304,7 +310,7 @@ bool AnimatedSprite::loadFromFile(std::string filePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setPos({0, 0, frameWidth, frameHeight});
|
setRect({0, 0, frameWidth, frameHeight});
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -442,7 +448,7 @@ bool AnimatedSprite::loadFromVector(std::vector<std::string> *source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setPos({0, 0, frameWidth, frameHeight});
|
setRect({0, 0, frameWidth, frameHeight});
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef ANIMATEDSPRITE_H
|
#ifndef ANIMATEDSPRITE_H
|
||||||
#define ANIMATEDSPRITE_H
|
#define ANIMATEDSPRITE_H
|
||||||
@@ -25,12 +25,14 @@ private:
|
|||||||
int currentFrame; // Frame actual
|
int currentFrame; // Frame actual
|
||||||
int counter; // Contador para las animaciones
|
int counter; // Contador para las animaciones
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Variables
|
||||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||||
int currentAnimation; // Animacion activa
|
int currentAnimation; // Animacion activa
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~AnimatedSprite();
|
~AnimatedSprite();
|
||||||
@@ -38,6 +40,9 @@ public:
|
|||||||
// Calcula el frame correspondiente a la animación actual
|
// Calcula el frame correspondiente a la animación actual
|
||||||
void animate();
|
void animate();
|
||||||
|
|
||||||
|
// Obtiene el numero de frames de la animación actual
|
||||||
|
int getNumFrames();
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
// Establece el frame actual de la animación
|
||||||
void setCurrentFrame(int num);
|
void setCurrentFrame(int num);
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Asset::Asset(std::string path)
|
Asset::Asset(std::string executablePath)
|
||||||
{
|
{
|
||||||
executablePath = path;
|
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
||||||
longest_name = 0;
|
longestName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -13,7 +13,7 @@ Asset::~Asset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void Asset::add(std::string file, enum assetType_e type, bool required)
|
void Asset::add(std::string file, enum assetType type, bool required)
|
||||||
{
|
{
|
||||||
item_t temp;
|
item_t temp;
|
||||||
temp.file = executablePath + file;
|
temp.file = executablePath + file;
|
||||||
@@ -22,7 +22,7 @@ void Asset::add(std::string file, enum assetType_e type, bool required)
|
|||||||
fileList.push_back(temp);
|
fileList.push_back(temp);
|
||||||
|
|
||||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
||||||
longest_name = SDL_max(longest_name, filename.size());
|
longestName = SDL_max(longestName, filename.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
||||||
@@ -106,7 +106,7 @@ bool Asset::checkFile(std::string path)
|
|||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string s = "Checking file %-" + std::to_string(longest_name) + "s [" + result + "]\n";
|
const std::string s = "Checking file %-" + std::to_string(longestName) + "s [" + result + "]\n";
|
||||||
printf(s.c_str(), filename.c_str());
|
printf(s.c_str(), filename.c_str());
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#ifndef ASSET_H
|
#ifndef ASSET_H
|
||||||
#define ASSET_H
|
#define ASSET_H
|
||||||
|
|
||||||
enum assetType_e
|
enum assetType
|
||||||
{
|
{
|
||||||
t_bitmap,
|
t_bitmap,
|
||||||
t_music,
|
t_music,
|
||||||
@@ -29,11 +29,11 @@ private:
|
|||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||||
enum assetType_e type; // Indica el tipo de recurso
|
enum assetType type; // Indica el tipo de recurso
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
bool required; // Indica si es un fichero que debe de existir
|
||||||
};
|
};
|
||||||
|
|
||||||
int longest_name; // Contiene la longitud del nombre de fichero mas largo
|
int longestName; // Contiene la longitud del nombre de fichero mas largo
|
||||||
|
|
||||||
std::vector<item_t> fileList;
|
std::vector<item_t> fileList;
|
||||||
std::string executablePath;
|
std::string executablePath;
|
||||||
@@ -46,13 +46,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Asset(std::string path);
|
Asset(std::string executablePath);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Asset();
|
~Asset();
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void add(std::string file, enum assetType_e type, bool required = true);
|
void add(std::string file, enum assetType type, bool required = true);
|
||||||
|
|
||||||
// Devuelve un elemento de la lista a partir de una cadena
|
// Devuelve un elemento de la lista a partir de una cadena
|
||||||
std::string get(std::string text);
|
std::string get(std::string text);
|
||||||
@@ -97,7 +97,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||||
{
|
{
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
@@ -108,11 +108,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!gameControllerBindings[input].active)
|
if (!gameControllerBindings.at(input).active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings[input].active = true;
|
gameControllerBindings.at(input).active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -122,9 +122,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) == 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings[input].active = false;
|
gameControllerBindings.at(input).active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -138,6 +138,44 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
return (successKeyboard || successGameController);
|
return (successKeyboard || successGameController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba si hay almenos un input activo
|
||||||
|
bool Input::checkAnyInput(int device, int index)
|
||||||
|
{
|
||||||
|
if (device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
||||||
|
{
|
||||||
|
if (mKeystates[keyBindings.at(i).scancode] != 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameControllerFound())
|
||||||
|
{
|
||||||
|
if (device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
||||||
|
{
|
||||||
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba si hay un mando conectado
|
// Comprueba si hay un mando conectado
|
||||||
bool Input::discoverGameController()
|
bool Input::discoverGameController()
|
||||||
{
|
{
|
||||||
@@ -74,6 +74,9 @@ public:
|
|||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|
||||||
|
// Comprueba si hay almenos un input activo
|
||||||
|
bool checkAnyInput(int device, int index);
|
||||||
|
|
||||||
// Comprueba si hay algun mando conectado
|
// Comprueba si hay algun mando conectado
|
||||||
bool gameControllerFound();
|
bool gameControllerFound();
|
||||||
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -20,6 +19,7 @@ Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
|||||||
itemSelected = MENU_NO_OPTION;
|
itemSelected = MENU_NO_OPTION;
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
|
w = 0;
|
||||||
rectBG.rect = {0, 0, 0, 0};
|
rectBG.rect = {0, 0, 0, 0};
|
||||||
rectBG.color = {0, 0, 0};
|
rectBG.color = {0, 0, 0};
|
||||||
rectBG.a = 0;
|
rectBG.a = 0;
|
||||||
@@ -57,6 +57,9 @@ Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
|||||||
{
|
{
|
||||||
load(file);
|
load(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deja el cursor en el primer elemento
|
||||||
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::~Menu()
|
Menu::~Menu()
|
||||||
@@ -167,9 +170,6 @@ bool Menu::load(std::string file_path)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorganiza el menu con los valores recien cargados
|
|
||||||
// reorganize();
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,6 +207,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
|||||||
else if ((var == "") || (var == "[/item]"))
|
else if ((var == "") || (var == "[/item]"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
@@ -351,11 +352,6 @@ bool Menu::setVars(std::string var, std::string value)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void Menu::init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga los ficheros de audio
|
// Carga los ficheros de audio
|
||||||
void Menu::loadAudioFile(std::string file, int sound)
|
void Menu::loadAudioFile(std::string file, int sound)
|
||||||
{
|
{
|
||||||
@@ -408,7 +404,8 @@ void Menu::updateSelector()
|
|||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selector.despY < 0) // Va hacia arriba
|
|
||||||
|
else if (selector.despY < 0) // Va hacia arriba
|
||||||
{
|
{
|
||||||
if (selector.y < selector.targetY) // Ha llegado al destino
|
if (selector.y < selector.targetY) // Ha llegado al destino
|
||||||
{
|
{
|
||||||
@@ -436,7 +433,8 @@ void Menu::updateSelector()
|
|||||||
selector.resizing = false;
|
selector.resizing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selector.incH < 0) // Decrece
|
|
||||||
|
else if (selector.incH < 0) // Decrece
|
||||||
{
|
{
|
||||||
if (selector.h < selector.targetH) // Ha llegado al destino
|
if (selector.h < selector.targetH) // Ha llegado al destino
|
||||||
{
|
{
|
||||||
@@ -459,7 +457,7 @@ void Menu::setSelectorPos(int index)
|
|||||||
if (index < (int)item.size())
|
if (index < (int)item.size())
|
||||||
{
|
{
|
||||||
selector.index = index;
|
selector.index = index;
|
||||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
|
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.rect.w = rectBG.rect.w;
|
selector.rect.w = rectBG.rect.w;
|
||||||
selector.rect.x = rectBG.rect.x;
|
selector.rect.x = rectBG.rect.x;
|
||||||
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
||||||
@@ -487,10 +485,17 @@ void Menu::reset()
|
|||||||
{
|
{
|
||||||
itemSelected = MENU_NO_OPTION;
|
itemSelected = MENU_NO_OPTION;
|
||||||
selector.index = 0;
|
selector.index = 0;
|
||||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
||||||
selector.originH = selector.targetH = item[0].rect.h;
|
selector.originH = selector.targetH = item.at(0).rect.h;
|
||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
selector.resizing = false;
|
selector.resizing = false;
|
||||||
|
|
||||||
|
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||||
|
if (!item.at(selector.index).selectable)
|
||||||
|
{
|
||||||
|
increaseSelectorIndex();
|
||||||
|
setSelectorPos(selector.index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
||||||
@@ -518,18 +523,18 @@ void Menu::reorganize()
|
|||||||
bool Menu::increaseSelectorIndex()
|
bool Menu::increaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item[selector.index].rect.y;
|
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
while (!item[selector.index].selectable)
|
while (!item.at(selector.index).selectable)
|
||||||
{
|
{
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item[selector.index].rect.y;
|
selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -548,7 +553,7 @@ bool Menu::increaseSelectorIndex()
|
|||||||
bool Menu::decreaseSelectorIndex()
|
bool Menu::decreaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item[selector.index].rect.y;
|
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
@@ -561,7 +566,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
selector.index--;
|
selector.index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!item[selector.index].selectable)
|
while (!item.at(selector.index).selectable)
|
||||||
{
|
{
|
||||||
if (selector.index == 0)
|
if (selector.index == 0)
|
||||||
{
|
{
|
||||||
@@ -574,7 +579,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item[selector.index].rect.y;
|
selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -608,8 +613,6 @@ void Menu::render()
|
|||||||
|
|
||||||
// Renderiza el rectangulo del selector
|
// Renderiza el rectangulo del selector
|
||||||
const SDL_Rect temp = {selector.rect.x, selector.rect.y - 1, selector.rect.w, selector.rect.h + 1};
|
const SDL_Rect temp = {selector.rect.x, selector.rect.y - 1, selector.rect.w, selector.rect.h + 1};
|
||||||
// temp.y--;
|
|
||||||
// temp.h++;
|
|
||||||
SDL_SetRenderDrawColor(renderer, selector.color.r, selector.color.g, selector.color.b, selector.a);
|
SDL_SetRenderDrawColor(renderer, selector.color.r, selector.color.g, selector.color.b, selector.a);
|
||||||
SDL_RenderFillRect(renderer, &temp);
|
SDL_RenderFillRect(renderer, &temp);
|
||||||
|
|
||||||
@@ -626,40 +629,74 @@ void Menu::render()
|
|||||||
if (i == selector.index)
|
if (i == selector.index)
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||||
}
|
}
|
||||||
else if (item[i].selectable)
|
|
||||||
|
else if (item.at(i).selectable)
|
||||||
{
|
{
|
||||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||||
}
|
}
|
||||||
else if (item[i].greyed)
|
|
||||||
|
else if (item.at(i).greyed)
|
||||||
{
|
{
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
// No seleccionable
|
{ // No seleccionable
|
||||||
{
|
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
||||||
if ((item[i].linkedUp) && (i == selector.index + 1))
|
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||||
}
|
}
|
||||||
else // No enlazado con el de arriba
|
else // No enlazado con el de arriba
|
||||||
{
|
{
|
||||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el rectangulo de fondo del menu y el selector
|
// Establece el rectangulo de fondo del menu y el selector
|
||||||
void Menu::setRectSize()
|
void Menu::setRectSize(int w, int h)
|
||||||
{
|
{
|
||||||
rectBG.rect.w = findWidth() + text->getCharacterSize();
|
// Establece el ancho
|
||||||
rectBG.rect.h = findHeight() + text->getCharacterSize();
|
if (w == 0)
|
||||||
|
{ // Si no se pasa un valor, se busca si hay uno prefijado
|
||||||
|
if (this->w == 0)
|
||||||
|
{ // Si no hay prefijado, coge el item mas ancho
|
||||||
|
rectBG.rect.w = findWidth() + text->getCharacterSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si hay prefijado, coge ese
|
||||||
|
rectBG.rect.w = this->w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si se pasa un valor, se usa y se prefija
|
||||||
|
rectBG.rect.w = w;
|
||||||
|
this->w = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el alto
|
||||||
|
if (h == 0)
|
||||||
|
{ // Si no se pasa un valor, se busca de manera automatica
|
||||||
|
rectBG.rect.h = findHeight() + text->getCharacterSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si se pasa un valor, se aplica
|
||||||
|
rectBG.rect.h = h;
|
||||||
|
}
|
||||||
|
|
||||||
// La posición X es la del menú menos medio caracter
|
// La posición X es la del menú menos medio caracter
|
||||||
rectBG.rect.x = x - (text->getCharacterSize() / 2);
|
if (this->w != 0)
|
||||||
|
{ // Si el ancho esta prefijado, la x coinccide
|
||||||
|
rectBG.rect.x = x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si el ancho es automatico, se le da un poco de margen
|
||||||
|
rectBG.rect.x = x - (text->getCharacterSize() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
// La posición Y es la del menu menos la altura de medio caracter
|
// La posición Y es la del menu menos la altura de medio caracter
|
||||||
rectBG.rect.y = y - (text->getCharacterSize() / 2);
|
rectBG.rect.y = y - (text->getCharacterSize() / 2);
|
||||||
@@ -692,10 +729,28 @@ void Menu::setSelectorTextColor(color_t color)
|
|||||||
void Menu::centerMenuOnX(int value)
|
void Menu::centerMenuOnX(int value)
|
||||||
{
|
{
|
||||||
isCenteredOnX = true;
|
isCenteredOnX = true;
|
||||||
centerX = value;
|
if (value != 0)
|
||||||
|
{
|
||||||
|
centerX = value;
|
||||||
|
}
|
||||||
|
else if (centerX == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Establece la nueva posición centrada en funcion del elemento más ancho
|
// Establece la nueva posición centrada en funcion del elemento más ancho o del ancho fijo del menu
|
||||||
x = (value) - (findWidth() / 2);
|
if (w != 0)
|
||||||
|
{ // Si se ha definido un ancho fijo
|
||||||
|
x = (centerX) - (w / 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si se actua en función del elemento más ancho
|
||||||
|
x = (centerX) - (findWidth() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza el rectangulo de fondo y del selector
|
||||||
|
rectBG.rect.x = x;
|
||||||
|
selector.rect.x = x;
|
||||||
|
|
||||||
// Reposiciona los elementos del menu
|
// Reposiciona los elementos del menu
|
||||||
for (auto &i : item)
|
for (auto &i : item)
|
||||||
@@ -705,6 +760,12 @@ void Menu::centerMenuOnX(int value)
|
|||||||
|
|
||||||
// Recalcula el rectangulo de fondo
|
// Recalcula el rectangulo de fondo
|
||||||
setRectSize();
|
setRectSize();
|
||||||
|
|
||||||
|
// Vuelve a centrar los elementos si fuera el caso
|
||||||
|
if (areElementsCenteredOnX)
|
||||||
|
{
|
||||||
|
centerMenuElementsOnX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Centra el menu respecto un punto en el eje Y
|
// Centra el menu respecto un punto en el eje Y
|
||||||
@@ -777,9 +838,6 @@ void Menu::setItemCaption(int index, std::string text)
|
|||||||
item.at(index).rect.w = this->text->lenght(item.at(index).label);
|
item.at(index).rect.w = this->text->lenght(item.at(index).label);
|
||||||
item.at(index).rect.h = this->text->getCharacterSize();
|
item.at(index).rect.h = this->text->getCharacterSize();
|
||||||
reorganize();
|
reorganize();
|
||||||
|
|
||||||
const std::string t = item.at(index).label + ":" + std::to_string(item.at(index).rect.w);
|
|
||||||
printf("Adding menu item -> %s\n", t.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el indice del itemm que se usará por defecto al cancelar el menu
|
// Establece el indice del itemm que se usará por defecto al cancelar el menu
|
||||||
@@ -855,42 +913,42 @@ int Menu::findHeight()
|
|||||||
// Recoloca los elementos del menu en el eje Y
|
// Recoloca los elementos del menu en el eje Y
|
||||||
void Menu::replaceElementsOnY()
|
void Menu::replaceElementsOnY()
|
||||||
{
|
{
|
||||||
item[0].rect.y = y;
|
item.at(0).rect.y = y;
|
||||||
|
|
||||||
for (int i = 1; i < (int)item.size(); i++)
|
for (int i = 1; i < (int)item.size(); i++)
|
||||||
{
|
{
|
||||||
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
|
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado seleccionable de un item
|
// Establece el estado seleccionable de un item
|
||||||
void Menu::setSelectable(int index, bool value)
|
void Menu::setSelectable(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].selectable = value;
|
item.at(index).selectable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado agrisado de un item
|
// Establece el estado agrisado de un item
|
||||||
void Menu::setGreyed(int index, bool value)
|
void Menu::setGreyed(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].greyed = value;
|
item.at(index).greyed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado de enlace de un item
|
// Establece el estado de enlace de un item
|
||||||
void Menu::setLinkedDown(int index, bool value)
|
void Menu::setLinkedDown(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].linkedDown = value;
|
item.at(index).linkedDown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula la altura del selector
|
// Calcula la altura del selector
|
||||||
int Menu::getSelectorHeight(int value)
|
int Menu::getSelectorHeight(int value)
|
||||||
{
|
{
|
||||||
if (item[value].linkedDown)
|
if (item.at(value).linkedDown)
|
||||||
{
|
{
|
||||||
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
|
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return item[value].rect.h;
|
return item.at(value).rect.h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <vector>
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include <sstream>
|
#include "sprite.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "utils.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
@@ -68,6 +68,13 @@ private:
|
|||||||
int a; // Cantidad de transparencia para el rectangulo del selector
|
int a; // Cantidad de transparencia para el rectangulo del selector
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Objetos y punteros
|
||||||
|
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||||
|
Text *text; // Texto para poder escribir los items del menu
|
||||||
|
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
||||||
|
Asset *asset; // Objeto para gestionar los ficheros de recursos
|
||||||
|
|
||||||
|
// Variables
|
||||||
std::string name; // Nombre del menu
|
std::string name; // Nombre del menu
|
||||||
int x; // Posición en el eje X de la primera letra del primer elemento
|
int x; // Posición en el eje X de la primera letra del primer elemento
|
||||||
int y; // Posición en el eje Y de la primera letra del primer elemento
|
int y; // Posición en el eje Y de la primera letra del primer elemento
|
||||||
@@ -85,10 +92,6 @@ private:
|
|||||||
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu
|
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu
|
||||||
JA_Sound soundCancel; // Sonido al cancelar el menu
|
JA_Sound soundCancel; // Sonido al cancelar el menu
|
||||||
JA_Sound soundMove; // Sonido al mover el selector
|
JA_Sound soundMove; // Sonido al mover el selector
|
||||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
|
||||||
Text *text; // Texto para poder escribir los items del menu
|
|
||||||
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
|
||||||
Asset *asset; // Objeto para gestionar los ficheros de recursos
|
|
||||||
color_t colorGreyed; // Color para los elementos agrisados
|
color_t colorGreyed; // Color para los elementos agrisados
|
||||||
rectangle_t rectBG; // Rectangulo de fondo del menu
|
rectangle_t rectBG; // Rectangulo de fondo del menu
|
||||||
std::vector<item_t> item; // Estructura para cada elemento del menu
|
std::vector<item_t> item; // Estructura para cada elemento del menu
|
||||||
@@ -105,12 +108,6 @@ private:
|
|||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setItem(item_t *item, std::string var, std::string value);
|
bool setItem(item_t *item, std::string var, std::string value);
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void init();
|
|
||||||
|
|
||||||
// Establece el rectangulo de fondo del menu
|
|
||||||
void setRectSize();
|
|
||||||
|
|
||||||
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
||||||
void reorganize();
|
void reorganize();
|
||||||
|
|
||||||
@@ -143,7 +140,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file="");
|
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file = "");
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Menu();
|
~Menu();
|
||||||
@@ -179,7 +176,7 @@ public:
|
|||||||
void setSelectorTextColor(color_t color);
|
void setSelectorTextColor(color_t color);
|
||||||
|
|
||||||
// Centra el menu respecto a un punto en el eje X
|
// Centra el menu respecto a un punto en el eje X
|
||||||
void centerMenuOnX(int value);
|
void centerMenuOnX(int value = 0);
|
||||||
|
|
||||||
// Centra el menu respecto a un punto en el eje Y
|
// Centra el menu respecto a un punto en el eje Y
|
||||||
void centerMenuOnY(int value);
|
void centerMenuOnY(int value);
|
||||||
@@ -219,6 +216,9 @@ public:
|
|||||||
|
|
||||||
// Establece la fuente de texto que se utilizará
|
// Establece la fuente de texto que se utilizará
|
||||||
void setText(std::string font_png, std::string font_txt);
|
void setText(std::string font_png, std::string font_txt);
|
||||||
|
|
||||||
|
// Establece el rectangulo de fondo del menu
|
||||||
|
void setRectSize(int w = 0, int h = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, LTexture *texture, SDL_Renderer *renderer)
|
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
@@ -51,11 +50,6 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
|
|||||||
currentFlip = SDL_FLIP_NONE;
|
currentFlip = SDL_FLIP_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destructor
|
|
||||||
MovingSprite::~MovingSprite()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinicia todas las variables
|
// Reinicia todas las variables
|
||||||
void MovingSprite::clear()
|
void MovingSprite::clear()
|
||||||
{
|
{
|
||||||
@@ -160,11 +154,13 @@ double MovingSprite::getAngle()
|
|||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición y el tamaño del objeto
|
||||||
void MovingSprite::setPos(SDL_Rect rect)
|
void MovingSprite::setRect(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
x = (float)rect.x;
|
x = (float)rect.x;
|
||||||
y = (float)rect.y;
|
y = (float)rect.y;
|
||||||
|
w = rect.w;
|
||||||
|
h = rect.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
@@ -333,15 +329,6 @@ SDL_Rect MovingSprite::getRect()
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece los valores de posición y tamaño del sprite
|
|
||||||
void MovingSprite::setRect(SDL_Rect rect)
|
|
||||||
{
|
|
||||||
x = (float)rect.x;
|
|
||||||
y = (float)rect.y;
|
|
||||||
w = rect.w;
|
|
||||||
h = rect.h;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void MovingSprite::undoMove()
|
void MovingSprite::undoMove()
|
||||||
{
|
{
|
||||||
@@ -35,10 +35,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~MovingSprite();
|
|
||||||
|
|
||||||
// Mueve el sprite
|
// Mueve el sprite
|
||||||
void move();
|
void move();
|
||||||
@@ -88,8 +85,8 @@ public:
|
|||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint16 getRotateSpeed();
|
Uint16 getRotateSpeed();
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición y el tamaño del objeto
|
||||||
void setPos(SDL_Rect rect);
|
void setRect(SDL_Rect rect);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPosX(float value);
|
void setPosX(float value);
|
||||||
@@ -151,9 +148,6 @@ public:
|
|||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect getRect();
|
SDL_Rect getRect();
|
||||||
|
|
||||||
// Establece los valores de posición y tamaño del sprite
|
|
||||||
void setRect(SDL_Rect rect);
|
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void undoMove();
|
void undoMove();
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
|||||||
|
|
||||||
// Crea la textura donde se dibujan los graficos del juego
|
// Crea la textura donde se dibujan los graficos del juego
|
||||||
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
||||||
if (gameCanvas == NULL)
|
if (gameCanvas == nullptr)
|
||||||
{
|
{
|
||||||
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
@@ -61,14 +61,14 @@ void Screen::start()
|
|||||||
void Screen::blit()
|
void Screen::blit()
|
||||||
{
|
{
|
||||||
// Vuelve a dejar el renderizador en modo normal
|
// Vuelve a dejar el renderizador en modo normal
|
||||||
SDL_SetRenderTarget(renderer, NULL);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
// Borra el contenido previo
|
// Borra el contenido previo
|
||||||
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||||
SDL_RenderCopy(renderer, gameCanvas, NULL, &dest);
|
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
|
||||||
|
|
||||||
// Muestra por pantalla el renderizador
|
// Muestra por pantalla el renderizador
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "smartsprite.h"
|
#include "smartsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite::SmartSprite(LTexture *texture, SDL_Renderer *renderer)
|
SmartSprite::SmartSprite(Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
@@ -12,11 +11,6 @@ SmartSprite::SmartSprite(LTexture *texture, SDL_Renderer *renderer)
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
SmartSprite::~SmartSprite()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
void SmartSprite::init()
|
void SmartSprite::init()
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
class SmartSprite : public AnimatedSprite
|
class SmartSprite : public AnimatedSprite
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// VAriables
|
// Variables
|
||||||
bool enabled; // Indica si esta habilitado
|
bool enabled; // Indica si esta habilitado
|
||||||
bool onDestination; // Indica si está en el destino
|
bool onDestination; // Indica si está en el destino
|
||||||
int destX; // Posicion de destino en el eje X
|
int destX; // Posicion de destino en el eje X
|
||||||
@@ -28,10 +28,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite(LTexture *texture, SDL_Renderer *renderer);
|
SmartSprite(Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~SmartSprite();
|
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
void init();
|
void init();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
this->x = x;
|
this->x = x;
|
||||||
@@ -24,7 +24,7 @@ Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *rend
|
|||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite::Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
x = rect.x;
|
x = rect.x;
|
||||||
@@ -137,13 +137,13 @@ void Sprite::setSpriteClip(int x, int y, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
LTexture *Sprite::getTexture()
|
Texture *Sprite::getTexture()
|
||||||
{
|
{
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setTexture(LTexture *texture)
|
void Sprite::setTexture(Texture *texture)
|
||||||
{
|
{
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
#ifndef SPRITE_H
|
#ifndef SPRITE_H
|
||||||
#define SPRITE_H
|
#define SPRITE_H
|
||||||
@@ -16,15 +16,15 @@ protected:
|
|||||||
int h; // Alto del sprite
|
int h; // Alto del sprite
|
||||||
|
|
||||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||||
LTexture *texture; // Textura donde estan todos los dibujos del sprite
|
Texture *texture; // Textura donde estan todos los dibujos del sprite
|
||||||
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||||
|
|
||||||
bool enabled; // Indica si el sprite esta habilitado
|
bool enabled; // Indica si el sprite esta habilitado
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||||
Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer);
|
Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Sprite();
|
~Sprite();
|
||||||
@@ -69,10 +69,10 @@ public:
|
|||||||
void setSpriteClip(int x, int y, int w, int h);
|
void setSpriteClip(int x, int y, int w, int h);
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
LTexture *getTexture();
|
Texture *getTexture();
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setTexture(LTexture *texture);
|
void setTexture(Texture *texture);
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
SDL_Renderer *getRenderer();
|
SDL_Renderer *getRenderer();
|
||||||
@@ -10,7 +10,7 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer)
|
|||||||
initOffsetFromFile(textFile);
|
initOffsetFromFile(textFile);
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
texture = new LTexture(renderer, bitmapFile);
|
texture = new Texture(renderer, bitmapFile);
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,9 @@ void Text::initOffsetFromFile(std::string file)
|
|||||||
{
|
{
|
||||||
// Almacena solo las lineas impares
|
// Almacena solo las lineas impares
|
||||||
if (line_read % 2 == 1)
|
if (line_read % 2 == 1)
|
||||||
|
{
|
||||||
offset[index++].w = std::stoi(buffer);
|
offset[index++].w = std::stoi(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
// Limpia el buffer
|
// Limpia el buffer
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
@@ -22,9 +22,9 @@ private:
|
|||||||
int w;
|
int w;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
Sprite *sprite; // Objeto con los graficos para el texto
|
Sprite *sprite; // Objeto con los graficos para el texto
|
||||||
LTexture *texture; // Textura con los bitmaps del texto
|
Texture *texture; // Textura con los bitmaps del texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
#include "ltexture.h"
|
#include "texture.h"
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LTexture::LTexture(SDL_Renderer *renderer, std::string path)
|
Texture::Texture(SDL_Renderer *renderer, std::string path)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -23,14 +23,14 @@ LTexture::LTexture(SDL_Renderer *renderer, std::string path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
LTexture::~LTexture()
|
Texture::~Texture()
|
||||||
{
|
{
|
||||||
// Libera memoria
|
// Libera memoria
|
||||||
unload();
|
unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||||
int req_format = STBI_rgb_alpha;
|
int req_format = STBI_rgb_alpha;
|
||||||
@@ -98,7 +98,7 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
||||||
{
|
{
|
||||||
// Crea una textura sin inicializar
|
// Crea una textura sin inicializar
|
||||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
|
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
|
||||||
@@ -116,7 +116,7 @@ bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Libera la memoria de la textura
|
// Libera la memoria de la textura
|
||||||
void LTexture::unload()
|
void Texture::unload()
|
||||||
{
|
{
|
||||||
// Libera la textura si existe
|
// Libera la textura si existe
|
||||||
if (texture != nullptr)
|
if (texture != nullptr)
|
||||||
@@ -129,25 +129,25 @@ void LTexture::unload()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el color para la modulacion
|
// Establece el color para la modulacion
|
||||||
void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
void Texture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
||||||
{
|
{
|
||||||
SDL_SetTextureColorMod(texture, red, green, blue);
|
SDL_SetTextureColorMod(texture, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el blending
|
// Establece el blending
|
||||||
void LTexture::setBlendMode(SDL_BlendMode blending)
|
void Texture::setBlendMode(SDL_BlendMode blending)
|
||||||
{
|
{
|
||||||
SDL_SetTextureBlendMode(texture, blending);
|
SDL_SetTextureBlendMode(texture, blending);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el alpha para la modulación
|
// Establece el alpha para la modulación
|
||||||
void LTexture::setAlpha(Uint8 alpha)
|
void Texture::setAlpha(Uint8 alpha)
|
||||||
{
|
{
|
||||||
SDL_SetTextureAlphaMod(texture, alpha);
|
SDL_SetTextureAlphaMod(texture, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza la textura en un punto específico
|
// Renderiza la textura en un punto específico
|
||||||
void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
void Texture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
// Establece el destino de renderizado en la pantalla
|
// Establece el destino de renderizado en la pantalla
|
||||||
SDL_Rect renderQuad = {x, y, width, height};
|
SDL_Rect renderQuad = {x, y, width, height};
|
||||||
@@ -167,25 +167,25 @@ void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, floa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece la textura como objetivo de renderizado
|
// Establece la textura como objetivo de renderizado
|
||||||
void LTexture::setAsRenderTarget(SDL_Renderer *renderer)
|
void Texture::setAsRenderTarget(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
SDL_SetRenderTarget(renderer, texture);
|
SDL_SetRenderTarget(renderer, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el ancho de la imagen
|
// Obtiene el ancho de la imagen
|
||||||
int LTexture::getWidth()
|
int Texture::getWidth()
|
||||||
{
|
{
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el alto de la imagen
|
// Obtiene el alto de la imagen
|
||||||
int LTexture::getHeight()
|
int Texture::getHeight()
|
||||||
{
|
{
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
bool LTexture::reLoad()
|
bool Texture::reLoad()
|
||||||
{
|
{
|
||||||
return loadFromFile(path, renderer);
|
return loadFromFile(path, renderer);
|
||||||
}
|
}
|
||||||
@@ -4,25 +4,27 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef LTEXTURE_H
|
#ifndef TEXTURE_H
|
||||||
#define LTEXTURE_H
|
#define TEXTURE_H
|
||||||
|
|
||||||
// Clase LTexture
|
class Texture
|
||||||
class LTexture
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// Objetos y punteros
|
||||||
SDL_Texture *texture; // La textura
|
SDL_Texture *texture; // La textura
|
||||||
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
||||||
int width; // Ancho de la imagen
|
|
||||||
int height; // Alto de la imagen
|
// Variables
|
||||||
std::string path; // Ruta de la imagen de la textura
|
int width; // Ancho de la imagen
|
||||||
|
int height; // Alto de la imagen
|
||||||
|
std::string path; // Ruta de la imagen de la textura
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
LTexture(SDL_Renderer *renderer, std::string path = "");
|
Texture(SDL_Renderer *renderer, std::string path = "");
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~LTexture();
|
~Texture();
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool loadFromFile(std::string path, SDL_Renderer *renderer);
|
bool loadFromFile(std::string path, SDL_Renderer *renderer);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "texture.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -87,6 +87,7 @@ struct input_t
|
|||||||
struct options_t
|
struct options_t
|
||||||
{
|
{
|
||||||
Uint8 difficulty; // Dificultad del juego
|
Uint8 difficulty; // Dificultad del juego
|
||||||
|
Uint8 playerSelected; // Jugador seleccionado para el modo 1P
|
||||||
std::vector<input_t> input; // Modo de control (teclado o mando)
|
std::vector<input_t> input; // Modo de control (teclado o mando)
|
||||||
Uint8 language; // Idioma usado en el juego
|
Uint8 language; // Idioma usado en el juego
|
||||||
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -22,11 +21,6 @@ Writer::Writer(Text *text)
|
|||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Writer::~Writer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Writer::update()
|
void Writer::update()
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
class Writer
|
class Writer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
Text *text; // Objeto encargado de escribir el texto
|
Text *text; // Objeto encargado de escribir el texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -32,9 +32,6 @@ public:
|
|||||||
// Constructor
|
// Constructor
|
||||||
Writer(Text *text);
|
Writer(Text *text);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Writer();
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "utils.h"
|
#include "common/utils.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
#ifndef CONST_H
|
#ifndef CONST_H
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "director.h"
|
#include "director.h"
|
||||||
#include "utils.h"
|
#include "common/utils.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -8,11 +8,10 @@
|
|||||||
Director::Director(std::string path)
|
Director::Director(std::string path)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section.name = PROG_SECTION_GAME;
|
section.name = PROG_SECTION_LOGO;
|
||||||
section.subsection = GAME_SECTION_PLAY_1P;
|
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
asset = new Asset(path.substr(0, path.find_last_of("\\/")) + "/../");
|
asset = new Asset(path);
|
||||||
|
|
||||||
// Establece la lista de ficheros
|
// Establece la lista de ficheros
|
||||||
if (!setFileList())
|
if (!setFileList())
|
||||||
@@ -161,118 +160,128 @@ bool Director::initSDL()
|
|||||||
// Crea el indice de ficheros
|
// Crea el indice de ficheros
|
||||||
bool Director::setFileList()
|
bool Director::setFileList()
|
||||||
{
|
{
|
||||||
|
#ifdef MACOS_BUNDLE
|
||||||
|
const std::string prefix = "/../Resources";
|
||||||
|
#else
|
||||||
|
const std::string prefix = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Ficheros de configuración
|
// Ficheros de configuración
|
||||||
asset->add("data/config/score.bin", t_data, false);
|
asset->add(prefix + "/data/config/score.bin", t_data, false);
|
||||||
asset->add("data/config/demo.bin", t_data);
|
asset->add(prefix + "/data/config/demo.bin", t_data);
|
||||||
asset->add("data/config/config.bin", t_data, false);
|
asset->add(prefix + "/data/config/config.bin", t_data, false);
|
||||||
asset->add("data/config/gamecontrollerdb.txt", t_data);
|
asset->add(prefix + "/data/config/gamecontrollerdb.txt", t_data);
|
||||||
|
|
||||||
// Musicas
|
// Musicas
|
||||||
asset->add("data/music/intro.ogg", t_music);
|
asset->add(prefix + "/data/music/intro.ogg", t_music);
|
||||||
asset->add("data/music/playing.ogg", t_music);
|
asset->add(prefix + "/data/music/playing.ogg", t_music);
|
||||||
asset->add("data/music/title.ogg", t_music);
|
asset->add(prefix + "/data/music/title.ogg", t_music);
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
asset->add("data/sound/balloon.wav", t_sound);
|
asset->add(prefix + "/data/sound/balloon.wav", t_sound);
|
||||||
asset->add("data/sound/bubble1.wav", t_sound);
|
asset->add(prefix + "/data/sound/bubble1.wav", t_sound);
|
||||||
asset->add("data/sound/bubble2.wav", t_sound);
|
asset->add(prefix + "/data/sound/bubble2.wav", t_sound);
|
||||||
asset->add("data/sound/bubble3.wav", t_sound);
|
asset->add(prefix + "/data/sound/bubble3.wav", t_sound);
|
||||||
asset->add("data/sound/bubble4.wav", t_sound);
|
asset->add(prefix + "/data/sound/bubble4.wav", t_sound);
|
||||||
asset->add("data/sound/bullet.wav", t_sound);
|
asset->add(prefix + "/data/sound/bullet.wav", t_sound);
|
||||||
asset->add("data/sound/coffeeout.wav", t_sound);
|
asset->add(prefix + "/data/sound/coffeeout.wav", t_sound);
|
||||||
asset->add("data/sound/hiscore.wav", t_sound);
|
asset->add(prefix + "/data/sound/hiscore.wav", t_sound);
|
||||||
asset->add("data/sound/itemdrop.wav", t_sound);
|
asset->add(prefix + "/data/sound/itemdrop.wav", t_sound);
|
||||||
asset->add("data/sound/itempickup.wav", t_sound);
|
asset->add(prefix + "/data/sound/itempickup.wav", t_sound);
|
||||||
asset->add("data/sound/menu_cancel.wav", t_sound);
|
asset->add(prefix + "/data/sound/menu_move.wav", t_sound);
|
||||||
asset->add("data/sound/menu_move.wav", t_sound);
|
asset->add(prefix + "/data/sound/menu_select.wav", t_sound);
|
||||||
asset->add("data/sound/menu_select.wav", t_sound);
|
asset->add(prefix + "/data/sound/player_collision.wav", t_sound);
|
||||||
asset->add("data/sound/player_collision.wav", t_sound);
|
asset->add(prefix + "/data/sound/stage_change.wav", t_sound);
|
||||||
asset->add("data/sound/stage_change.wav", t_sound);
|
asset->add(prefix + "/data/sound/title.wav", t_sound);
|
||||||
asset->add("data/sound/title.wav", t_sound);
|
asset->add(prefix + "/data/sound/clock.wav", t_sound);
|
||||||
asset->add("data/sound/clock.wav", t_sound);
|
asset->add(prefix + "/data/sound/powerball.wav", t_sound);
|
||||||
asset->add("data/sound/powerball.wav", t_sound);
|
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
asset->add("data/gfx/balloon1.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
|
||||||
asset->add("data/gfx/balloon1.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
||||||
asset->add("data/gfx/balloon2.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
|
||||||
asset->add("data/gfx/balloon2.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon2.ani", t_data);
|
||||||
asset->add("data/gfx/balloon3.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
|
||||||
asset->add("data/gfx/balloon3.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon3.ani", t_data);
|
||||||
asset->add("data/gfx/balloon4.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
|
||||||
asset->add("data/gfx/balloon4.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon4.ani", t_data);
|
||||||
asset->add("data/gfx/bullet.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/bullet.png", t_bitmap);
|
||||||
|
|
||||||
asset->add("data/gfx/game_buildings.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
|
||||||
asset->add("data/gfx/game_clouds.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_clouds.png", t_bitmap);
|
||||||
asset->add("data/gfx/game_grass.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_grass.png", t_bitmap);
|
||||||
asset->add("data/gfx/game_power_meter.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_power_meter.png", t_bitmap);
|
||||||
asset->add("data/gfx/game_sky_colors.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_sky_colors.png", t_bitmap);
|
||||||
asset->add("data/gfx/game_text.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_text.png", t_bitmap);
|
||||||
|
|
||||||
asset->add("data/gfx/intro.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/intro.png", t_bitmap);
|
||||||
asset->add("data/gfx/logo.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/logo.png", t_bitmap);
|
||||||
asset->add("data/gfx/menu_game_over.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
|
||||||
|
|
||||||
asset->add("data/gfx/item_points1_disk.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_points1_disk.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_points1_disk.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_points1_disk.ani", t_data);
|
||||||
asset->add("data/gfx/item_points2_gavina.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_points2_gavina.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_points2_gavina.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_points2_gavina.ani", t_data);
|
||||||
asset->add("data/gfx/item_points3_pacmar.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_points3_pacmar.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_points3_pacmar.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_points3_pacmar.ani", t_data);
|
||||||
asset->add("data/gfx/item_clock.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_clock.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_clock.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_clock.ani", t_data);
|
||||||
asset->add("data/gfx/item_coffee.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_coffee.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_coffee.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_coffee.ani", t_data);
|
||||||
asset->add("data/gfx/item_coffee_machine.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/item_coffee_machine.png", t_bitmap);
|
||||||
asset->add("data/gfx/item_coffee_machine.ani", t_data);
|
asset->add(prefix + "/data/gfx/item_coffee_machine.ani", t_data);
|
||||||
|
|
||||||
asset->add("data/gfx/title_bg_tile.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/title_bg_tile.png", t_bitmap);
|
||||||
asset->add("data/gfx/title_coffee.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/title_coffee.png", t_bitmap);
|
||||||
asset->add("data/gfx/title_crisis.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/title_crisis.png", t_bitmap);
|
||||||
asset->add("data/gfx/title_dust.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/title_dust.png", t_bitmap);
|
||||||
asset->add("data/gfx/title_dust.ani", t_data);
|
asset->add(prefix + "/data/gfx/title_dust.ani", t_data);
|
||||||
asset->add("data/gfx/title_gradient.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/title_gradient.png", t_bitmap);
|
||||||
|
|
||||||
asset->add("data/gfx/player_head.ani", t_data);
|
asset->add(prefix + "/data/gfx/player_head.ani", t_data);
|
||||||
asset->add("data/gfx/player_body.ani", t_data);
|
asset->add(prefix + "/data/gfx/player_body.ani", t_data);
|
||||||
asset->add("data/gfx/player_legs.ani", t_data);
|
asset->add(prefix + "/data/gfx/player_legs.ani", t_data);
|
||||||
asset->add("data/gfx/player_death.ani", t_data);
|
asset->add(prefix + "/data/gfx/player_death.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/player_fire.ani", t_data);
|
||||||
|
|
||||||
asset->add("data/gfx/player_bal1_head.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_bal1_head.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_bal1_body.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_bal1_body.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_bal1_legs.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_bal1_legs.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_bal1_death.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_bal1_death.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/player_bal1_fire.png", t_bitmap);
|
||||||
|
|
||||||
asset->add("data/gfx/player_arounder_head.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_arounder_head.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_arounder_body.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_arounder_body.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_arounder_legs.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_arounder_legs.png", t_bitmap);
|
||||||
asset->add("data/gfx/player_arounder_death.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/player_arounder_death.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/player_arounder_fire.png", t_bitmap);
|
||||||
|
|
||||||
// Fuentes
|
// Fuentes
|
||||||
asset->add("data/font/8bithud.png", t_font);
|
asset->add(prefix + "/data/font/8bithud.png", t_font);
|
||||||
asset->add("data/font/8bithud.txt", t_font);
|
asset->add(prefix + "/data/font/8bithud.txt", t_font);
|
||||||
asset->add("data/font/nokia.png", t_font);
|
asset->add(prefix + "/data/font/nokia.png", t_font);
|
||||||
asset->add("data/font/nokia_big2.png", t_font);
|
asset->add(prefix + "/data/font/nokia_big2.png", t_font);
|
||||||
asset->add("data/font/nokia.txt", t_font);
|
asset->add(prefix + "/data/font/nokia.txt", t_font);
|
||||||
asset->add("data/font/nokia2.png", t_font);
|
asset->add(prefix + "/data/font/nokia2.png", t_font);
|
||||||
asset->add("data/font/nokia2.txt", t_font);
|
asset->add(prefix + "/data/font/nokia2.txt", t_font);
|
||||||
asset->add("data/font/nokia_big2.txt", t_font);
|
asset->add(prefix + "/data/font/nokia_big2.txt", t_font);
|
||||||
asset->add("data/font/smb2_big.png", t_font);
|
asset->add(prefix + "/data/font/smb2_big.png", t_font);
|
||||||
asset->add("data/font/smb2_big.txt", t_font);
|
asset->add(prefix + "/data/font/smb2_big.txt", t_font);
|
||||||
asset->add("data/font/smb2.png", t_font);
|
asset->add(prefix + "/data/font/smb2.png", t_font);
|
||||||
asset->add("data/font/smb2.txt", t_font);
|
asset->add(prefix + "/data/font/smb2.txt", t_font);
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
asset->add("data/lang/es_ES.txt", t_lang);
|
asset->add(prefix + "/data/lang/es_ES.txt", t_lang);
|
||||||
asset->add("data/lang/en_UK.txt", t_lang);
|
asset->add(prefix + "/data/lang/en_UK.txt", t_lang);
|
||||||
asset->add("data/lang/ba_BA.txt", t_lang);
|
asset->add(prefix + "/data/lang/ba_BA.txt", t_lang);
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
asset->add("data/menu/title.men", t_data);
|
asset->add(prefix + "/data/menu/title.men", t_data);
|
||||||
asset->add("data/menu/options.men", t_data);
|
asset->add(prefix + "/data/menu/options.men", t_data);
|
||||||
asset->add("data/menu/pause.men", t_data);
|
asset->add(prefix + "/data/menu/pause.men", t_data);
|
||||||
asset->add("data/menu/gameover.men", t_data);
|
asset->add(prefix + "/data/menu/gameover.men", t_data);
|
||||||
|
asset->add(prefix + "/data/menu/player_select.men", t_data);
|
||||||
|
|
||||||
return asset->check();
|
return asset->check();
|
||||||
}
|
}
|
||||||
@@ -298,6 +307,7 @@ bool Director::loadConfigFile()
|
|||||||
options->windowSize = 3;
|
options->windowSize = 3;
|
||||||
options->language = ba_BA;
|
options->language = ba_BA;
|
||||||
options->difficulty = DIFFICULTY_NORMAL;
|
options->difficulty = DIFFICULTY_NORMAL;
|
||||||
|
options->playerSelected = 0;
|
||||||
options->filter = FILTER_NEAREST;
|
options->filter = FILTER_NEAREST;
|
||||||
options->vSync = true;
|
options->vSync = true;
|
||||||
options->screenWidth = GAME_WIDTH;
|
options->screenWidth = GAME_WIDTH;
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
|
||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/menu.h"
|
||||||
|
#include "common/movingsprite.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/smartsprite.h"
|
||||||
|
#include "common/sprite.h"
|
||||||
|
#include "common/text.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
#include "common/writer.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "input.h"
|
|
||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
#include "menu.h"
|
|
||||||
#include "movingsprite.h"
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "screen.h"
|
|
||||||
#include "smartsprite.h"
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "writer.h"
|
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
#define DIRECTOR_H
|
#define DIRECTOR_H
|
||||||
@@ -29,11 +29,10 @@
|
|||||||
// Textos
|
// Textos
|
||||||
#define WINDOW_CAPTION "Coffee Crisis"
|
#define WINDOW_CAPTION "Coffee Crisis"
|
||||||
|
|
||||||
// Clase Director
|
|
||||||
class Director
|
class Director
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Window *window; // La ventana donde dibujamos
|
SDL_Window *window; // La ventana donde dibujamos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "common/texture.h"
|
||||||
|
|
||||||
#ifndef FADE_H
|
#ifndef FADE_H
|
||||||
#define FADE_H
|
#define FADE_H
|
||||||
|
|||||||
660
source/game.cpp
@@ -45,6 +45,7 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
|
|||||||
grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer);
|
grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer);
|
||||||
powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer);
|
powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer);
|
||||||
gameOverSprite = new Sprite(16, 80, 128, 96, gameOverTexture, renderer);
|
gameOverSprite = new Sprite(16, 80, 128, 96, gameOverTexture, renderer);
|
||||||
|
gameOverEndSprite = new Sprite(PLAY_AREA_CENTER_X - gameOverEndTexture->getWidth() / 2, 80, 128, 96, gameOverEndTexture, renderer);
|
||||||
|
|
||||||
// Inicializa las variables necesarias para la sección 'Game'
|
// Inicializa las variables necesarias para la sección 'Game'
|
||||||
init();
|
init();
|
||||||
@@ -88,6 +89,9 @@ Game::~Game()
|
|||||||
gameOverTexture->unload();
|
gameOverTexture->unload();
|
||||||
delete gameOverTexture;
|
delete gameOverTexture;
|
||||||
|
|
||||||
|
gameOverEndTexture->unload();
|
||||||
|
delete gameOverEndTexture;
|
||||||
|
|
||||||
// Animaciones
|
// Animaciones
|
||||||
for (auto animation : playerAnimations)
|
for (auto animation : playerAnimations)
|
||||||
{
|
{
|
||||||
@@ -157,6 +161,8 @@ Game::~Game()
|
|||||||
delete skyColorsSprite;
|
delete skyColorsSprite;
|
||||||
delete grassSprite;
|
delete grassSprite;
|
||||||
delete powerMeterSprite;
|
delete powerMeterSprite;
|
||||||
|
delete gameOverSprite;
|
||||||
|
delete gameOverEndSprite;
|
||||||
|
|
||||||
JA_DeleteSound(balloonSound);
|
JA_DeleteSound(balloonSound);
|
||||||
JA_DeleteSound(bulletSound);
|
JA_DeleteSound(bulletSound);
|
||||||
@@ -183,23 +189,24 @@ void Game::init()
|
|||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
|
|
||||||
// Crea los jugadores
|
// Elimina qualquier jugador que hubiese antes de crear los nuevos
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
{
|
{
|
||||||
delete player;
|
delete player;
|
||||||
};
|
};
|
||||||
players.clear();
|
players.clear();
|
||||||
|
|
||||||
|
// Crea los jugadores
|
||||||
if (numPlayers == 1)
|
if (numPlayers == 1)
|
||||||
{
|
{
|
||||||
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, player1Textures, playerAnimations);
|
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(options->playerSelected), playerAnimations);
|
||||||
players.push_back(player);
|
players.push_back(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (numPlayers == 2)
|
else if (numPlayers == 2)
|
||||||
{
|
{
|
||||||
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, player1Textures, playerAnimations);
|
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(0), playerAnimations);
|
||||||
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, player2Textures, playerAnimations);
|
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(1), playerAnimations);
|
||||||
players.push_back(player1);
|
players.push_back(player1);
|
||||||
players.push_back(player2);
|
players.push_back(player2);
|
||||||
}
|
}
|
||||||
@@ -212,12 +219,15 @@ void Game::init()
|
|||||||
difficultyScoreMultiplier = 0.5f;
|
difficultyScoreMultiplier = 0.5f;
|
||||||
difficultyColor = {75, 105, 47};
|
difficultyColor = {75, 105, 47};
|
||||||
pauseMenu->setSelectorColor(difficultyColor, 255);
|
pauseMenu->setSelectorColor(difficultyColor, 255);
|
||||||
|
gameOverMenu->setSelectorColor(difficultyColor, 255);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIFFICULTY_NORMAL:
|
case DIFFICULTY_NORMAL:
|
||||||
defaultEnemySpeed = BALLOON_SPEED_1;
|
defaultEnemySpeed = BALLOON_SPEED_1;
|
||||||
difficultyScoreMultiplier = 1.0f;
|
difficultyScoreMultiplier = 1.0f;
|
||||||
difficultyColor = {46, 63, 71};
|
difficultyColor = {255, 122, 0};
|
||||||
|
pauseMenu->setSelectorColor(difficultyColor, 255);
|
||||||
|
gameOverMenu->setSelectorColor(difficultyColor, 255);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIFFICULTY_HARD:
|
case DIFFICULTY_HARD:
|
||||||
@@ -225,11 +235,13 @@ void Game::init()
|
|||||||
difficultyScoreMultiplier = 1.5f;
|
difficultyScoreMultiplier = 1.5f;
|
||||||
difficultyColor = {118, 66, 138};
|
difficultyColor = {118, 66, 138};
|
||||||
pauseMenu->setSelectorColor(difficultyColor, 255);
|
pauseMenu->setSelectorColor(difficultyColor, 255);
|
||||||
|
gameOverMenu->setSelectorColor(difficultyColor, 255);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gameCompleted = false;
|
gameCompleted = false;
|
||||||
gameCompletedCounter = 0;
|
gameCompletedCounter = 0;
|
||||||
section.name = PROG_SECTION_GAME;
|
section.name = PROG_SECTION_GAME;
|
||||||
@@ -261,6 +273,8 @@ void Game::init()
|
|||||||
powerBallEnabled = false;
|
powerBallEnabled = false;
|
||||||
powerBallCounter = 0;
|
powerBallCounter = 0;
|
||||||
coffeeMachineEnabled = false;
|
coffeeMachineEnabled = false;
|
||||||
|
pauseCounter = 0;
|
||||||
|
leavingPauseMenu = false;
|
||||||
|
|
||||||
if (demo.enabled)
|
if (demo.enabled)
|
||||||
{
|
{
|
||||||
@@ -289,6 +303,12 @@ void Game::init()
|
|||||||
balloonsPopped += stage[i].powerToComplete;
|
balloonsPopped += stage[i].powerToComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalPowerToCompleteGame = 0;
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
totalPowerToCompleteGame += stage[i].powerToComplete;
|
||||||
|
}
|
||||||
|
|
||||||
// Modo demo
|
// Modo demo
|
||||||
demo.recording = false;
|
demo.recording = false;
|
||||||
demo.counter = 0;
|
demo.counter = 0;
|
||||||
@@ -371,73 +391,84 @@ void Game::loadMedia()
|
|||||||
loadDemoFile();
|
loadDemoFile();
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
bulletTexture = new LTexture(renderer, asset->get("bullet.png"));
|
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
|
||||||
gameBuildingsTexture = new LTexture(renderer, asset->get("game_buildings.png"));
|
gameBuildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
||||||
gameCloudsTexture = new LTexture(renderer, asset->get("game_clouds.png"));
|
gameCloudsTexture = new Texture(renderer, asset->get("game_clouds.png"));
|
||||||
gameGrassTexture = new LTexture(renderer, asset->get("game_grass.png"));
|
gameGrassTexture = new Texture(renderer, asset->get("game_grass.png"));
|
||||||
gamePowerMeterTexture = new LTexture(renderer, asset->get("game_power_meter.png"));
|
gamePowerMeterTexture = new Texture(renderer, asset->get("game_power_meter.png"));
|
||||||
gameSkyColorsTexture = new LTexture(renderer, asset->get("game_sky_colors.png"));
|
gameSkyColorsTexture = new Texture(renderer, asset->get("game_sky_colors.png"));
|
||||||
gameTextTexture = new LTexture(renderer, asset->get("game_text.png"));
|
gameTextTexture = new Texture(renderer, asset->get("game_text.png"));
|
||||||
gameOverTexture = new LTexture(renderer, asset->get("menu_game_over.png"));
|
gameOverTexture = new Texture(renderer, asset->get("menu_game_over.png"));
|
||||||
|
gameOverEndTexture = new Texture(renderer, asset->get("menu_game_over_end.png"));
|
||||||
|
|
||||||
// Texturas - Globos
|
// Texturas - Globos
|
||||||
LTexture *balloon1Texture = new LTexture(renderer, asset->get("balloon1.png"));
|
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png"));
|
||||||
balloonTextures.push_back(balloon1Texture);
|
balloonTextures.push_back(balloon1Texture);
|
||||||
|
|
||||||
LTexture *balloon2Texture = new LTexture(renderer, asset->get("balloon2.png"));
|
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.png"));
|
||||||
balloonTextures.push_back(balloon2Texture);
|
balloonTextures.push_back(balloon2Texture);
|
||||||
|
|
||||||
LTexture *balloon3Texture = new LTexture(renderer, asset->get("balloon3.png"));
|
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.png"));
|
||||||
balloonTextures.push_back(balloon3Texture);
|
balloonTextures.push_back(balloon3Texture);
|
||||||
|
|
||||||
LTexture *balloon4Texture = new LTexture(renderer, asset->get("balloon4.png"));
|
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.png"));
|
||||||
balloonTextures.push_back(balloon4Texture);
|
balloonTextures.push_back(balloon4Texture);
|
||||||
|
|
||||||
// Texturas - Items
|
// Texturas - Items
|
||||||
LTexture *item1 = new LTexture(renderer, asset->get("item_points1_disk.png"));
|
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
||||||
itemTextures.push_back(item1);
|
itemTextures.push_back(item1);
|
||||||
|
|
||||||
LTexture *item2 = new LTexture(renderer, asset->get("item_points2_gavina.png"));
|
Texture *item2 = new Texture(renderer, asset->get("item_points2_gavina.png"));
|
||||||
itemTextures.push_back(item2);
|
itemTextures.push_back(item2);
|
||||||
|
|
||||||
LTexture *item3 = new LTexture(renderer, asset->get("item_points3_pacmar.png"));
|
Texture *item3 = new Texture(renderer, asset->get("item_points3_pacmar.png"));
|
||||||
itemTextures.push_back(item3);
|
itemTextures.push_back(item3);
|
||||||
|
|
||||||
LTexture *item4 = new LTexture(renderer, asset->get("item_clock.png"));
|
Texture *item4 = new Texture(renderer, asset->get("item_clock.png"));
|
||||||
itemTextures.push_back(item4);
|
itemTextures.push_back(item4);
|
||||||
|
|
||||||
LTexture *item5 = new LTexture(renderer, asset->get("item_coffee.png"));
|
Texture *item5 = new Texture(renderer, asset->get("item_coffee.png"));
|
||||||
itemTextures.push_back(item5);
|
itemTextures.push_back(item5);
|
||||||
|
|
||||||
LTexture *item6 = new LTexture(renderer, asset->get("item_coffee_machine.png"));
|
Texture *item6 = new Texture(renderer, asset->get("item_coffee_machine.png"));
|
||||||
itemTextures.push_back(item6);
|
itemTextures.push_back(item6);
|
||||||
|
|
||||||
// Texturas - Player1
|
// Texturas - Player1
|
||||||
LTexture *player1Head = new LTexture(renderer, asset->get("player_bal1_head.png"));
|
Texture *player1Head = new Texture(renderer, asset->get("player_bal1_head.png"));
|
||||||
player1Textures.push_back(player1Head);
|
player1Textures.push_back(player1Head);
|
||||||
|
|
||||||
LTexture *player1Body = new LTexture(renderer, asset->get("player_bal1_body.png"));
|
Texture *player1Body = new Texture(renderer, asset->get("player_bal1_body.png"));
|
||||||
player1Textures.push_back(player1Body);
|
player1Textures.push_back(player1Body);
|
||||||
|
|
||||||
LTexture *player1Legs = new LTexture(renderer, asset->get("player_bal1_legs.png"));
|
Texture *player1Legs = new Texture(renderer, asset->get("player_bal1_legs.png"));
|
||||||
player1Textures.push_back(player1Legs);
|
player1Textures.push_back(player1Legs);
|
||||||
|
|
||||||
LTexture *player1Death = new LTexture(renderer, asset->get("player_bal1_death.png"));
|
Texture *player1Death = new Texture(renderer, asset->get("player_bal1_death.png"));
|
||||||
player1Textures.push_back(player1Death);
|
player1Textures.push_back(player1Death);
|
||||||
|
|
||||||
|
Texture *player1Fire = new Texture(renderer, asset->get("player_bal1_fire.png"));
|
||||||
|
player1Textures.push_back(player1Fire);
|
||||||
|
|
||||||
|
playerTextures.push_back(player1Textures);
|
||||||
|
|
||||||
// Texturas - Player2
|
// Texturas - Player2
|
||||||
LTexture *player2Head = new LTexture(renderer, asset->get("player_arounder_head.png"));
|
Texture *player2Head = new Texture(renderer, asset->get("player_arounder_head.png"));
|
||||||
player2Textures.push_back(player2Head);
|
player2Textures.push_back(player2Head);
|
||||||
|
|
||||||
LTexture *player2Body = new LTexture(renderer, asset->get("player_arounder_body.png"));
|
Texture *player2Body = new Texture(renderer, asset->get("player_arounder_body.png"));
|
||||||
player2Textures.push_back(player2Body);
|
player2Textures.push_back(player2Body);
|
||||||
|
|
||||||
LTexture *player2Legs = new LTexture(renderer, asset->get("player_arounder_legs.png"));
|
Texture *player2Legs = new Texture(renderer, asset->get("player_arounder_legs.png"));
|
||||||
player2Textures.push_back(player2Legs);
|
player2Textures.push_back(player2Legs);
|
||||||
|
|
||||||
LTexture *player2Death = new LTexture(renderer, asset->get("player_arounder_death.png"));
|
Texture *player2Death = new Texture(renderer, asset->get("player_arounder_death.png"));
|
||||||
player2Textures.push_back(player2Death);
|
player2Textures.push_back(player2Death);
|
||||||
|
|
||||||
|
Texture *player2Fire = new Texture(renderer, asset->get("player_arounder_fire.png"));
|
||||||
|
player2Textures.push_back(player2Fire);
|
||||||
|
|
||||||
|
playerTextures.push_back(player2Textures);
|
||||||
|
|
||||||
// Animaciones -- Jugador
|
// Animaciones -- Jugador
|
||||||
std::vector<std::string> *playerHeadAnimation = new std::vector<std::string>;
|
std::vector<std::string> *playerHeadAnimation = new std::vector<std::string>;
|
||||||
loadAnimations(asset->get("player_head.ani"), playerHeadAnimation);
|
loadAnimations(asset->get("player_head.ani"), playerHeadAnimation);
|
||||||
@@ -455,6 +486,10 @@ void Game::loadMedia()
|
|||||||
loadAnimations(asset->get("player_death.ani"), playerDeathAnimation);
|
loadAnimations(asset->get("player_death.ani"), playerDeathAnimation);
|
||||||
playerAnimations.push_back(playerDeathAnimation);
|
playerAnimations.push_back(playerDeathAnimation);
|
||||||
|
|
||||||
|
std::vector<std::string> *playerFireAnimation = new std::vector<std::string>;
|
||||||
|
loadAnimations(asset->get("player_fire.ani"), playerFireAnimation);
|
||||||
|
playerAnimations.push_back(playerFireAnimation);
|
||||||
|
|
||||||
// Animaciones -- Globos
|
// Animaciones -- Globos
|
||||||
std::vector<std::string> *balloon1Animation = new std::vector<std::string>;
|
std::vector<std::string> *balloon1Animation = new std::vector<std::string>;
|
||||||
loadAnimations(asset->get("balloon1.ani"), balloon1Animation);
|
loadAnimations(asset->get("balloon1.ani"), balloon1Animation);
|
||||||
@@ -508,9 +543,13 @@ void Game::loadMedia()
|
|||||||
gameOverMenu = new Menu(renderer, asset, input, asset->get("gameover.men"));
|
gameOverMenu = new Menu(renderer, asset, input, asset->get("gameover.men"));
|
||||||
gameOverMenu->setItemCaption(0, lang->getText(48));
|
gameOverMenu->setItemCaption(0, lang->getText(48));
|
||||||
gameOverMenu->setItemCaption(1, lang->getText(49));
|
gameOverMenu->setItemCaption(1, lang->getText(49));
|
||||||
|
const int w = text->getCharacterSize() * lang->getText(45).length();
|
||||||
|
gameOverMenu->setRectSize(w, 0);
|
||||||
|
gameOverMenu->centerMenuOnX(199);
|
||||||
pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men"));
|
pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men"));
|
||||||
pauseMenu->setItemCaption(0, lang->getText(46));
|
pauseMenu->setItemCaption(0, lang->getText(41));
|
||||||
pauseMenu->setItemCaption(1, lang->getText(47));
|
pauseMenu->setItemCaption(1, lang->getText(46));
|
||||||
|
pauseMenu->setItemCaption(2, lang->getText(47));
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str());
|
balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str());
|
||||||
@@ -1491,7 +1530,6 @@ void Game::updateHiScore()
|
|||||||
{
|
{
|
||||||
// Si la puntuación actual es mayor que la máxima puntuación
|
// Si la puntuación actual es mayor que la máxima puntuación
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
// for (int i = 0; i < numPlayers; i++)
|
|
||||||
if (player->getScore() > hiScore)
|
if (player->getScore() > hiScore)
|
||||||
{
|
{
|
||||||
// Actualiza la máxima puntuación
|
// Actualiza la máxima puntuación
|
||||||
@@ -1513,8 +1551,6 @@ void Game::updateHiScore()
|
|||||||
// Transforma un valor numérico en una cadena de 6 cifras
|
// Transforma un valor numérico en una cadena de 6 cifras
|
||||||
std::string Game::updateScoreText(Uint32 num)
|
std::string Game::updateScoreText(Uint32 num)
|
||||||
{
|
{
|
||||||
// return (std::to_string(num));
|
|
||||||
|
|
||||||
if ((num >= 0) && (num <= 9))
|
if ((num >= 0) && (num <= 9))
|
||||||
{
|
{
|
||||||
return ("000000" + std::to_string(num));
|
return ("000000" + std::to_string(num));
|
||||||
@@ -1557,7 +1593,14 @@ std::string Game::updateScoreText(Uint32 num)
|
|||||||
void Game::renderScoreBoard()
|
void Game::renderScoreBoard()
|
||||||
{
|
{
|
||||||
// Dibuja el fondo del marcador
|
// Dibuja el fondo del marcador
|
||||||
SDL_SetRenderDrawColor(renderer, difficultyColor.r, difficultyColor.g, difficultyColor.b, 255);
|
if (difficulty == DIFFICULTY_NORMAL)
|
||||||
|
{ // Pone el color gris de siempre
|
||||||
|
SDL_SetRenderDrawColor(renderer, 46, 63, 71, 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Pinta el fondo del marcador del color de la dificultad
|
||||||
|
SDL_SetRenderDrawColor(renderer, difficultyColor.r, difficultyColor.g, difficultyColor.b, 255);
|
||||||
|
}
|
||||||
SDL_Rect rect = {0, 160, 256, 32};
|
SDL_Rect rect = {0, 160, 256, 32};
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
@@ -1673,8 +1716,7 @@ void Game::updateStage()
|
|||||||
stage[currentStage].currentPower = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos
|
stage[currentStage].currentPower = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos
|
||||||
menaceCurrent = 255; // Sube el nivel de amenaza para que no cree mas globos
|
menaceCurrent = 255; // Sube el nivel de amenaza para que no cree mas globos
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
// for (int i = 0; i < numPlayers; i++) // Añade un millon de puntos a los jugadores que queden vivos
|
{ // Añade un millon de puntos a los jugadores que queden vivos
|
||||||
{
|
|
||||||
if (player->isAlive())
|
if (player->isAlive())
|
||||||
{
|
{
|
||||||
player->addScore(1000000);
|
player->addScore(1000000);
|
||||||
@@ -1740,8 +1782,7 @@ void Game::updateDeath()
|
|||||||
|
|
||||||
// Renderiza el fade final cuando se acaba la partida
|
// Renderiza el fade final cuando se acaba la partida
|
||||||
void Game::renderDeathFade(int counter)
|
void Game::renderDeathFade(int counter)
|
||||||
// Counter debe ir de 0 a 150
|
{ // Counter debe ir de 0 a 150
|
||||||
{
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255);
|
SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255);
|
||||||
|
|
||||||
if (counter < 150)
|
if (counter < 150)
|
||||||
@@ -1749,15 +1790,19 @@ void Game::renderDeathFade(int counter)
|
|||||||
// 192 / 6 = 32, 6 cuadrados de 32 pixeles
|
// 192 / 6 = 32, 6 cuadrados de 32 pixeles
|
||||||
SDL_Rect rect[12];
|
SDL_Rect rect[12];
|
||||||
Uint8 h = counter / 3;
|
Uint8 h = counter / 3;
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; ++i)
|
||||||
{
|
{
|
||||||
rect[i].x = 0;
|
rect[i].x = 0;
|
||||||
rect[i].y = i * 16;
|
rect[i].y = i * 16;
|
||||||
rect[i].w = GAME_WIDTH;
|
rect[i].w = GAME_WIDTH;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
{
|
||||||
rect[i].h = h;
|
rect[i].h = h;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
rect[i].h = std::max(rect[i - 1].h - 3, 0);
|
rect[i].h = std::max(rect[i - 1].h - 3, 0);
|
||||||
|
}
|
||||||
SDL_RenderFillRect(renderer, &rect[i]);
|
SDL_RenderFillRect(renderer, &rect[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2700,10 +2745,7 @@ void Game::update()
|
|||||||
checkBulletBalloonCollision();
|
checkBulletBalloonCollision();
|
||||||
|
|
||||||
// Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos
|
// Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos
|
||||||
if (!gameCompleted)
|
updateMenace();
|
||||||
{
|
|
||||||
updateMenace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza la velocidad de los enemigos
|
// Actualiza la velocidad de los enemigos
|
||||||
updateBalloonSpeed();
|
updateBalloonSpeed();
|
||||||
@@ -2722,11 +2764,38 @@ void Game::update()
|
|||||||
// Actualiza el fondo
|
// Actualiza el fondo
|
||||||
void Game::updateBackground()
|
void Game::updateBackground()
|
||||||
{
|
{
|
||||||
|
if (!gameCompleted)
|
||||||
|
{ // Si el juego no esta completo, la velocidad de las nubes es igual a los globos explotados
|
||||||
|
cloudsSpeed = balloonsPopped;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si el juego está completado, se reduce la velocidad de las nubes
|
||||||
|
if (cloudsSpeed > 400)
|
||||||
|
{
|
||||||
|
cloudsSpeed -= 25;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cloudsSpeed = 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
|
||||||
|
const float speed = (-0.2f) + (-3.00f * ((float)cloudsSpeed / (float)totalPowerToCompleteGame));
|
||||||
|
|
||||||
|
// Aplica la velocidad calculada a las nubes
|
||||||
|
clouds1A->setVelX(speed);
|
||||||
|
clouds1B->setVelX(speed);
|
||||||
|
clouds2A->setVelX(speed / 2);
|
||||||
|
clouds2B->setVelX(speed / 2);
|
||||||
|
|
||||||
|
// Mueve las nubes
|
||||||
clouds1A->move();
|
clouds1A->move();
|
||||||
clouds1B->move();
|
clouds1B->move();
|
||||||
clouds2A->move();
|
clouds2A->move();
|
||||||
clouds2B->move();
|
clouds2B->move();
|
||||||
|
|
||||||
|
// Calcula el offset de las nubes
|
||||||
if (clouds1A->getPosX() < -clouds1A->getWidth())
|
if (clouds1A->getPosX() < -clouds1A->getWidth())
|
||||||
{
|
{
|
||||||
clouds1A->setPosX(clouds1A->getWidth());
|
clouds1A->setPosX(clouds1A->getWidth());
|
||||||
@@ -2747,8 +2816,10 @@ void Game::updateBackground()
|
|||||||
clouds2B->setPosX(clouds2B->getWidth());
|
clouds2B->setPosX(clouds2B->getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calcula el frame de la hierba
|
||||||
grassSprite->setSpriteClip(0, (6 * (counter / 20 % 2)), 256, 6);
|
grassSprite->setSpriteClip(0, (6 * (counter / 20 % 2)), 256, 6);
|
||||||
|
|
||||||
|
// Mueve los edificios en funcion de si está activo el efecto de agitarlos
|
||||||
if (effect.shake)
|
if (effect.shake)
|
||||||
{
|
{
|
||||||
buildingsSprite->setPosX(((effect.shakeCounter % 2) * 2) - 1);
|
buildingsSprite->setPosX(((effect.shakeCounter % 2) * 2) - 1);
|
||||||
@@ -2762,7 +2833,7 @@ void Game::updateBackground()
|
|||||||
// Dibuja el fondo
|
// Dibuja el fondo
|
||||||
void Game::renderBackground()
|
void Game::renderBackground()
|
||||||
{
|
{
|
||||||
const float gradientNumber = std::min(((float)balloonsPopped / 1000.0f), 3.0f);
|
const float gradientNumber = std::min(((float)balloonsPopped / 1250.0f), 3.0f);
|
||||||
const float percent = gradientNumber - (int)gradientNumber;
|
const float percent = gradientNumber - (int)gradientNumber;
|
||||||
const int alpha = std::max((255 - (int)(255 * percent)), 0);
|
const int alpha = std::max((255 - (int)(255 * percent)), 0);
|
||||||
|
|
||||||
@@ -2813,9 +2884,9 @@ void Game::render()
|
|||||||
renderDeathFade(150 - deathCounter);
|
renderDeathFade(150 - deathCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gameCompleted) && (gameCompletedCounter >= 300))
|
if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE))
|
||||||
{
|
{
|
||||||
renderDeathFade(gameCompletedCounter - 300);
|
renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFlashEffect();
|
renderFlashEffect();
|
||||||
@@ -2827,6 +2898,11 @@ void Game::render()
|
|||||||
// Gestiona el nivel de amenaza
|
// Gestiona el nivel de amenaza
|
||||||
void Game::updateMenace()
|
void Game::updateMenace()
|
||||||
{
|
{
|
||||||
|
if (gameCompleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const float percent = stage[currentStage].currentPower / stage[currentStage].powerToComplete;
|
const float percent = stage[currentStage].currentPower / stage[currentStage].powerToComplete;
|
||||||
const Uint8 difference = stage[currentStage].maxMenace - stage[currentStage].minMenace;
|
const Uint8 difference = stage[currentStage].maxMenace - stage[currentStage].minMenace;
|
||||||
|
|
||||||
@@ -2999,11 +3075,6 @@ void Game::checkGameInput()
|
|||||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
section.subsection = GAME_SECTION_PAUSE;
|
section.subsection = GAME_SECTION_PAUSE;
|
||||||
|
|
||||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
|
||||||
{
|
|
||||||
JA_PauseMusic();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.counter < TOTAL_DEMO_DATA)
|
if (demo.counter < TOTAL_DEMO_DATA)
|
||||||
@@ -3203,112 +3274,301 @@ section_t Game::run()
|
|||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el menu de pausa del juego
|
// Actualiza las variables del menu de pausa del juego
|
||||||
void Game::runPausedGame()
|
void Game::updatePausedGame()
|
||||||
{
|
{
|
||||||
// Reinicia el menu
|
// Comprueba los eventos que hay en la cola
|
||||||
pauseMenu->reset();
|
checkEventHandler();
|
||||||
|
|
||||||
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
// Calcula la lógica de los objetos
|
||||||
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
// Actualiza el contador de ticks
|
||||||
checkEventHandler();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Calcula la lógica de los objetos
|
if (leavingPauseMenu)
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
if (pauseCounter > 0)
|
||||||
ticks = SDL_GetTicks();
|
{ // El contador está descendiendo
|
||||||
|
const bool a = pauseCounter == 90;
|
||||||
|
const bool b = pauseCounter == 60;
|
||||||
|
const bool c = pauseCounter == 30;
|
||||||
|
if (a || b || c)
|
||||||
|
{
|
||||||
|
JA_PlaySound(clockSound);
|
||||||
|
}
|
||||||
|
pauseCounter--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Ha finalizado el contador
|
||||||
|
section.name = PROG_SECTION_GAME;
|
||||||
|
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||||
|
|
||||||
// Actualiza la lógica del menu
|
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||||
|
{
|
||||||
|
JA_ResumeMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Actualiza la lógica del menu de pausa
|
||||||
pauseMenu->update();
|
pauseMenu->update();
|
||||||
|
|
||||||
|
// Comprueba las entradas para el menu
|
||||||
|
pauseMenu->checkInput();
|
||||||
|
|
||||||
|
// Comprueba si se ha seleccionado algún item del menú
|
||||||
|
switch (pauseMenu->getItemSelected())
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
leavingPauseMenu = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
fade->setFadeType(FADE_CENTER);
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza el fade
|
||||||
fade->update();
|
fade->update();
|
||||||
if (fade->hasEnded())
|
if (fade->hasEnded())
|
||||||
{
|
{
|
||||||
section.name = PROG_SECTION_TITLE;
|
section.name = PROG_SECTION_TITLE;
|
||||||
section.subsection = TITLE_SECTION_1;
|
section.subsection = TITLE_SECTION_1;
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja el menu de pausa del juego
|
||||||
|
void Game::renderPausedGame()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean(bgColor);
|
||||||
|
|
||||||
|
// Pinta el escenario
|
||||||
|
{
|
||||||
|
renderBackground();
|
||||||
|
renderBalloons();
|
||||||
|
renderBullets();
|
||||||
|
renderMessages();
|
||||||
|
renderItems();
|
||||||
|
renderSmartSprites();
|
||||||
|
renderScoreBoard();
|
||||||
|
renderPlayers();
|
||||||
|
|
||||||
|
if ((deathCounter <= 150) && !players.at(0)->isAlive())
|
||||||
|
{
|
||||||
|
renderDeathFade(150 - deathCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE))
|
||||||
|
{
|
||||||
|
renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderFlashEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leavingPauseMenu)
|
||||||
|
{
|
||||||
|
textNokiaBig2->writeCentered(SCREEN_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pauseMenu->render();
|
||||||
|
}
|
||||||
|
fade->render();
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle para el menu de pausa del juego
|
||||||
|
void Game::runPausedGame()
|
||||||
|
{
|
||||||
|
// Pone en pausa la música
|
||||||
|
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
||||||
|
{
|
||||||
|
JA_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reinicia el menu
|
||||||
|
pauseMenu->reset();
|
||||||
|
leavingPauseMenu = false;
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
pauseCounter = 90;
|
||||||
|
|
||||||
|
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
||||||
|
{
|
||||||
|
updatePausedGame();
|
||||||
|
renderPausedGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza los elementos de la pantalla de game over
|
||||||
|
void Game::updateGameOverScreen()
|
||||||
|
{
|
||||||
|
// Variables
|
||||||
|
static int postFade = 0;
|
||||||
|
|
||||||
|
// 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 = PROG_SECTION_QUIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
|
{
|
||||||
|
if (gameCompleted)
|
||||||
|
{
|
||||||
|
postFade = 1;
|
||||||
|
fade->activateFade();
|
||||||
|
JA_PlaySound(itemPickUpSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcula la lógica de los objetos
|
||||||
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
|
{
|
||||||
|
// Actualiza el contador de ticks
|
||||||
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
|
// Actualiza la lógica del menu
|
||||||
|
gameOverMenu->update();
|
||||||
|
|
||||||
|
// Actualiza el fade
|
||||||
|
fade->update();
|
||||||
|
|
||||||
|
// Si ha terminado el fade, actua segun se haya operado
|
||||||
|
if (fade->hasEnded())
|
||||||
|
{
|
||||||
|
switch (postFade)
|
||||||
|
{
|
||||||
|
case 0: // YES
|
||||||
|
section.name = PROG_SECTION_GAME;
|
||||||
|
deleteAllVectorObjects();
|
||||||
|
init();
|
||||||
|
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // NO
|
||||||
|
section.name = PROG_SECTION_TITLE;
|
||||||
|
section.subsection = TITLE_SECTION_1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Comprueba las entradas para el menu solo si no esta el juego completo
|
||||||
screen->start();
|
if (!gameCompleted)
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean(bgColor);
|
|
||||||
|
|
||||||
// Pinta el escenario
|
|
||||||
{
|
{
|
||||||
renderBackground();
|
gameOverMenu->checkInput();
|
||||||
renderBalloons();
|
|
||||||
renderBullets();
|
|
||||||
renderMessages();
|
|
||||||
renderItems();
|
|
||||||
renderSmartSprites();
|
|
||||||
renderScoreBoard();
|
|
||||||
renderPlayers();
|
|
||||||
|
|
||||||
if ((deathCounter <= 150) && !players.at(0)->isAlive())
|
// Comprueba si se ha seleccionado algún item del menú
|
||||||
|
switch (gameOverMenu->getItemSelected())
|
||||||
{
|
{
|
||||||
renderDeathFade(150 - deathCounter);
|
case 0: // YES
|
||||||
|
postFade = 0;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // NO
|
||||||
|
postFade = 1;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gameCompleted) && (gameCompletedCounter >= 300))
|
|
||||||
{
|
|
||||||
renderDeathFade(gameCompletedCounter - 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderFlashEffect();
|
|
||||||
}
|
|
||||||
|
|
||||||
pauseMenu->render();
|
|
||||||
fade->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
screen->blit();
|
|
||||||
|
|
||||||
// Comprueba las entradas para el menu
|
|
||||||
pauseMenu->checkInput();
|
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item del menú
|
|
||||||
switch (pauseMenu->getItemSelected())
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
section.name = PROG_SECTION_GAME;
|
|
||||||
|
|
||||||
if (numPlayers == 1)
|
|
||||||
{
|
|
||||||
section.subsection = GAME_SECTION_PLAY_1P;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
section.subsection = GAME_SECTION_PLAY_2P;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
|
||||||
{
|
|
||||||
JA_ResumeMusic();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
fade->setFadeType(FADE_CENTER);
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dibuja los elementos de la pantalla de game over
|
||||||
|
void Game::renderGameOverScreen()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean(bgColor);
|
||||||
|
|
||||||
|
// Dibujo
|
||||||
|
if (!gameCompleted)
|
||||||
|
{ // Dibujo de haber perdido la partida
|
||||||
|
gameOverSprite->render();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Dinujo de haber completado la partida
|
||||||
|
gameOverEndSprite->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja los objetos
|
||||||
|
if (numPlayers == 1)
|
||||||
|
{
|
||||||
|
// Congratulations!!
|
||||||
|
if (gameCompleted)
|
||||||
|
{
|
||||||
|
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), lang->getText(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game Over
|
||||||
|
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43));
|
||||||
|
|
||||||
|
// Your Score
|
||||||
|
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), lang->getText(44) + std::to_string(players.at(0)->getScore()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Congratulations!!
|
||||||
|
if (gameCompleted)
|
||||||
|
{
|
||||||
|
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), lang->getText(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game Over
|
||||||
|
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), lang->getText(43));
|
||||||
|
|
||||||
|
// Player1 Score
|
||||||
|
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), lang->getText(77) + std::to_string(players.at(0)->getScore()));
|
||||||
|
|
||||||
|
// Player2 Score
|
||||||
|
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), lang->getText(78) + std::to_string(players.at(1)->getScore()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue?
|
||||||
|
if (!gameCompleted)
|
||||||
|
{ // Solo dibuja el menu de continuar en el caso de no haber completado la partida
|
||||||
|
text->writeCentered(199, PLAY_AREA_CENTER_Y + BLOCK * 3, lang->getText(45));
|
||||||
|
gameOverMenu->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pinta el fade
|
||||||
|
fade->render();
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
|
}
|
||||||
|
|
||||||
// Bucle para la pantalla de game over
|
// Bucle para la pantalla de game over
|
||||||
void Game::runGameOverScreen()
|
void Game::runGameOverScreen()
|
||||||
{
|
{
|
||||||
// Variables
|
|
||||||
int postFade = 0;
|
|
||||||
|
|
||||||
// Guarda los puntos
|
// Guarda los puntos
|
||||||
saveScoreFile();
|
saveScoreFile();
|
||||||
|
|
||||||
@@ -3317,101 +3577,8 @@ void Game::runGameOverScreen()
|
|||||||
|
|
||||||
while ((section.subsection == GAME_SECTION_GAMEOVER) && (section.name == PROG_SECTION_GAME))
|
while ((section.subsection == GAME_SECTION_GAMEOVER) && (section.name == PROG_SECTION_GAME))
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
updateGameOverScreen();
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
renderGameOverScreen();
|
||||||
{
|
|
||||||
// Evento de salida de la aplicación
|
|
||||||
if (eventHandler->type == SDL_QUIT)
|
|
||||||
{
|
|
||||||
section.name = PROG_SECTION_QUIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcula la lógica de los objetos
|
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
|
||||||
{
|
|
||||||
// Actualiza el contador de ticks
|
|
||||||
ticks = SDL_GetTicks();
|
|
||||||
|
|
||||||
// Actualiza la lógica del menu
|
|
||||||
gameOverMenu->update();
|
|
||||||
fade->update();
|
|
||||||
if (fade->hasEnded())
|
|
||||||
{
|
|
||||||
switch (postFade)
|
|
||||||
{
|
|
||||||
case 0: // YES
|
|
||||||
section.name = PROG_SECTION_GAME;
|
|
||||||
deleteAllVectorObjects();
|
|
||||||
init();
|
|
||||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // NO
|
|
||||||
section.name = PROG_SECTION_TITLE;
|
|
||||||
section.subsection = TITLE_SECTION_1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
|
||||||
screen->start();
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean(bgColor);
|
|
||||||
|
|
||||||
// Dibujo
|
|
||||||
gameOverSprite->render();
|
|
||||||
|
|
||||||
// Dibuja los objetos
|
|
||||||
if (numPlayers == 1)
|
|
||||||
{
|
|
||||||
// Game Over
|
|
||||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43));
|
|
||||||
|
|
||||||
// Your Score
|
|
||||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), lang->getText(44) + std::to_string(players.at(0)->getScore()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 36, lang->getText(43));
|
|
||||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 12, lang->getText(77) + std::to_string(players.at(0)->getScore()));
|
|
||||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y, lang->getText(78) + std::to_string(players.at(1)->getScore()));
|
|
||||||
}
|
|
||||||
// Continue?
|
|
||||||
text->writeCentered(99, PLAY_AREA_CENTER_Y + BLOCK * 2, lang->getText(45));
|
|
||||||
gameOverMenu->render();
|
|
||||||
fade->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
screen->blit();
|
|
||||||
|
|
||||||
// Comprueba las entradas para el menu
|
|
||||||
gameOverMenu->checkInput();
|
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item del menú
|
|
||||||
switch (gameOverMenu->getItemSelected())
|
|
||||||
{
|
|
||||||
case 0: // YES
|
|
||||||
postFade = 0;
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // NO
|
|
||||||
postFade = 1;
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3458,7 +3625,7 @@ void Game::initPaths()
|
|||||||
const int centerPoint = PLAY_AREA_CENTER_Y - (BLOCK * 2);
|
const int centerPoint = PLAY_AREA_CENTER_Y - (BLOCK * 2);
|
||||||
const int distance = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16);
|
const int distance = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16);
|
||||||
|
|
||||||
for (int i = 0; i < STAGE_COUNTER; i++)
|
for (int i = 0; i < STAGE_COUNTER; ++i)
|
||||||
{
|
{
|
||||||
if (i < firstPart)
|
if (i < firstPart)
|
||||||
{
|
{
|
||||||
@@ -3488,7 +3655,7 @@ void Game::initPaths()
|
|||||||
const float distance1 = finish1 - start1;
|
const float distance1 = finish1 - start1;
|
||||||
const float distance2 = finish2 - start2;
|
const float distance2 = finish2 - start2;
|
||||||
|
|
||||||
for (int i = 0; i < STAGE_COUNTER; i++)
|
for (int i = 0; i < STAGE_COUNTER; ++i)
|
||||||
{
|
{
|
||||||
if (i < firstPart)
|
if (i < firstPart)
|
||||||
{
|
{
|
||||||
@@ -3496,10 +3663,12 @@ void Game::initPaths()
|
|||||||
getReadyBitmapPath[i] *= distance1;
|
getReadyBitmapPath[i] *= distance1;
|
||||||
getReadyBitmapPath[i] -= size;
|
getReadyBitmapPath[i] -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (i < secondPart)
|
else if (i < secondPart)
|
||||||
{
|
{
|
||||||
getReadyBitmapPath[i] = (int)finish1;
|
getReadyBitmapPath[i] = (int)finish1;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getReadyBitmapPath[i] = sin[(int)((i - 150) * 1.8f)];
|
getReadyBitmapPath[i] = sin[(int)((i - 150) * 1.8f)];
|
||||||
@@ -3517,7 +3686,7 @@ void Game::updateGameCompleted()
|
|||||||
gameCompletedCounter++;
|
gameCompletedCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameCompletedCounter == 500)
|
if (gameCompletedCounter == GAME_COMPLETED_END)
|
||||||
{
|
{
|
||||||
section.subsection = GAME_SECTION_GAMEOVER;
|
section.subsection = GAME_SECTION_GAMEOVER;
|
||||||
}
|
}
|
||||||
@@ -3580,6 +3749,15 @@ void Game::checkEventHandler()
|
|||||||
section.name = PROG_SECTION_QUIT;
|
section.name = PROG_SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->type == SDL_WINDOWEVENT)
|
||||||
|
{
|
||||||
|
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
|
{
|
||||||
|
section.subsection = GAME_SECTION_PAUSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
@@ -3609,28 +3787,6 @@ void Game::checkEventHandler()
|
|||||||
reloadTextures();
|
reloadTextures();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_P:
|
|
||||||
createPowerBall();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_O:
|
|
||||||
stopAllBalloons(200);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_I:
|
|
||||||
static bool toogle = true;
|
|
||||||
if (toogle)
|
|
||||||
{
|
|
||||||
players.at(0)->setPlayerTextures(player1Textures);
|
|
||||||
toogle = !toogle;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
players.at(0)->setPlayerTextures(player2Textures);
|
|
||||||
toogle = !toogle;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
|
||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/menu.h"
|
||||||
|
#include "common/movingsprite.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/smartsprite.h"
|
||||||
|
#include "common/sprite.h"
|
||||||
|
#include "common/text.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
#include "common/writer.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "input.h"
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "movingsprite.h"
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "screen.h"
|
|
||||||
#include "smartsprite.h"
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "writer.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
#define STAGE_COUNTER 200
|
#define STAGE_COUNTER 200
|
||||||
#define SHAKE_COUNTER 10
|
#define SHAKE_COUNTER 10
|
||||||
#define HELP_COUNTER 1000
|
#define HELP_COUNTER 1000
|
||||||
|
#define GAME_COMPLETED_START_FADE 500
|
||||||
|
#define GAME_COMPLETED_END 700
|
||||||
|
|
||||||
// Formaciones enemigas
|
// Formaciones enemigas
|
||||||
#define NUMBER_OF_ENEMY_FORMATIONS 100
|
#define NUMBER_OF_ENEMY_FORMATIONS 100
|
||||||
@@ -112,7 +114,7 @@ private:
|
|||||||
demoKeys_t dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo
|
demoKeys_t dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
@@ -125,19 +127,21 @@ private:
|
|||||||
std::vector<Item *> items; // Vector con los items
|
std::vector<Item *> items; // Vector con los items
|
||||||
std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites
|
std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites
|
||||||
|
|
||||||
LTexture *bulletTexture; // Textura para las balas
|
Texture *bulletTexture; // Textura para las balas
|
||||||
std::vector<LTexture *> itemTextures; // Vector con las texturas de los items
|
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
std::vector<LTexture *> balloonTextures; // Vector con las texturas de los globos
|
std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos
|
||||||
std::vector<LTexture *> player1Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player1Textures; // Vector con las texturas del jugador
|
||||||
std::vector<LTexture *> player2Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player2Textures; // Vector con las texturas del jugador
|
||||||
|
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
|
||||||
|
|
||||||
LTexture *gameBuildingsTexture; // Textura con los edificios de fondo
|
Texture *gameBuildingsTexture; // Textura con los edificios de fondo
|
||||||
LTexture *gameCloudsTexture; // Textura con las nubes de fondo
|
Texture *gameCloudsTexture; // Textura con las nubes de fondo
|
||||||
LTexture *gameGrassTexture; // Textura con la hierba del suelo
|
Texture *gameGrassTexture; // Textura con la hierba del suelo
|
||||||
LTexture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase
|
Texture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase
|
||||||
LTexture *gameSkyColorsTexture; // Textura con los diferentes colores de fondo del juego
|
Texture *gameSkyColorsTexture; // Textura con los diferentes colores de fondo del juego
|
||||||
LTexture *gameTextTexture; // Textura para los sprites con textos
|
Texture *gameTextTexture; // Textura para los sprites con textos
|
||||||
LTexture *gameOverTexture; // Textura para la pantalla de game over
|
Texture *gameOverTexture; // Textura para la pantalla de game over
|
||||||
|
Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
|
||||||
|
|
||||||
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
||||||
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
||||||
@@ -163,11 +167,12 @@ private:
|
|||||||
SmartSprite *n2500Sprite; // Sprite con el texto 2.500
|
SmartSprite *n2500Sprite; // Sprite con el texto 2.500
|
||||||
SmartSprite *n5000Sprite; // Sprite con el texto 5.000
|
SmartSprite *n5000Sprite; // Sprite con el texto 5.000
|
||||||
|
|
||||||
Sprite *buildingsSprite; // Sprite con los edificios de fondo
|
Sprite *buildingsSprite; // Sprite con los edificios de fondo
|
||||||
Sprite *skyColorsSprite; // Sprite con los graficos del degradado de color de fondo
|
Sprite *skyColorsSprite; // Sprite con los graficos del degradado de color de fondo
|
||||||
Sprite *grassSprite; // Sprite para la hierba
|
Sprite *grassSprite; // Sprite para la hierba
|
||||||
Sprite *powerMeterSprite; // Sprite para el medidor de poder de la fase
|
Sprite *powerMeterSprite; // Sprite para el medidor de poder de la fase
|
||||||
Sprite *gameOverSprite; // Sprite para dibujar los graficos del game over
|
Sprite *gameOverSprite; // Sprite para dibujar los graficos del game over
|
||||||
|
Sprite *gameOverEndSprite; // Sprite para dibujar los graficos del game over de acabar el juego
|
||||||
|
|
||||||
JA_Sound balloonSound; // Sonido para la explosión del globo
|
JA_Sound balloonSound; // Sonido para la explosión del globo
|
||||||
JA_Sound bulletSound; // Sonido para los disparos
|
JA_Sound bulletSound; // Sonido para los disparos
|
||||||
@@ -188,10 +193,9 @@ private:
|
|||||||
JA_Music gameMusic; // Musica de fondo
|
JA_Music gameMusic; // Musica de fondo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int numPlayers; // Numero de jugadores
|
int numPlayers; // Numero de jugadores
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
|
|
||||||
Uint32 hiScore; // Puntuación máxima
|
Uint32 hiScore; // Puntuación máxima
|
||||||
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||||
section_t section; // Seccion actual dentro del juego
|
section_t section; // Seccion actual dentro del juego
|
||||||
@@ -229,6 +233,10 @@ private:
|
|||||||
enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas
|
enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas
|
||||||
Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado
|
Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado
|
||||||
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
||||||
|
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
|
||||||
|
int cloudsSpeed; // Velocidad a la que se desplazan las nubes
|
||||||
|
int pauseCounter; // Contador para salir del menu de pausa y volver al juego
|
||||||
|
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
|
||||||
|
|
||||||
// Actualiza el juego
|
// Actualiza el juego
|
||||||
void update();
|
void update();
|
||||||
@@ -458,9 +466,21 @@ private:
|
|||||||
// Agita la pantalla
|
// Agita la pantalla
|
||||||
void shakeScreen();
|
void shakeScreen();
|
||||||
|
|
||||||
|
// Actualiza las variables del menu de pausa del juego
|
||||||
|
void updatePausedGame();
|
||||||
|
|
||||||
|
// Dibuja el menu de pausa del juego
|
||||||
|
void renderPausedGame();
|
||||||
|
|
||||||
// Bucle para el menu de pausa del juego
|
// Bucle para el menu de pausa del juego
|
||||||
void runPausedGame();
|
void runPausedGame();
|
||||||
|
|
||||||
|
// Actualiza los elementos de la pantalla de game over
|
||||||
|
void updateGameOverScreen();
|
||||||
|
|
||||||
|
// Dibuja los elementos de la pantalla de game over
|
||||||
|
void renderGameOverScreen();
|
||||||
|
|
||||||
// Bucle para la pantalla de game over
|
// Bucle para la pantalla de game over
|
||||||
void runGameOverScreen();
|
void runGameOverScreen();
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,22 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
|||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
LTexture *item1 = new LTexture(renderer, asset->get("item_points1_disk.png"));
|
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
||||||
itemTextures.push_back(item1);
|
itemTextures.push_back(item1);
|
||||||
|
|
||||||
LTexture *item2 = new LTexture(renderer, asset->get("item_points2_gavina.png"));
|
Texture *item2 = new Texture(renderer, asset->get("item_points2_gavina.png"));
|
||||||
itemTextures.push_back(item2);
|
itemTextures.push_back(item2);
|
||||||
|
|
||||||
LTexture *item3 = new LTexture(renderer, asset->get("item_points3_pacmar.png"));
|
Texture *item3 = new Texture(renderer, asset->get("item_points3_pacmar.png"));
|
||||||
itemTextures.push_back(item3);
|
itemTextures.push_back(item3);
|
||||||
|
|
||||||
LTexture *item4 = new LTexture(renderer, asset->get("item_clock.png"));
|
Texture *item4 = new Texture(renderer, asset->get("item_clock.png"));
|
||||||
itemTextures.push_back(item4);
|
itemTextures.push_back(item4);
|
||||||
|
|
||||||
LTexture *item5 = new LTexture(renderer, asset->get("item_coffee.png"));
|
Texture *item5 = new Texture(renderer, asset->get("item_coffee.png"));
|
||||||
itemTextures.push_back(item5);
|
itemTextures.push_back(item5);
|
||||||
|
|
||||||
LTexture *item6 = new LTexture(renderer, asset->get("item_coffee_machine.png"));
|
Texture *item6 = new Texture(renderer, asset->get("item_coffee_machine.png"));
|
||||||
itemTextures.push_back(item6);
|
itemTextures.push_back(item6);
|
||||||
|
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -236,7 +236,7 @@ void Instructions::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para la pantalla de instrucciones
|
// Bucle para la pantalla de instrucciones
|
||||||
void Instructions::run(mode_e mode)
|
section_t Instructions::run(mode_e mode)
|
||||||
{
|
{
|
||||||
this->mode = mode;
|
this->mode = mode;
|
||||||
|
|
||||||
@@ -245,4 +245,6 @@ void Instructions::run(mode_e mode)
|
|||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/sprite.h"
|
||||||
|
#include "common/text.h"
|
||||||
|
#include "common/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#ifndef INSTRUCTIONS_H
|
#ifndef INSTRUCTIONS_H
|
||||||
#define INSTRUCTIONS_H
|
#define INSTRUCTIONS_H
|
||||||
@@ -22,10 +22,10 @@ enum mode_e
|
|||||||
class Instructions
|
class Instructions
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
std::vector<LTexture *> itemTextures; // Vector con las texturas de los items
|
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||||
Sprite *sprite; // Sprite con la textura de las instrucciones
|
Sprite *sprite; // Sprite con la textura de las instrucciones
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
~Instructions();
|
~Instructions();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
void run(mode_e mode);
|
section_t run(mode_e mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang)
|
|||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
texture = new LTexture(renderer, asset->get("intro.png"));
|
texture = new Texture(renderer, asset->get("intro.png"));
|
||||||
text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer);
|
text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer);
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/smartsprite.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
#include "common/writer.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "smartsprite.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "writer.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef INTRO_H
|
#ifndef INTRO_H
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
class Intro
|
class Intro
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
LTexture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item::Item(Uint8 kind, float x, float y, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#ifndef ITEM_H
|
#ifndef ITEM_H
|
||||||
#define ITEM_H
|
#define ITEM_H
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
class Item
|
class Item
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
AnimatedSprite *sprite; // Sprite con los graficos del objeto
|
AnimatedSprite *sprite; // Sprite con los graficos del objeto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item(Uint8 kind, float x, float y, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Item();
|
~Item();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
#include "common/asset.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef LANG_H
|
#ifndef LANG_H
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
texture = new LTexture(renderer, asset->get("logo.png"));
|
texture = new Texture(renderer, asset->get("logo.png"));
|
||||||
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/sprite.h"
|
||||||
|
#include "common/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#ifndef LOGO_H
|
#ifndef LOGO_H
|
||||||
#define LOGO_H
|
#define LOGO_H
|
||||||
@@ -15,11 +15,11 @@
|
|||||||
class Logo
|
class Logo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
LTexture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite; // Sprite con la textura del logo
|
Sprite *sprite; // Sprite con la textura del logo
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<LTexture *> texture, std::vector<std::vector<std::string> *> animations)
|
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -12,6 +12,8 @@ Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<LTexture *> t
|
|||||||
bodySprite = new AnimatedSprite(texture.at(1), renderer, "", animations.at(1));
|
bodySprite = new AnimatedSprite(texture.at(1), renderer, "", animations.at(1));
|
||||||
legsSprite = new AnimatedSprite(texture.at(2), renderer, "", animations.at(2));
|
legsSprite = new AnimatedSprite(texture.at(2), renderer, "", animations.at(2));
|
||||||
deathSprite = new AnimatedSprite(texture.at(3), renderer, "", animations.at(3));
|
deathSprite = new AnimatedSprite(texture.at(3), renderer, "", animations.at(3));
|
||||||
|
fireSprite = new AnimatedSprite(texture.at(4), renderer, "", animations.at(4));
|
||||||
|
fireSprite->getTexture()->setAlpha(224);
|
||||||
|
|
||||||
// Establece la posición inicial del jugador
|
// Establece la posición inicial del jugador
|
||||||
posX = x;
|
posX = x;
|
||||||
@@ -27,6 +29,7 @@ Player::~Player()
|
|||||||
delete bodySprite;
|
delete bodySprite;
|
||||||
delete legsSprite;
|
delete legsSprite;
|
||||||
delete deathSprite;
|
delete deathSprite;
|
||||||
|
delete fireSprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iniciador
|
// Iniciador
|
||||||
@@ -144,6 +147,9 @@ void Player::move()
|
|||||||
|
|
||||||
headSprite->setPosX(getPosX());
|
headSprite->setPosX(getPosX());
|
||||||
headSprite->setPosY(posY);
|
headSprite->setPosY(posY);
|
||||||
|
|
||||||
|
fireSprite->setPosX(getPosX() - 2);
|
||||||
|
fireSprite->setPosY(posY - 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -170,6 +176,10 @@ void Player::render()
|
|||||||
{
|
{
|
||||||
if ((invulnerableCounter % 10) > 4)
|
if ((invulnerableCounter % 10) > 4)
|
||||||
{
|
{
|
||||||
|
if (powerUp)
|
||||||
|
{
|
||||||
|
fireSprite->render();
|
||||||
|
}
|
||||||
legsSprite->render();
|
legsSprite->render();
|
||||||
bodySprite->render();
|
bodySprite->render();
|
||||||
headSprite->render();
|
headSprite->render();
|
||||||
@@ -177,6 +187,10 @@ void Player::render()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (powerUp)
|
||||||
|
{
|
||||||
|
fireSprite->render();
|
||||||
|
}
|
||||||
legsSprite->render();
|
legsSprite->render();
|
||||||
bodySprite->render();
|
bodySprite->render();
|
||||||
headSprite->render();
|
headSprite->render();
|
||||||
@@ -233,14 +247,14 @@ void Player::setAnimation()
|
|||||||
legsSprite->setFlip(flipWalk);
|
legsSprite->setFlip(flipWalk);
|
||||||
if (statusFiring == PLAYER_STATUS_FIRING_NO)
|
if (statusFiring == PLAYER_STATUS_FIRING_NO)
|
||||||
{ // No esta disparando
|
{ // No esta disparando
|
||||||
bodySprite->setCurrentAnimation(aWalking + aBodyCoffees);
|
bodySprite->setCurrentAnimation(aWalking + aBodyCoffees + aPowerUp);
|
||||||
bodySprite->setFlip(flipWalk);
|
bodySprite->setFlip(flipWalk);
|
||||||
headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp);
|
headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp);
|
||||||
headSprite->setFlip(flipWalk);
|
headSprite->setFlip(flipWalk);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Está disparando
|
{ // Está disparando
|
||||||
bodySprite->setCurrentAnimation(aFiring + aBodyCoffees);
|
bodySprite->setCurrentAnimation(aFiring + aBodyCoffees + aPowerUp);
|
||||||
bodySprite->setFlip(flipFire);
|
bodySprite->setFlip(flipFire);
|
||||||
headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp);
|
headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp);
|
||||||
headSprite->setFlip(flipFire);
|
headSprite->setFlip(flipFire);
|
||||||
@@ -250,6 +264,9 @@ void Player::setAnimation()
|
|||||||
legsSprite->animate();
|
legsSprite->animate();
|
||||||
bodySprite->animate();
|
bodySprite->animate();
|
||||||
headSprite->animate();
|
headSprite->animate();
|
||||||
|
|
||||||
|
fireSprite->animate();
|
||||||
|
fireSprite->setFlip(flipWalk);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
@@ -561,7 +578,7 @@ void Player::shiftColliders()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||||
LTexture *Player::getDeadTexture()
|
Texture *Player::getDeadTexture()
|
||||||
{
|
{
|
||||||
return deathSprite->getTexture();
|
return deathSprite->getTexture();
|
||||||
;
|
;
|
||||||
@@ -588,20 +605,23 @@ void Player::updatePowerUpHeadOffset()
|
|||||||
if (powerUpCounter % 10 > 4)
|
if (powerUpCounter % 10 > 4)
|
||||||
{
|
{
|
||||||
// powerUpHeadOffset = 96;
|
// powerUpHeadOffset = 96;
|
||||||
|
fireSprite->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// powerUpHeadOffset = 0;
|
// powerUpHeadOffset = 0;
|
||||||
|
fireSprite->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
void Player::setPlayerTextures(std::vector<LTexture *> texture)
|
void Player::setPlayerTextures(std::vector<Texture *> texture)
|
||||||
{
|
{
|
||||||
headSprite->setTexture(texture.at(0));
|
headSprite->setTexture(texture.at(0));
|
||||||
bodySprite->setTexture(texture.at(1));
|
bodySprite->setTexture(texture.at(1));
|
||||||
legsSprite->setTexture(texture.at(2));
|
legsSprite->setTexture(texture.at(2));
|
||||||
deathSprite->setTexture(texture.at(3));
|
deathSprite->setTexture(texture.at(3));
|
||||||
|
fireSprite->setTexture(texture.at(4));
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "utils.h"
|
#include "common/animatedsprite.h"
|
||||||
#include "input.h"
|
#include "common/asset.h"
|
||||||
#include "asset.h"
|
#include "common/input.h"
|
||||||
#include "ltexture.h"
|
#include "common/texture.h"
|
||||||
#include "animatedsprite.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
@@ -31,12 +31,13 @@
|
|||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
AnimatedSprite *headSprite; // Sprite para dibujar la cabeza
|
AnimatedSprite *headSprite; // Sprite para dibujar la cabeza
|
||||||
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
|
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
|
||||||
AnimatedSprite *legsSprite; // Sprite para dibujar las piernas
|
AnimatedSprite *legsSprite; // Sprite para dibujar las piernas
|
||||||
AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado
|
AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado
|
||||||
|
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float posX; // Posicion en el eje X
|
float posX; // Posicion en el eje X
|
||||||
@@ -82,7 +83,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(float x, int y, SDL_Renderer *renderer, std::vector<LTexture *> texture, std::vector<std::vector<std::string> *> animations);
|
Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player();
|
~Player();
|
||||||
@@ -97,7 +98,7 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
void setPlayerTextures(std::vector<LTexture *> texture);
|
void setPlayerTextures(std::vector<Texture *> texture);
|
||||||
|
|
||||||
// Actua en consecuencia de la entrada recibida
|
// Actua en consecuencia de la entrada recibida
|
||||||
void setInput(Uint8 input);
|
void setInput(Uint8 input);
|
||||||
@@ -211,7 +212,7 @@ public:
|
|||||||
circle_t &getCollider();
|
circle_t &getCollider();
|
||||||
|
|
||||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||||
LTexture *getDeadTexture();
|
Texture *getDeadTexture();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint16 getDeathCounter();
|
Uint16 getDeathCounter();
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
|
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros propios
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
fade = new Fade(renderer);
|
fade = new Fade(renderer);
|
||||||
|
|
||||||
dustTexture = new LTexture(renderer, asset->get("title_dust.png"));
|
dustTexture = new Texture(renderer, asset->get("title_dust.png"));
|
||||||
coffeeTexture = new LTexture(renderer, asset->get("title_coffee.png"));
|
coffeeTexture = new Texture(renderer, asset->get("title_coffee.png"));
|
||||||
crisisTexture = new LTexture(renderer, asset->get("title_crisis.png"));
|
crisisTexture = new Texture(renderer, asset->get("title_crisis.png"));
|
||||||
gradientTexture = new LTexture(renderer, asset->get("title_gradient.png"));
|
gradientTexture = new Texture(renderer, asset->get("title_gradient.png"));
|
||||||
|
|
||||||
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
||||||
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
||||||
@@ -33,6 +33,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
|
|
||||||
menu.title = new Menu(renderer, asset, input, asset->get("title.men"));
|
menu.title = new Menu(renderer, asset, input, asset->get("title.men"));
|
||||||
menu.options = new Menu(renderer, asset, input, asset->get("options.men"));
|
menu.options = new Menu(renderer, asset, input, asset->get("options.men"));
|
||||||
|
menu.playerSelect = new Menu(renderer, asset, input, asset->get("player_select.men"));
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||||
@@ -73,6 +74,7 @@ Title::~Title()
|
|||||||
|
|
||||||
delete menu.title;
|
delete menu.title;
|
||||||
delete menu.options;
|
delete menu.options;
|
||||||
|
delete menu.playerSelect;
|
||||||
|
|
||||||
JA_DeleteSound(crashSound);
|
JA_DeleteSound(crashSound);
|
||||||
JA_DeleteMusic(titleMusic);
|
JA_DeleteMusic(titleMusic);
|
||||||
@@ -299,7 +301,10 @@ void Title::update()
|
|||||||
if (demo)
|
if (demo)
|
||||||
{
|
{
|
||||||
runDemoGame();
|
runDemoGame();
|
||||||
runInstructions(m_auto);
|
if (section.name != PROG_SECTION_QUIT)
|
||||||
|
{
|
||||||
|
runInstructions(m_auto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
section.name = PROG_SECTION_LOGO;
|
section.name = PROG_SECTION_LOGO;
|
||||||
@@ -319,14 +324,13 @@ void Title::update()
|
|||||||
menu.active->update();
|
menu.active->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item del menú
|
// Comprueba si se ha seleccionado algún item del menú de titulo
|
||||||
if (menu.active->getName() == "TITLE")
|
if (menu.active->getName() == "TITLE")
|
||||||
{
|
{
|
||||||
switch (menu.active->getItemSelected())
|
switch (menu.active->getItemSelected())
|
||||||
{
|
{
|
||||||
case 0: // 1 PLAYER
|
case 0: // 1 PLAYER -> Cambia al manu de selección de jugador
|
||||||
postFade = 0;
|
menu.active = menu.playerSelect;
|
||||||
fade->activateFade();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // 2 PLAYERS
|
case 1: // 2 PLAYERS
|
||||||
@@ -349,6 +353,37 @@ void Title::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba si se ha seleccionado algún item del menú de selección de jugador
|
||||||
|
if (menu.active->getName() == "PLAYER_SELECT")
|
||||||
|
{
|
||||||
|
switch (menu.active->getItemSelected())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// Este item no se puede seleccionar y actua de titulo
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // BAL1
|
||||||
|
postFade = 0;
|
||||||
|
options->playerSelected = 0;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // AROUNDER
|
||||||
|
postFade = 0;
|
||||||
|
options->playerSelected = 1;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // BACK
|
||||||
|
menu.active = menu.title;
|
||||||
|
menu.playerSelect->reset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item de opciones
|
// Comprueba si se ha seleccionado algún item de opciones
|
||||||
if (menu.active->getName() == "OPTIONS")
|
if (menu.active->getName() == "OPTIONS")
|
||||||
{
|
{
|
||||||
@@ -451,7 +486,10 @@ void Title::update()
|
|||||||
if (demo)
|
if (demo)
|
||||||
{
|
{
|
||||||
runDemoGame();
|
runDemoGame();
|
||||||
runInstructions(m_auto);
|
if (section.name != PROG_SECTION_QUIT)
|
||||||
|
{
|
||||||
|
runInstructions(m_auto);
|
||||||
|
}
|
||||||
init();
|
init();
|
||||||
demo = false;
|
demo = false;
|
||||||
counter = TITLE_COUNTER;
|
counter = TITLE_COUNTER;
|
||||||
@@ -873,6 +911,14 @@ void Title::updateMenuLabels()
|
|||||||
// Recoloca el menu de titulo
|
// Recoloca el menu de titulo
|
||||||
menu.title->centerMenuOnX(SCREEN_CENTER_X);
|
menu.title->centerMenuOnX(SCREEN_CENTER_X);
|
||||||
menu.title->centerMenuElementsOnX();
|
menu.title->centerMenuElementsOnX();
|
||||||
|
|
||||||
|
// Establece las etiquetas del menu de seleccion de jugador
|
||||||
|
menu.playerSelect->setItemCaption(0, lang->getText(39)); // SELECT PLAYER
|
||||||
|
menu.playerSelect->setItemCaption(3, lang->getText(40)); // BACK
|
||||||
|
|
||||||
|
// Recoloca el menu de selección de jugador
|
||||||
|
menu.playerSelect->centerMenuOnX(SCREEN_CENTER_X);
|
||||||
|
menu.playerSelect->centerMenuElementsOnX();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aplica las opciones de menu seleccionadas
|
// Aplica las opciones de menu seleccionadas
|
||||||
@@ -899,19 +945,23 @@ section_t Title::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void Title::runInstructions(mode_e mode)
|
section_t Title::runInstructions(mode_e mode)
|
||||||
{
|
{
|
||||||
instructions = new Instructions(renderer, screen, asset, lang);
|
instructions = new Instructions(renderer, screen, asset, lang);
|
||||||
instructions->run(mode);
|
section = instructions->run(mode);
|
||||||
delete instructions;
|
delete instructions;
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta el juego en modo demo
|
// Ejecuta el juego en modo demo
|
||||||
void Title::runDemoGame()
|
section_t Title::runDemoGame()
|
||||||
{
|
{
|
||||||
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options);
|
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options);
|
||||||
demoGame->run();
|
section = demoGame->run();
|
||||||
delete demoGame;
|
delete demoGame;
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
@@ -980,7 +1030,7 @@ void Title::createTiledBackground()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea los objetos para pintar en la textura de fondo
|
// Crea los objetos para pintar en la textura de fondo
|
||||||
LTexture *bgTileTexture = new LTexture(renderer, asset->get("title_bg_tile.png"));
|
Texture *bgTileTexture = new Texture(renderer, asset->get("title_bg_tile.png"));
|
||||||
Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer);
|
Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer);
|
||||||
|
|
||||||
// Prepara para dibujar sobre la textura
|
// Prepara para dibujar sobre la textura
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
|
#include "common/jail_audio.h"
|
||||||
|
#include "common/menu.h"
|
||||||
|
#include "common/movingsprite.h"
|
||||||
|
#include "common/screen.h"
|
||||||
|
#include "common/smartsprite.h"
|
||||||
|
#include "common/sprite.h"
|
||||||
|
#include "common/text.h"
|
||||||
|
#include "common/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "input.h"
|
|
||||||
#include "instructions.h"
|
#include "instructions.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "movingsprite.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "smartsprite.h"
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#ifndef TITLE_H
|
#ifndef TITLE_H
|
||||||
#define TITLE_H
|
#define TITLE_H
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
#define TEXT_COPYRIGHT "@2020,2022 JailDesigner (v2.1)"
|
#define TEXT_COPYRIGHT "@2020,2022 JailDesigner (v2.1b)"
|
||||||
|
|
||||||
// Contadores
|
// Contadores
|
||||||
#define TITLE_COUNTER 800
|
#define TITLE_COUNTER 800
|
||||||
@@ -29,19 +29,19 @@
|
|||||||
// Cantidad de eventos de la pantalla de titulo
|
// Cantidad de eventos de la pantalla de titulo
|
||||||
#define TITLE_TOTAL_EVENTS 2
|
#define TITLE_TOTAL_EVENTS 2
|
||||||
|
|
||||||
// Clase Title
|
|
||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct menu_t
|
struct menu_t
|
||||||
{
|
{
|
||||||
Menu *title; // Menu de la pantalla de título
|
Menu *title; // Menu de la pantalla de título
|
||||||
Menu *options; // Menú de la pantalla de opciones
|
Menu *options; // Menú de la pantalla de opciones
|
||||||
Menu *active; // Menu activo (de momento para la pantalla del titulo)
|
Menu *playerSelect; // Menu para elegir jugador
|
||||||
bool keyPressed; // Variable para evitar la repetición de teclas en los menus
|
Menu *active; // Menu activo (de momento para la pantalla del titulo)
|
||||||
|
bool keyPressed; // Variable para evitar la repetición de teclas en los menus
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
@@ -51,10 +51,10 @@ private:
|
|||||||
Game *demoGame; // Objeto para lanzar la demo del juego
|
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
|
|
||||||
LTexture *dustTexture; // Textura con los graficos del polvo
|
Texture *dustTexture; // Textura con los graficos del polvo
|
||||||
LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||||
LTexture *crisisTexture; // Textura con los graficos de la plabra crisis
|
Texture *crisisTexture; // Textura con los graficos de la plabra crisis
|
||||||
LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
Texture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
||||||
|
|
||||||
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
||||||
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
||||||
@@ -116,10 +116,10 @@ private:
|
|||||||
void applyOptions();
|
void applyOptions();
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void runInstructions(mode_e mode);
|
section_t runInstructions(mode_e mode);
|
||||||
|
|
||||||
// Ejecuta el juego en modo demo
|
// Ejecuta el juego en modo demo
|
||||||
void runDemoGame();
|
section_t runDemoGame();
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
bool updatePlayerInputs(int numPlayer);
|
bool updatePlayerInputs(int numPlayer);
|
||||||
|
|||||||
25
todo.txt
@@ -1,25 +0,0 @@
|
|||||||
x los items se quedan pegados en el techo (comprobar si sigue pasando, he cambiado la coreción al chocar arriba. Si sigue fallando se quita la comprobación superior)
|
|
||||||
x la maquina de cafe no toca el suelo
|
|
||||||
x las bolas verdes nacen naranja al explotarlas
|
|
||||||
falta el aura de superguerrero al pillar la maquina de cafe
|
|
||||||
x la powerball deja la mascara al explotarlas
|
|
||||||
x los menus de pausa y game over falta poner bien los textos
|
|
||||||
x cuando continuas la partida sigues muerto
|
|
||||||
poder elegir el personaje para jugar
|
|
||||||
x arreglar los smart sprites de muerte y de perder el cafe
|
|
||||||
x arreglar los items de las instrucciones
|
|
||||||
x que cicle la musica en el titulo, demo, instrucciones
|
|
||||||
NO que guarde el progreso del juego
|
|
||||||
que aumente la velocidad de las nubes conforme avanzas
|
|
||||||
retocar un poco la distancia entre los cambios de color del cielo, se llega al oscuro muy pronto
|
|
||||||
x las balas deberian llegar a salir de la pantalla
|
|
||||||
x hacer desaparecer los accesos a disco en el juego. cargar todos los recursos previamente y pasarlos por punteros
|
|
||||||
x la powerball se para con el reloj y sigue rodando
|
|
||||||
x acelerar la animacion de disparar recto
|
|
||||||
x no pone la animacion corecta al no disparar con el powerup
|
|
||||||
NO que grite "yiiijaa!" o algo parecido al coger la maquina de cafe
|
|
||||||
NO o que diga DIMONIS! en un globo de texto que se evapore
|
|
||||||
NO podrian salir comentarios aleatoriamente o con ciertos eventos (falta ver si no estorbará)
|
|
||||||
x que se vea el nivel de dificultad
|
|
||||||
poner un dibujito en la pantalla de game over al terminar el juego
|
|
||||||
y quizas otro en la propia pantalla de game over
|
|
||||||