Compare commits
77 Commits
c8bebfd2d9
...
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 | |||
| 88041eba23 | |||
| 698721ae03 | |||
| c7109a46cd | |||
| bb20522172 | |||
| bebc016f3c | |||
| 56c1a1d7f3 | |||
| 50d2a5d1c7 | |||
| 83103ddfea | |||
| f4f7bb52b3 | |||
| b861f33867 | |||
| 2576d62002 | |||
| 02312e1342 | |||
| 83a34d61bf | |||
| 8076d8a765 | |||
| 901757b9b2 | |||
| f5ba15a4af | |||
| 6eda55cdae | |||
| 18c36ad3fb | |||
| a5adf1ba01 | |||
| d5ab7cbe2a | |||
| adad58ccfa | |||
| 33b7c6082e | |||
| 5fd1ffa865 | |||
| 9f93de1d06 | |||
| c3fd348a61 | |||
| ddb70c8c85 | |||
| 95d6396dfa | |||
| 99b61c4b2d | |||
| 91b868572e | |||
| 9c35fadd55 | |||
| 80ca04fd64 | |||
| 4ac7496eff | |||
| b6225d2d2f | |||
| a148c38ef8 | |||
| 902d901698 | |||
| a1bdb6add3 | |||
| 0063a2ede5 | |||
| e46a346d20 | |||
| 15b73f1d2c | |||
| fd90a3c66c | |||
| 3d75fae393 | |||
| 6df5d484bc | |||
| e2298dc2b2 | |||
| c213124193 | |||
| 2209ed5f97 | |||
| 1552f6385c | |||
| 072a488de6 | |||
| 8b2459dc35 | |||
| 10882780e5 | |||
| 96ee1fdbe5 | |||
| 50e31a3db3 | |||
| 740e495ad0 | |||
| 2528969801 | |||
| 8d56912765 |
14
.gitignore
vendored
@@ -1,5 +1,13 @@
|
||||
.vscode
|
||||
*config.txt
|
||||
*.DS_Store
|
||||
bin
|
||||
data/config.bin
|
||||
data/score.bin
|
||||
thumbs.db
|
||||
*.exe
|
||||
*_macos
|
||||
*_linux
|
||||
*.dmg
|
||||
*.tar.gz
|
||||
*.zip
|
||||
*.app
|
||||
*config.bin
|
||||
*score.bin
|
||||
123
Makefile
@@ -1,13 +1,118 @@
|
||||
executable = coffee_crisis
|
||||
source = source/*.cpp source/common/*.cpp
|
||||
appName = Coffee Crisis
|
||||
releaseFolder = cc_release
|
||||
version = v2.1b
|
||||
|
||||
windows:
|
||||
@echo off
|
||||
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}
|
||||
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:
|
||||
mkdir -p bin
|
||||
g++ -std=c++11 -Wall -O2 source/*.cpp -o bin/$(executable)_macos -lSDL2
|
||||
rm -f data/config/config.bin
|
||||
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:
|
||||
mkdir -p bin
|
||||
g++ source/*.cpp -std=c++11 -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
|
||||
opendingux:
|
||||
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
|
||||
/opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./bin ./data ./media coffee_crisis.opk -all-root -noappend -no-exports -no-xattrs
|
||||
rm -f data/config/config.bin
|
||||
rm -f data/config/score.bin
|
||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o $(executable)_linux
|
||||
strip -s -R .comment -R .gnu.version $(executable)_linux --strip-unneeded
|
||||
|
||||
linux_release:
|
||||
# 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: 57 KiB |
37
data/gfx/balloon1.ani
Normal file
@@ -0,0 +1,37 @@
|
||||
frameWidth=8
|
||||
frameHeight=8
|
||||
|
||||
[animation]
|
||||
name=orange
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1,2,3,4,5,6,7,8,9
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=blue
|
||||
speed=20
|
||||
loop=0
|
||||
frames=12,13,14,15,16,17,18,19,20,21
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=green
|
||||
speed=10
|
||||
loop=0
|
||||
frames=24,25,26,27,28,29,30,31,32,33
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red
|
||||
speed=20
|
||||
loop=0
|
||||
frames=36,37,38,39,40,41,42,43,44,45
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=pop
|
||||
speed=5
|
||||
loop=-1
|
||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
||||
[/animation]
|
||||
BIN
data/gfx/balloon1.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
37
data/gfx/balloon2.ani
Normal file
@@ -0,0 +1,37 @@
|
||||
frameWidth=13
|
||||
frameHeight=13
|
||||
|
||||
[animation]
|
||||
name=orange
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1,2,3,4,5,6,7,8,9
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=blue
|
||||
speed=20
|
||||
loop=0
|
||||
frames=12,13,14,15,16,17,18,19,20,21
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=green
|
||||
speed=10
|
||||
loop=0
|
||||
frames=24,25,26,27,28,29,30,31,32,33
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red
|
||||
speed=20
|
||||
loop=0
|
||||
frames=36,37,38,39,40,41,42,43,44,45
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=pop
|
||||
speed=5
|
||||
loop=-1
|
||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
||||
[/animation]
|
||||
BIN
data/gfx/balloon2.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
37
data/gfx/balloon3.ani
Normal file
@@ -0,0 +1,37 @@
|
||||
frameWidth=21
|
||||
frameHeight=21
|
||||
|
||||
[animation]
|
||||
name=orange
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1,2,3,4,5,6,7,8,9
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=blue
|
||||
speed=20
|
||||
loop=0
|
||||
frames=12,13,14,15,16,17,18,19,20,21
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=green
|
||||
speed=10
|
||||
loop=0
|
||||
frames=24,25,26,27,28,29,30,31,32,33
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red
|
||||
speed=20
|
||||
loop=0
|
||||
frames=36,37,38,39,40,41,42,43,44,45
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=pop
|
||||
speed=5
|
||||
loop=-1
|
||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
||||
[/animation]
|
||||
BIN
data/gfx/balloon3.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
44
data/gfx/balloon4.ani
Normal file
@@ -0,0 +1,44 @@
|
||||
frameWidth=37
|
||||
frameHeight=37
|
||||
|
||||
[animation]
|
||||
name=orange
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1,2,3,4,5,6,7,8,9
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=blue
|
||||
speed=20
|
||||
loop=0
|
||||
frames=12,13,14,15,16,17,18,19,20,21
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=green
|
||||
speed=10
|
||||
loop=0
|
||||
frames=24,25,26,27,28,29,30,31,32,33
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red
|
||||
speed=20
|
||||
loop=0
|
||||
frames=36,37,38,39,40,41,42,43,44,45
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=powerball
|
||||
speed=10
|
||||
loop=0
|
||||
frames=10
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=pop
|
||||
speed=5
|
||||
loop=-1
|
||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
||||
[/animation]
|
||||
BIN
data/gfx/balloon4.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
data/gfx/game_buildings.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
data/gfx/game_clouds.png
Normal file
|
After Width: | Height: | Size: 901 B |
BIN
data/gfx/game_grass.png
Normal file
|
After Width: | Height: | Size: 468 B |
BIN
data/gfx/game_power_meter.png
Normal file
|
After Width: | Height: | Size: 270 B |
BIN
data/gfx/game_sky_colors.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 795 B After Width: | Height: | Size: 438 B |
9
data/gfx/item_clock.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item_clock.png
Normal file
|
After Width: | Height: | Size: 334 B |
9
data/gfx/item_coffee.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item_coffee.png
Normal file
|
After Width: | Height: | Size: 462 B |
9
data/gfx/item_coffee_machine.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=23
|
||||
frameHeight=29
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1,2,3
|
||||
[/animation]
|
||||
BIN
data/gfx/item_coffee_machine.png
Normal file
|
After Width: | Height: | Size: 553 B |
9
data/gfx/item_points1_disk.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item_points1_disk.png
Normal file
|
After Width: | Height: | Size: 263 B |
9
data/gfx/item_points2_gavina.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item_points2_gavina.png
Normal file
|
After Width: | Height: | Size: 422 B |
9
data/gfx/item_points3_pacmar.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item_points3_pacmar.png
Normal file
|
After Width: | Height: | Size: 388 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
data/gfx/menu_game_over.png
Normal file
|
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: 6.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 785 B |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 654 B |
BIN
data/gfx/player_arounder_body.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
data/gfx/player_arounder_death.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
data/gfx/player_arounder_fire.png
Normal file
|
After Width: | Height: | Size: 887 B |
BIN
data/gfx/player_arounder_head.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
data/gfx/player_arounder_legs.png
Normal file
|
After Width: | Height: | Size: 443 B |
BIN
data/gfx/player_bal1_body.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
data/gfx/player_bal1_death.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
data/gfx/player_bal1_fire.png
Normal file
|
After Width: | Height: | Size: 835 B |
BIN
data/gfx/player_bal1_head.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
data/gfx/player_bal1_legs.png
Normal file
|
After Width: | Height: | Size: 529 B |
176
data/gfx/player_body.ani
Normal file
@@ -0,0 +1,176 @@
|
||||
frameWidth=24
|
||||
frameHeight=24
|
||||
|
||||
[animation]
|
||||
name=walk
|
||||
speed=5
|
||||
loop=0
|
||||
frames=0,1,2,3
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand
|
||||
speed=10
|
||||
loop=0
|
||||
frames=4,5,6,7
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=walk_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=8,9,10,11
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand_1C
|
||||
speed=10
|
||||
loop=0
|
||||
frames=12,13,14,15
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=walk_2C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=16,17,18,19
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand_2C
|
||||
speed=10
|
||||
loop=0
|
||||
frames=20,21,22,23
|
||||
[/animation]
|
||||
|
||||
|
||||
|
||||
[animation]
|
||||
name=sideshoot
|
||||
speed=5
|
||||
loop=0
|
||||
frames=24,25,26,27
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot
|
||||
speed=5
|
||||
loop=0
|
||||
frames=28,29,30,31
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=32,33,34,35
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=36,37,38,39
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot_2C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=40,41,42,43
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot_2C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=44,45,46,47
|
||||
[/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_death.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=24
|
||||
frameHeight=24
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=5
|
||||
loop=0
|
||||
frames=0,1,2,3
|
||||
[/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]
|
||||
114
data/gfx/player_head.ani
Normal file
@@ -0,0 +1,114 @@
|
||||
frameWidth=24
|
||||
frameHeight=24
|
||||
|
||||
[animation]
|
||||
name=walk
|
||||
speed=5
|
||||
loop=0
|
||||
frames=0,1,2,3
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand
|
||||
speed=10
|
||||
loop=0
|
||||
frames=4,5,6,7
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=walk_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=8,9,10,11
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand_1C
|
||||
speed=10
|
||||
loop=0
|
||||
frames=12,13,14,15
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=walk_pwr
|
||||
speed=5
|
||||
loop=0
|
||||
frames=16,17,18,19
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand_pwr
|
||||
speed=10
|
||||
loop=0
|
||||
frames=20,21,22,23
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=walk_1C_pwr
|
||||
speed=5
|
||||
loop=0
|
||||
frames=24,25,26,27
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand_1C_pwr
|
||||
speed=10
|
||||
loop=0
|
||||
frames=28,29,30,31
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot
|
||||
speed=5
|
||||
loop=0
|
||||
frames=16,17,18,19
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot
|
||||
speed=5
|
||||
loop=0
|
||||
frames=20,21,22,23
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=24,25,26,27
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot_1C
|
||||
speed=5
|
||||
loop=0
|
||||
frames=28,29,30,31
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot_pwr
|
||||
speed=2
|
||||
loop=0
|
||||
frames=16,17,18,19
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot_pwr
|
||||
speed=2
|
||||
loop=0
|
||||
frames=20,21,22,23
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=sideshoot_1C_pwr
|
||||
speed=2
|
||||
loop=0
|
||||
frames=24,25,26,27
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=centershoot_1C_pwr
|
||||
speed=2
|
||||
loop=0
|
||||
frames=28,29,30,31
|
||||
[/animation]
|
||||
16
data/gfx/player_legs.ani
Normal file
@@ -0,0 +1,16 @@
|
||||
frameWidth=24
|
||||
frameHeight=24
|
||||
|
||||
[animation]
|
||||
name=walk
|
||||
speed=5
|
||||
loop=0
|
||||
frames=0,1,2,3
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=stand
|
||||
speed=10
|
||||
loop=0
|
||||
frames=4,5,6,7
|
||||
[/animation]
|
||||
|
Before Width: | Height: | Size: 71 KiB |
BIN
data/gfx/title_bg_tile.png
Normal file
|
After Width: | Height: | Size: 899 B |
BIN
data/gfx/title_coffee.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
data/gfx/title_crisis.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
9
data/gfx/title_dust.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frameWidth=16
|
||||
frameHeight=16
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=8
|
||||
loop=-1
|
||||
frames=0,1,2,3,4,5,6
|
||||
[/animation]
|
||||
BIN
data/gfx/title_dust.png
Normal file
|
After Width: | Height: | Size: 212 B |
BIN
data/gfx/title_gradient.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
@@ -1,160 +1,239 @@
|
||||
## 0 - MENU DEL TITULO
|
||||
JUGAR
|
||||
|
||||
## 1 - MENU DEL TITULO
|
||||
OPCIONS
|
||||
|
||||
## 2 - MENU DEL TITULO
|
||||
INSTRUCCIONS
|
||||
|
||||
## 3 - MENU DEL TITULO
|
||||
EIXIR
|
||||
|
||||
## 4 - MENU DE OPCIONES
|
||||
FINESTRA
|
||||
|
||||
## 5 - MENU DE OPCIONES
|
||||
PANTALLA COMPLETA
|
||||
|
||||
## 6 - MENU DE OPCIONES
|
||||
PANTALLA COMPLETA FALSA
|
||||
|
||||
## 7 - MENU DE OPCIONES
|
||||
TAMANY DE FINESTRA
|
||||
|
||||
## 8 - MENU DE OPCIONES
|
||||
IDIOMA
|
||||
|
||||
## 9 - MENU DE OPCIONES
|
||||
[ ACEPTAR ]
|
||||
|
||||
## 10 - MENU DE OPCIONES
|
||||
[ CANCELAR ]
|
||||
|
||||
## 11 - INSTRUCCIONES
|
||||
OBJECTIU
|
||||
|
||||
## 12 - INSTRUCCIONES
|
||||
HAS D'EXPLOTAR
|
||||
|
||||
## 13 - INSTRUCCIONES
|
||||
TANTS GLOBUS COM PUGUES
|
||||
|
||||
## 14 - INSTRUCCIONES
|
||||
LA DIFICULTAT AUGMENTA
|
||||
|
||||
## 15 - INSTRUCCIONES
|
||||
A MESURA QUE VAS PUNTUANT
|
||||
|
||||
## 16 - INSTRUCCIONES
|
||||
OBJECTES
|
||||
|
||||
## 17 - INSTRUCCIONES
|
||||
1.000 PUNTS
|
||||
|
||||
## 18 - INSTRUCCIONES
|
||||
2.500 PUNTS
|
||||
|
||||
## 19 - INSTRUCCIONES
|
||||
5.000 PUNTS
|
||||
|
||||
## 20 - INSTRUCCIONES
|
||||
PARA EL TEMPS
|
||||
|
||||
## 21 - INSTRUCCIONES
|
||||
VIDA EXTRA
|
||||
|
||||
## 22 - INSTRUCCIONES
|
||||
PREM UNA TECLA PER A TORNAR
|
||||
|
||||
## 23 - TITULO
|
||||
PREM QUALSEVOL TECLA
|
||||
|
||||
## 24 - MENU SELECCION DE IDIOMA
|
||||
ESPA{OL (ESPANYOL)
|
||||
|
||||
## 25 - MENU SELECCION DE IDIOMA
|
||||
BALOONCIA
|
||||
|
||||
## 26 - MENU SELECCION DE IDIOMA
|
||||
ENGLISH (ANGLES)
|
||||
|
||||
## 27 - INTRO
|
||||
Un dia qualsevol de l'any 2000
|
||||
|
||||
## 28 - INTRO
|
||||
Tot esta tranquil a la UPV
|
||||
|
||||
## 29 - INTRO
|
||||
Fins que un desaprensiu...
|
||||
|
||||
## 30 - INTRO
|
||||
HEY! ME ANE A FERME UN CORTAET...
|
||||
|
||||
## 31 - INTRO
|
||||
UAAAAAAAAAAAAA!!!
|
||||
|
||||
## 32 - INTRO
|
||||
Espera un moment...
|
||||
|
||||
## 33 - INTRO
|
||||
Si resulta que no tinc solt!
|
||||
|
||||
## 34 - INTRO
|
||||
MERDA DE MAQUINA!
|
||||
|
||||
## 35 - INTRO
|
||||
Blop... blop... blop...
|
||||
|
||||
## 36 - TEXTOS DEL JUEGO
|
||||
Temps detes:
|
||||
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
fases mes!
|
||||
## 39 -
|
||||
|
||||
## 40 -
|
||||
## 39 - MENU SELECCION DE JUGADOR
|
||||
Selecciona personatge
|
||||
|
||||
## 41 -
|
||||
## 40 - MENU SELECCION DE JUGADOR
|
||||
Enrere
|
||||
|
||||
## 41 - MENU DE PAUSA
|
||||
Menu de pausa
|
||||
|
||||
## 42 -
|
||||
-
|
||||
|
||||
## 43 - PANTALLA DE GAME OVER
|
||||
FI DEL JOC
|
||||
|
||||
## 44 - PANTALLA DE GAME OVER
|
||||
ELS TEUS PUNTS:
|
||||
|
||||
## 45 - PANTALLA DE GAME OVER
|
||||
CONTINUAR?
|
||||
|
||||
## 46 - MENU DE PAUSA
|
||||
CONTINUAR
|
||||
|
||||
## 47 - MENU DE PAUSA
|
||||
EIXIR DEL JOC
|
||||
|
||||
## 48 - MENU GAME OVER
|
||||
SI
|
||||
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
Felicitats!!
|
||||
|
||||
## 51 - MENU DEL TITULO
|
||||
1 JUGADOR
|
||||
|
||||
## 52 - MENU DEL TITULO
|
||||
2 JUGADORS
|
||||
|
||||
## 53 MARCADOR
|
||||
jugador 1
|
||||
|
||||
## 54 MARCADOR
|
||||
jugador 2
|
||||
|
||||
## 55 MARCADOR
|
||||
mult
|
||||
|
||||
## 56 MARCADOR
|
||||
max. puntuacio
|
||||
|
||||
## 57 MARCADOR
|
||||
fase
|
||||
|
||||
## 58 - MENU DE OPCIONES
|
||||
MODE DE VISUALITZACIO
|
||||
|
||||
## 59 - MENU DE OPCIONES
|
||||
DIFICULTAT
|
||||
|
||||
## 60 - MENU DE OPCIONES
|
||||
FILTRE
|
||||
|
||||
## 61 - MENU DE OPCIONES
|
||||
SINC. VERTICAL
|
||||
|
||||
## 62 - MENU DE OPCIONES
|
||||
CONTROLS DEL JUGADOR 1
|
||||
|
||||
## 63 - MENU DE OPCIONES
|
||||
CONTROLS DEL JUGADOR 2
|
||||
|
||||
## 64 -
|
||||
-
|
||||
|
||||
## 65 -
|
||||
-
|
||||
|
||||
## 66 - MENU DE OPCIONES
|
||||
FACIL
|
||||
|
||||
## 67 - MENU DE OPCIONES
|
||||
NORMAL
|
||||
|
||||
## 68 - MENU DE OPCIONES
|
||||
DIFICIL
|
||||
|
||||
## 69 - MENU DE OPCIONES
|
||||
TECLAT
|
||||
|
||||
## 70 - MENU DE OPCIONES
|
||||
MANDO
|
||||
|
||||
## 71 - MENU DE OPCIONES
|
||||
LINEAL
|
||||
|
||||
## 72 - MENU DE OPCIONES
|
||||
NEAREST
|
||||
|
||||
## 73 - MENU DE OPCIONES
|
||||
ACTIVADA
|
||||
|
||||
## 74 - MENU DE OPCIONES
|
||||
DESACTIVADA
|
||||
|
||||
## 75 - JUEGO
|
||||
Endavant!
|
||||
|
||||
## 76 - JUEGO
|
||||
1.000.000 de punts!
|
||||
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PUNTS J1:
|
||||
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PUNTS J2:
|
||||
|
||||
## 79 - TEXTOS DEL JUEGO
|
||||
Ultima fase!
|
||||
@@ -1,160 +1,239 @@
|
||||
## 0 - MENU DEL TITULO
|
||||
PLAY
|
||||
|
||||
## 1 - MENU DEL TITULO
|
||||
OPTIONS
|
||||
|
||||
## 2 - MENU DEL TITULO
|
||||
HOW TO PLAY
|
||||
|
||||
## 3 - MENU DEL TITULO
|
||||
QUIT
|
||||
|
||||
## 4 - MENU DE OPCIONES
|
||||
WINDOW
|
||||
|
||||
## 5 - MENU DE OPCIONES
|
||||
FULLSCREEN
|
||||
|
||||
## 6 - MENU DE OPCIONES
|
||||
FAKE FULLSCREEN
|
||||
|
||||
## 7 - MENU DE OPCIONES
|
||||
WINDOW SIZE
|
||||
|
||||
## 8 - MENU DE OPCIONES
|
||||
LANGUAGE
|
||||
|
||||
## 9 - MENU DE OPCIONES
|
||||
[ ACCEPT ]
|
||||
|
||||
## 10 - MENU DE OPCIONES
|
||||
[ CANCEL ]
|
||||
|
||||
## 11 - INSTRUCCIONES
|
||||
OBJECTIVE
|
||||
|
||||
## 12 - INSTRUCCIONES
|
||||
YOU HAVE TO POP AS MANY
|
||||
|
||||
## 13 - INSTRUCCIONES
|
||||
BALLOONS AS YOU CAN
|
||||
|
||||
## 14 - INSTRUCCIONES
|
||||
DIFFICULTY WILL BE INCREASED
|
||||
|
||||
## 15 - INSTRUCCIONES
|
||||
AS YOU SCORE POINTS
|
||||
|
||||
## 16 - INSTRUCCIONES
|
||||
ITEMS
|
||||
|
||||
## 17 - INSTRUCCIONES
|
||||
1.000 POINTS
|
||||
|
||||
## 18 - INSTRUCCIONES
|
||||
2.500 POINTS
|
||||
|
||||
## 19 - INSTRUCCIONES
|
||||
5.000 POINTS
|
||||
|
||||
## 20 - INSTRUCCIONES
|
||||
TIME STOPPER
|
||||
|
||||
## 21 - INSTRUCCIONES
|
||||
EXTRA HIT
|
||||
|
||||
## 22 - INSTRUCCIONES
|
||||
PRESS ANY KEY TO RETURN
|
||||
|
||||
## 23 - TITULO
|
||||
PRESS ANY KEY
|
||||
|
||||
## 24 - MENU SELECCION DE IDIOMA
|
||||
ESPA{OL (SPANISH)
|
||||
|
||||
## 25 - MENU SELECCION DE IDIOMA
|
||||
BALOONCIA (VALENCIAN)
|
||||
|
||||
## 26 - MENU SELECCION DE IDIOMA
|
||||
ENGLISH
|
||||
|
||||
## 27 - INTRO
|
||||
Any day of the year 2000
|
||||
|
||||
## 28 - INTRO
|
||||
Everything is quiet at the UPV
|
||||
|
||||
## 29 - INTRO
|
||||
Until a bastard arrives...
|
||||
|
||||
## 30 - INTRO
|
||||
YO! GONNA TAKE A CAFELITO...
|
||||
|
||||
## 31 - INTRO
|
||||
AAAAAAAARGHHHH!!!
|
||||
|
||||
## 32 - INTRO
|
||||
Wait a moment...
|
||||
|
||||
## 33 - INTRO
|
||||
I don't have any loose!
|
||||
|
||||
## 34 - INTRO
|
||||
FUCKING MACHINE!
|
||||
|
||||
## 35 - INTRO
|
||||
Blop... blop... blop...
|
||||
|
||||
## 36 - TEXTOS DEL JUEGO
|
||||
Time stopped:
|
||||
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
stages left!
|
||||
## 39 -
|
||||
|
||||
## 40 -
|
||||
## 39 - MENU SELECCION DE JUGADOR
|
||||
Select Player
|
||||
|
||||
## 41 -
|
||||
## 40 - MENU SELECCION DE JUGADOR
|
||||
Back
|
||||
|
||||
## 41 - MENU DE PAUSA
|
||||
Pause Menu
|
||||
|
||||
## 42 -
|
||||
-
|
||||
|
||||
## 43 - PANTALLA DE GAME OVER
|
||||
GAME OVER
|
||||
|
||||
## 44 - PANTALLA DE GAME OVER
|
||||
YOUR SCORE:
|
||||
|
||||
## 45 - PANTALLA DE GAME OVER
|
||||
CONTINUE?
|
||||
|
||||
## 46 - MENU DE PAUSA
|
||||
CONTINUE
|
||||
|
||||
## 47 - MENU DE PAUSA
|
||||
LEAVE GAME
|
||||
|
||||
## 48 - MENU GAME OVER
|
||||
YES
|
||||
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
Congratulations!!
|
||||
|
||||
## 51 - MENU DEL TITULO
|
||||
1 PLAYER
|
||||
|
||||
## 52 - MENU DEL TITULO
|
||||
2 PLAYERS
|
||||
|
||||
## 53 - MARCADOR
|
||||
player 1
|
||||
|
||||
## 54 - MARCADOR
|
||||
player 2
|
||||
|
||||
## 55 - MARCADOR
|
||||
mult
|
||||
|
||||
## 56 - MARCADOR
|
||||
high score
|
||||
|
||||
## 57 - MARCADOR
|
||||
stage
|
||||
|
||||
## 58 - MENU DE OPCIONES
|
||||
DISPLAY MODE
|
||||
|
||||
## 59 - MENU DE OPCIONES
|
||||
DIFFICULTY
|
||||
|
||||
## 60 - MENU DE OPCIONES
|
||||
FILTER
|
||||
|
||||
## 61 - MENU DE OPCIONES
|
||||
VSYNC
|
||||
|
||||
## 62 - MENU DE OPCIONES
|
||||
PLAYER 1 CONTROLS
|
||||
|
||||
## 63 - MENU DE OPCIONES
|
||||
PLAYER 2 CONTROLS
|
||||
|
||||
## 64 -
|
||||
-
|
||||
|
||||
## 65 -
|
||||
-
|
||||
|
||||
## 66 - MENU DE OPCIONES
|
||||
EASY
|
||||
|
||||
## 67 - MENU DE OPCIONES
|
||||
NORMAL
|
||||
|
||||
## 68 - MENU DE OPCIONES
|
||||
HARD
|
||||
|
||||
## 69 - MENU DE OPCIONES
|
||||
KEYBOARD
|
||||
|
||||
## 70 - MENU DE OPCIONES
|
||||
GAME CONTROLLER
|
||||
|
||||
## 71 - MENU DE OPCIONES
|
||||
LINEAL
|
||||
|
||||
## 72 - MENU DE OPCIONES
|
||||
NEAREST
|
||||
|
||||
## 73 - MENU DE OPCIONES
|
||||
ON
|
||||
|
||||
## 74 - MENU DE OPCIONES
|
||||
OFF
|
||||
|
||||
## 75 - JUEGO
|
||||
Get Ready!
|
||||
|
||||
## 76 - JUEGO
|
||||
1.000.000 points!
|
||||
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PLAYER1 SCORE:
|
||||
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PLAYER2 SCORE:
|
||||
|
||||
## 79 - TEXTOS DEL JUEGO
|
||||
Last stage!
|
||||
@@ -1,160 +1,239 @@
|
||||
## 0 - MENU DEL TITULO
|
||||
JUGAR
|
||||
|
||||
## 1 - MENU DEL TITULO
|
||||
OPCIONES
|
||||
|
||||
## 2 - MENU DEL TITULO
|
||||
INSTRUCCIONES
|
||||
|
||||
## 3 - MENU DEL TITULO
|
||||
SALIR
|
||||
|
||||
## 4 - MENU DE OPCIONES
|
||||
VENTANA
|
||||
|
||||
## 5 - MENU DE OPCIONES
|
||||
PANTALLA COMPLETA
|
||||
|
||||
## 6 - MENU DE OPCIONES
|
||||
PANTALLA COMPLETA FALSA
|
||||
|
||||
## 7 - MENU DE OPCIONES
|
||||
TAMA{O DE VENTANA
|
||||
|
||||
## 8 - MENU DE OPCIONES
|
||||
IDIOMA
|
||||
|
||||
## 9 - MENU DE OPCIONES
|
||||
[ ACEPTAR ]
|
||||
|
||||
## 10 - MENU DE OPCIONES
|
||||
[ CANCELAR ]
|
||||
|
||||
## 11 - INSTRUCCIONES
|
||||
OBJETIVO
|
||||
|
||||
## 12 - INSTRUCCIONES
|
||||
TIENES QUE EXPLOTAR
|
||||
|
||||
## 13 - INSTRUCCIONES
|
||||
TANTOS GLOBOS COMO PUEDAS
|
||||
|
||||
## 14 - INSTRUCCIONES
|
||||
LA DIFICULTAD SE INCREMENTA
|
||||
|
||||
## 15 - INSTRUCCIONES
|
||||
A MEDIDA QUE VAS PUNTUANDO
|
||||
|
||||
## 16 - INSTRUCCIONES
|
||||
OBJETOS
|
||||
|
||||
## 17 - INSTRUCCIONES
|
||||
1.000 PUNTOS
|
||||
|
||||
## 18 - INSTRUCCIONES
|
||||
2.500 PUNTOS
|
||||
|
||||
## 19 - INSTRUCCIONES
|
||||
5.000 PUNTOS
|
||||
|
||||
## 20 - INSTRUCCIONES
|
||||
DETIENE EL TIEMPO
|
||||
|
||||
## 21 - INSTRUCCIONES
|
||||
VIDA EXTRA
|
||||
|
||||
## 22 - INSTRUCCIONES
|
||||
PULSA UNA TECLA PARA VOLVER
|
||||
|
||||
## 23 - TITULO
|
||||
PULSA CUALQUIER TECLA
|
||||
|
||||
## 24 - MENU SELECCION DE IDIOMA
|
||||
ESPA{OL
|
||||
|
||||
## 25 - MENU SELECCION DE IDIOMA
|
||||
BALOONCIA (VALENCIANO)
|
||||
|
||||
## 26 - MENU SELECCION DE IDIOMA
|
||||
ENGLISH (INGLES)
|
||||
|
||||
## 27 - INTRO
|
||||
Un dia cualquiera del a{o 2000
|
||||
|
||||
## 28 - INTRO
|
||||
Todo esta tranquilo en la UPV
|
||||
|
||||
## 29 - INTRO
|
||||
Hasta que un desaprensivo...
|
||||
|
||||
## 30 - INTRO
|
||||
HEY! VOY A SACARME UN TALLADET...
|
||||
|
||||
## 31 - INTRO
|
||||
UAAAAAAAAAAAAA!!!
|
||||
|
||||
## 32 - INTRO
|
||||
Espera un momento...
|
||||
|
||||
## 33 - INTRO
|
||||
Si no llevo suelto encima!
|
||||
|
||||
## 34 - INTRO
|
||||
MIERDA DE MAQUINA!
|
||||
|
||||
## 35 - INTRO
|
||||
Blop... blop... blop...
|
||||
|
||||
## 36 - TEXTOS DEL JUEGO
|
||||
Tiempo:
|
||||
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
fases mas!
|
||||
## 39 -
|
||||
|
||||
## 40 -
|
||||
## 39 - MENU SELECCION DE JUGADOR
|
||||
Selecciona jugador
|
||||
|
||||
## 41 -
|
||||
## 40 - MENU SELECCION DE JUGADOR
|
||||
Volver
|
||||
|
||||
## 41 - MENU DE PAUSA
|
||||
Menu de pausa
|
||||
|
||||
## 42 -
|
||||
-
|
||||
|
||||
## 43 - PANTALLA DE GAME OVER
|
||||
FIN DE JUEGO
|
||||
|
||||
## 44 - PANTALLA DE GAME OVER
|
||||
TU PUNTUACION:
|
||||
|
||||
## 45 - PANTALLA DE GAME OVER
|
||||
CONTINUAR?
|
||||
|
||||
## 46 - MENU DE PAUSA
|
||||
CONTINUAR
|
||||
|
||||
## 47 - MENU DE PAUSA
|
||||
SALIR DEL JUEGO
|
||||
|
||||
## 48 - MENU GAME OVER
|
||||
SI
|
||||
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
Felicidades!!
|
||||
|
||||
## 51 - MENU DEL TITULO
|
||||
1 JUGADOR
|
||||
|
||||
## 52 - MENU DEL TITULO
|
||||
2 JUGADORES
|
||||
|
||||
## 53 - MARCADOR
|
||||
jugador 1
|
||||
|
||||
## 54 - MARCADOR
|
||||
jugador 2
|
||||
|
||||
## 55 - MARCADOR
|
||||
mult
|
||||
|
||||
## 56 - MARCADOR
|
||||
max. puntuacion
|
||||
|
||||
## 57 - MARCADOR
|
||||
FASE
|
||||
|
||||
## 58 - MENU DE OPCIONES
|
||||
MODO DE VISUALIZACION
|
||||
|
||||
## 59 - MENU DE OPCIONES
|
||||
DIFICULTAD
|
||||
|
||||
## 60 - MENU DE OPCIONES
|
||||
FILTRO
|
||||
|
||||
## 61 - MENU DE OPCIONES
|
||||
SINC. VERTICAL
|
||||
|
||||
## 62 - MENU DE OPCIONES
|
||||
CONTROLES DEL JUGADOR 1
|
||||
|
||||
## 63 - MENU DE OPCIONES
|
||||
CONTROLES DEL JUGADOR 2
|
||||
|
||||
## 64 -
|
||||
-
|
||||
|
||||
## 65 -
|
||||
-
|
||||
|
||||
## 66 - MENU DE OPCIONES
|
||||
FACIL
|
||||
|
||||
## 67 - MENU DE OPCIONES
|
||||
NORMAL
|
||||
|
||||
## 68 - MENU DE OPCIONES
|
||||
DIFICIL
|
||||
|
||||
## 69 - MENU DE OPCIONES
|
||||
TECLADO
|
||||
|
||||
## 70 - MENU DE OPCIONES
|
||||
MANDO
|
||||
|
||||
## 71 - MENU DE OPCIONES
|
||||
LINEAL
|
||||
|
||||
## 72 - MENU DE OPCIONES
|
||||
NEAREST
|
||||
|
||||
## 73 - MENU DE OPCIONES
|
||||
ACTIVADA
|
||||
|
||||
## 74 - MENU DE OPCIONES
|
||||
DESACTIVADA
|
||||
|
||||
## 75 - JUEGO
|
||||
Adelante!
|
||||
|
||||
## 76 - JUEGO
|
||||
1.000.000 de puntos!
|
||||
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PUNTUACION J1:
|
||||
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PUNTUACION J2:
|
||||
|
||||
## 79 - TEXTOS DEL JUEGO
|
||||
Ultima fase!
|
||||
29
data/menu/gameover.men
Normal file
@@ -0,0 +1,29 @@
|
||||
font_png=smb2.png
|
||||
font_txt=smb2.txt
|
||||
|
||||
sound_move=menu_move.wav
|
||||
sound_accept=menu_select.wav
|
||||
|
||||
name=GAME OVER
|
||||
x=0
|
||||
y=120
|
||||
backgroundType=0
|
||||
backgroundColor=128,64,0,0
|
||||
|
||||
areElementsCenteredOnX=true
|
||||
isCenteredOnX=true
|
||||
centerX=199
|
||||
|
||||
selector_color=255,122,0,255
|
||||
selector_text_color=255,255,235
|
||||
|
||||
defaultActionWhenCancel=1
|
||||
|
||||
[item]
|
||||
text=SI
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=NO
|
||||
[/item]
|
||||
108
data/menu/options.men
Normal file
@@ -0,0 +1,108 @@
|
||||
font_png=smb2.png
|
||||
font_txt=smb2.txt
|
||||
|
||||
sound_move=menu_move.wav
|
||||
sound_accept=menu_select.wav
|
||||
|
||||
name=OPTIONS
|
||||
x=0
|
||||
y=116
|
||||
backgroundType=0
|
||||
backgroundColor=48,48,64,192
|
||||
|
||||
areElementsCenteredOnX=true
|
||||
|
||||
isCenteredOnX=true
|
||||
centerX=128
|
||||
|
||||
isCenteredOnY=true
|
||||
centerY=96
|
||||
|
||||
selector_color=229,28,35,255
|
||||
selector_text_color=255,241,118
|
||||
|
||||
defaultActionWhenCancel=13
|
||||
|
||||
[item]
|
||||
text=DIFFICULTY
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=PLAYER 1 CONTROLS
|
||||
hPaddingDown=2
|
||||
selectable=true
|
||||
greyed=false
|
||||
linkedDown=true
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=KEYBOARD
|
||||
hPaddingDown=7
|
||||
selectable=false
|
||||
greyed=false
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=PLAYER 2 CONTROLS
|
||||
hPaddingDown=2
|
||||
selectable=true
|
||||
greyed=false
|
||||
linkedDown=true
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=GAME CONTROLLER
|
||||
hPaddingDown=7
|
||||
selectable=false
|
||||
greyed=false
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=LANGUAGE
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=DISPLAY MODE
|
||||
hPaddingDown=2
|
||||
selectable=true
|
||||
greyed=false
|
||||
linkedDown=true
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=WINDOW
|
||||
hPaddingDown=7
|
||||
selectable=false
|
||||
greyed=false
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=WINDOW SIZE
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=FILTER
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=VSYNC
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=HOW TO PLAY
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=ACCEPT
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=CANCEL
|
||||
[/item]
|
||||
35
data/menu/pause.men
Normal file
@@ -0,0 +1,35 @@
|
||||
font_png=smb2.png
|
||||
font_txt=smb2.txt
|
||||
|
||||
sound_move=menu_move.wav
|
||||
sound_accept=menu_select.wav
|
||||
|
||||
name=PAUSE
|
||||
x=0
|
||||
y=80
|
||||
backgroundType=1
|
||||
backgroundColor=41,57,65,240
|
||||
|
||||
areElementsCenteredOnX=true
|
||||
isCenteredOnX=true
|
||||
centerX=128
|
||||
|
||||
selector_color=255,122,0,255
|
||||
selector_text_color=255,255,255
|
||||
|
||||
defaultActionWhenCancel=1
|
||||
|
||||
[item]
|
||||
text=PAUSE MENU
|
||||
hPaddingDown=7
|
||||
selectable=false
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=CONTINUE
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=LEAVE GAME
|
||||
[/item]
|
||||
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]
|
||||
39
data/menu/title.men
Normal file
@@ -0,0 +1,39 @@
|
||||
font_png=smb2.png
|
||||
font_txt=smb2.txt
|
||||
|
||||
sound_move=menu_move.wav
|
||||
sound_accept=menu_select.wav
|
||||
|
||||
name=TITLE
|
||||
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=1 PLAYER
|
||||
hPaddingDown=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=2 PLAYERS
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=OPTIONS
|
||||
hPaddingDown=7
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
text=QUIT
|
||||
[/item]
|
||||
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
@@ -1,333 +0,0 @@
|
||||
|
||||
#include "animatedsprite.h"
|
||||
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(LTexture *texture, SDL_Renderer *renderer, std::string file)
|
||||
{
|
||||
// Copia los punteros
|
||||
setTexture(texture);
|
||||
setRenderer(renderer);
|
||||
|
||||
// Carga las animaciones
|
||||
load(file);
|
||||
|
||||
// Inicializa variables
|
||||
currentAnimation = 0;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
AnimatedSprite::~AnimatedSprite()
|
||||
{
|
||||
for (auto &a : animation)
|
||||
{
|
||||
a.frames.clear();
|
||||
}
|
||||
animation.clear();
|
||||
}
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int AnimatedSprite::getIndex(std::string name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
for (auto a : animation)
|
||||
{
|
||||
index++;
|
||||
if (a.name == name)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Calcula el frame correspondiente a la animación
|
||||
void AnimatedSprite::animate()
|
||||
{
|
||||
if (!enabled || animation[currentAnimation].speed == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcula el frame actual a partir del contador
|
||||
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
||||
|
||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||
// en función de la variable loop y coloca el nuevo frame
|
||||
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
|
||||
{
|
||||
if (animation[currentAnimation].loop == -1)
|
||||
{ // Si no hay loop, deja el último frame
|
||||
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
|
||||
animation[currentAnimation].completed = true;
|
||||
}
|
||||
else
|
||||
{ // Si hay loop, vuelve al frame indicado
|
||||
animation[currentAnimation].counter = 0;
|
||||
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
|
||||
}
|
||||
}
|
||||
// En caso contrario
|
||||
else
|
||||
{
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||
|
||||
// Incrementa el contador de la animacion
|
||||
animation[currentAnimation].counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void AnimatedSprite::setCurrentFrame(int num)
|
||||
{
|
||||
// Descarta valores fuera de rango
|
||||
if (num >= (int)animation[currentAnimation].frames.size())
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
animation[currentAnimation].counter = animation[currentAnimation].speed * num;
|
||||
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||
}
|
||||
|
||||
// Establece el valor del contador
|
||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
||||
{
|
||||
animation[getIndex(name)].counter = num;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
||||
{
|
||||
animation[getIndex(name)].counter = speed;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||
{
|
||||
animation[index].counter = speed;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
||||
{
|
||||
animation[getIndex(name)].loop = loop;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||
{
|
||||
animation[index].loop = loop;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
||||
{
|
||||
animation[getIndex(name)].completed = value;
|
||||
}
|
||||
|
||||
// OLD - Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||
{
|
||||
animation[index].completed = value;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool AnimatedSprite::animationIsCompleted()
|
||||
{
|
||||
return animation[currentAnimation].completed;
|
||||
}
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
||||
{
|
||||
return animation[getIndex(name)].frames[index];
|
||||
}
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool AnimatedSprite::load(std::string filePath)
|
||||
{
|
||||
int frames_per_row = 0;
|
||||
int frame_width = 0;
|
||||
int frame_height = 0;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::ifstream file(filePath);
|
||||
std::string line;
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
printf("Reading file %s\n", filename.c_str());
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||
if (line == "[animation]")
|
||||
{
|
||||
t_animation buffer;
|
||||
buffer.counter = 0;
|
||||
buffer.currentFrame = 0;
|
||||
buffer.completed = false;
|
||||
|
||||
do
|
||||
{
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "name")
|
||||
{
|
||||
buffer.name = line.substr(pos + 1, line.length());
|
||||
}
|
||||
else if (line.substr(0, pos) == "speed")
|
||||
{
|
||||
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
else if (line.substr(0, pos) == "loop")
|
||||
{
|
||||
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
else if (line.substr(0, pos) == "frames")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(line.substr(pos + 1, line.length()));
|
||||
std::string tmp;
|
||||
SDL_Rect rect = {0, 0, frame_width, frame_height};
|
||||
while (getline(ss, tmp, ','))
|
||||
{
|
||||
int num_tile = std::stoi(tmp);
|
||||
rect.x = (num_tile % frames_per_row) * frame_width;
|
||||
rect.y = (num_tile / frames_per_row) * frame_height;
|
||||
buffer.frames.push_back(rect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
} while (line != "[/animation]");
|
||||
|
||||
// Añade la animación al vector de animaciones
|
||||
animation.push_back(buffer);
|
||||
}
|
||||
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else
|
||||
{
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "frames_per_row")
|
||||
{
|
||||
frames_per_row = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frame_width")
|
||||
{
|
||||
frame_width = std::stoi(line.substr(pos + 1, line.length()));
|
||||
|
||||
// Normaliza valores
|
||||
if (frames_per_row == 0)
|
||||
{
|
||||
frames_per_row = texture->getWidth() / frame_width;
|
||||
}
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frame_height")
|
||||
{
|
||||
frame_height = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
printf("Closing file %s\n\n", filename.c_str());
|
||||
file.close();
|
||||
}
|
||||
// El fichero no se puede abrir
|
||||
else
|
||||
{
|
||||
printf("Warning: Unable to open %s file\n", filename.c_str());
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Pone un valor por defecto
|
||||
setPos({0, 0, frame_width, frame_height});
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void AnimatedSprite::setCurrentAnimation(std::string name)
|
||||
{
|
||||
const int newAnimation = getIndex(name);
|
||||
if (currentAnimation != newAnimation)
|
||||
{
|
||||
currentAnimation = newAnimation;
|
||||
animation[currentAnimation].currentFrame = 0;
|
||||
animation[currentAnimation].counter = 0;
|
||||
animation[currentAnimation].completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void AnimatedSprite::setCurrentAnimation(int index)
|
||||
{
|
||||
const int newAnimation = index;
|
||||
if (currentAnimation != newAnimation)
|
||||
{
|
||||
currentAnimation = newAnimation;
|
||||
animation[currentAnimation].currentFrame = 0;
|
||||
animation[currentAnimation].counter = 0;
|
||||
animation[currentAnimation].completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void AnimatedSprite::update()
|
||||
{
|
||||
animate();
|
||||
MovingSprite::update();
|
||||
}
|
||||
|
||||
// Establece el rectangulo para un frame de una animación
|
||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||
{
|
||||
animation[index_animation].frames.push_back({x, y, w, h});
|
||||
}
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void AnimatedSprite::setAnimationCounter(int value)
|
||||
{
|
||||
for (auto &a:animation)
|
||||
{
|
||||
a.counter = value;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "animatedsprite.h"
|
||||
#include "common/animatedsprite.h"
|
||||
#include "common/utils.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#ifndef BALLOON_H
|
||||
@@ -85,37 +86,39 @@ private:
|
||||
std::vector<float> h; // Vector con los valores de zoom para el alto del globo
|
||||
};
|
||||
|
||||
float mPosX; // Posición en el eje X
|
||||
float mPosY; // Posición en el eje Y
|
||||
Uint8 mWidth; // Ancho
|
||||
Uint8 mHeight; // Alto
|
||||
float mVelX; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float mVelY; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
float mGravity; // Aceleración en el eje Y. Modifica la velocidad
|
||||
float mDefaultVelY; // Velocidad inicial que tienen al rebotar contra el suelo
|
||||
float mMaxVelY; // Máxima velocidad que puede alcanzar el objeto en el eje Y
|
||||
AnimatedSprite *mSprite; // Sprite del objeto globo
|
||||
bool mBeingCreated; // Indica si el globo se está creando
|
||||
bool mBlinking; // Indica si el globo está intermitente
|
||||
bool mEnabled; // Indica si el globo esta activo
|
||||
bool mInvulnerable; // Indica si el globo es invulnerable
|
||||
bool mPopping; // Indica si el globo está explotando
|
||||
bool mStopped; // Indica si el globo está parado
|
||||
bool mVisible; // Indica si el globo es visible
|
||||
circle_t mCollider; // Circulo de colisión del objeto
|
||||
Uint16 mCreationCounter; // Temporizador para controlar el estado "creandose"
|
||||
Uint16 mCreationCounterIni; // Valor inicial para el temporizador para controlar el estado "creandose"
|
||||
Uint16 mScore; // Puntos que da el globo al ser destruido
|
||||
Uint16 mStoppedCounter; // Contador para controlar el estado "parado"
|
||||
Uint16 mTimeToLive; // Indica el tiempo de vida que le queda al globo
|
||||
Uint8 mKind; // Tipo de globo
|
||||
Uint8 mMenace; // Cantidad de amenaza que genera el globo
|
||||
Uint32 mCounter; // Contador interno
|
||||
float mTravelY; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
|
||||
float mSpeed; // Velocidad a la que se mueven los globos
|
||||
Uint8 mSize; // Tamaño del globo
|
||||
Uint8 mPower; // Cantidad de poder que alberga el globo
|
||||
bouncing mBouncing; // Contiene las variables para el efecto de rebote
|
||||
// Objetos y punteros
|
||||
AnimatedSprite *sprite; // Sprite del objeto globo
|
||||
|
||||
// Variables
|
||||
float posX; // Posición en el eje X
|
||||
float posY; // Posición en el eje Y
|
||||
Uint8 width; // Ancho
|
||||
Uint8 height; // Alto
|
||||
float velX; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float velY; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
float gravity; // Aceleración en el eje Y. Modifica la velocidad
|
||||
float defaultVelY; // Velocidad inicial que tienen al rebotar contra el suelo
|
||||
float maxVelY; // Máxima velocidad que puede alcanzar el objeto en el eje Y
|
||||
bool beingCreated; // Indica si el globo se está creando
|
||||
bool blinking; // Indica si el globo está intermitente
|
||||
bool enabled; // Indica si el globo esta activo
|
||||
bool invulnerable; // Indica si el globo es invulnerable
|
||||
bool popping; // Indica si el globo está explotando
|
||||
bool stopped; // Indica si el globo está parado
|
||||
bool visible; // Indica si el globo es visible
|
||||
circle_t collider; // Circulo de colisión del objeto
|
||||
Uint16 creationCounter; // Temporizador para controlar el estado "creandose"
|
||||
Uint16 creationCounterIni; // Valor inicial para el temporizador para controlar el estado "creandose"
|
||||
Uint16 score; // Puntos que da el globo al ser destruido
|
||||
Uint16 stoppedCounter; // Contador para controlar el estado "parado"
|
||||
Uint8 kind; // Tipo de globo
|
||||
Uint8 menace; // Cantidad de amenaza que genera el globo
|
||||
Uint32 counter; // Contador interno
|
||||
float travelY; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
|
||||
float speed; // Velocidad a la que se mueven los globos
|
||||
Uint8 size; // Tamaño del globo
|
||||
Uint8 power; // Cantidad de poder que alberga el globo
|
||||
bouncing bouncing; // Contiene las variables para el efecto de rebote
|
||||
|
||||
// Alinea el circulo de colisión con la posición del objeto globo
|
||||
void updateColliders();
|
||||
@@ -136,17 +139,11 @@ private:
|
||||
void updateAnimation();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setBeingCreated(bool state);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setTimeToLive(Uint16 time);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 getTimeToLive();
|
||||
void setBeingCreated(bool value);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, 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
|
||||
~Balloon();
|
||||
@@ -203,25 +200,25 @@ public:
|
||||
Uint8 getClass();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setStop(bool state);
|
||||
void setStop(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isStopped();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setBlink(bool state);
|
||||
void setBlink(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isBlinking();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVisible(bool state);
|
||||
void setVisible(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isVisible();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setInvulnerable(bool state);
|
||||
void setInvulnerable(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isInvulnerable();
|
||||
@@ -230,7 +227,7 @@ public:
|
||||
bool isBeingCreated();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPopping(bool state);
|
||||
void setPopping(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isPopping();
|
||||
|
||||
@@ -2,87 +2,73 @@
|
||||
#include "bullet.h"
|
||||
|
||||
// Constructor
|
||||
Bullet::Bullet()
|
||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
mSprite = new Sprite();
|
||||
mKind = NO_KIND;
|
||||
}
|
||||
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
||||
|
||||
// Destructor
|
||||
Bullet::~Bullet()
|
||||
{
|
||||
delete mSprite;
|
||||
mSprite = nullptr;
|
||||
}
|
||||
|
||||
// Iniciador
|
||||
void Bullet::init(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
// Posición inicial del objeto
|
||||
mPosX = x;
|
||||
mPosY = y;
|
||||
posX = x;
|
||||
posY = y;
|
||||
|
||||
// Alto y ancho del objeto
|
||||
mWidth = 10;
|
||||
mHeight = mWidth;
|
||||
width = 10;
|
||||
height = 10;
|
||||
|
||||
// Velocidad inicial en el eje Y
|
||||
mVelY = -3;
|
||||
velY = -3;
|
||||
|
||||
// Tipo de bala
|
||||
mKind = kind;
|
||||
this->kind = kind;
|
||||
|
||||
// Identificador del dueño del objeto
|
||||
mOwner = owner;
|
||||
|
||||
// Textura con los gráficos del objeto
|
||||
mSprite->setTexture(texture);
|
||||
|
||||
// Renderizador
|
||||
mSprite->setRenderer(renderer);
|
||||
|
||||
// Alto y ancho del sprite
|
||||
mSprite->setWidth(mWidth);
|
||||
mSprite->setHeight(mHeight);
|
||||
|
||||
// Posición inicial del sprite
|
||||
mSprite->setPosX(mPosX);
|
||||
mSprite->setPosY(mPosY);
|
||||
this->owner = owner;
|
||||
|
||||
// Valores especificos según el tipo
|
||||
switch (kind)
|
||||
{
|
||||
case BULLET_UP:
|
||||
// Establece la velocidad inicial
|
||||
mVelX = 0;
|
||||
velX = 0;
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
mSprite->setSpriteClip(0 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip(0 * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
else
|
||||
mSprite->setSpriteClip((0 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip((0 + 3) * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_LEFT:
|
||||
// Establece la velocidad inicial
|
||||
mVelX = -2;
|
||||
velX = -2;
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
mSprite->setSpriteClip(1 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip(1 * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
else
|
||||
mSprite->setSpriteClip((1 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip((1 + 3) * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_RIGHT:
|
||||
// Establece la velocidad inicial
|
||||
mVelX = 2;
|
||||
velX = 2;
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
mSprite->setSpriteClip(2 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip(2 * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
else
|
||||
mSprite->setSpriteClip((2 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
{
|
||||
sprite->setSpriteClip((2 + 3) * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -90,16 +76,22 @@ void Bullet::init(int x, int y, int kind, bool poweredUp, int owner, LTexture *t
|
||||
}
|
||||
|
||||
// Establece el tamaño del circulo de colisión
|
||||
mCollider.r = mWidth / 2;
|
||||
collider.r = width / 2;
|
||||
|
||||
// Alinea el circulo de colisión con el objeto
|
||||
shiftColliders();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Bullet::~Bullet()
|
||||
{
|
||||
delete sprite;
|
||||
}
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void Bullet::render()
|
||||
{
|
||||
mSprite->render();
|
||||
sprite->render();
|
||||
}
|
||||
|
||||
// Actualiza la posición y estado del objeto en horizontal
|
||||
@@ -109,34 +101,34 @@ Uint8 Bullet::move()
|
||||
Uint8 msg = BULLET_MOVE_OK;
|
||||
|
||||
// Mueve el objeto a su nueva posición
|
||||
mPosX += mVelX;
|
||||
posX += velX;
|
||||
|
||||
// Si el objeto se sale del area de juego por los laterales
|
||||
if ((mPosX < PLAY_AREA_LEFT) || (mPosX + mWidth > PLAY_AREA_RIGHT))
|
||||
if ((posX < PLAY_AREA_LEFT - width) || (posX > PLAY_AREA_RIGHT))
|
||||
{
|
||||
// Se deshabilita
|
||||
mKind = NO_KIND;
|
||||
kind = NO_KIND;
|
||||
|
||||
// Mensaje de salida
|
||||
msg = BULLET_MOVE_OUT;
|
||||
}
|
||||
|
||||
// Mueve el objeto a su nueva posición en vertical
|
||||
mPosY += int(mVelY);
|
||||
posY += int(velY);
|
||||
|
||||
// Si el objeto se sale del area de juego por la parte superior o inferior
|
||||
if ((mPosY < PLAY_AREA_TOP) || (mPosY + mHeight > PLAY_AREA_BOTTOM))
|
||||
// Si el objeto se sale del area de juego por la parte superior
|
||||
if (posY < PLAY_AREA_TOP - height)
|
||||
{
|
||||
// Se deshabilita
|
||||
mKind = NO_KIND;
|
||||
kind = NO_KIND;
|
||||
|
||||
// Mensaje de salida
|
||||
msg = BULLET_MOVE_OUT;
|
||||
}
|
||||
|
||||
// Actualiza la posición del sprite
|
||||
mSprite->setPosX(mPosX);
|
||||
mSprite->setPosY(mPosY);
|
||||
sprite->setPosX(posX);
|
||||
sprite->setPosY(posY);
|
||||
|
||||
// Alinea el circulo de colisión con el objeto
|
||||
shiftColliders();
|
||||
@@ -144,72 +136,76 @@ Uint8 Bullet::move()
|
||||
return msg;
|
||||
}
|
||||
|
||||
// Deshabilita el objeto
|
||||
void Bullet::erase()
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool Bullet::isEnabled()
|
||||
{
|
||||
init(0, 0, 0, false, -1, nullptr, nullptr);
|
||||
if (kind == NO_KIND)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si el objeto está activo
|
||||
bool Bullet::isActive()
|
||||
// Deshabilita el objeto
|
||||
void Bullet::disable()
|
||||
{
|
||||
if (mKind == NO_KIND)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
kind = NO_KIND;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getPosX()
|
||||
{
|
||||
return mPosX;
|
||||
return posX;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getPosY()
|
||||
{
|
||||
return mPosY;
|
||||
return posY;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Bullet::setPosX(int x)
|
||||
{
|
||||
mPosX = x;
|
||||
posX = x;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Bullet::setPosY(int y)
|
||||
{
|
||||
mPosY = y;
|
||||
posY = y;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getVelY()
|
||||
{
|
||||
return mVelY;
|
||||
return velY;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getKind()
|
||||
{
|
||||
return mKind;
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getOwner()
|
||||
{
|
||||
return mOwner;
|
||||
return owner;
|
||||
}
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &Bullet::getCollider()
|
||||
{
|
||||
return mCollider;
|
||||
return collider;
|
||||
}
|
||||
|
||||
// Alinea el circulo de colisión con el objeto
|
||||
void Bullet::shiftColliders()
|
||||
{
|
||||
mCollider.x = mPosX + mCollider.r;
|
||||
mCollider.y = mPosY + mCollider.r;
|
||||
collider.x = posX + collider.r;
|
||||
collider.y = posY + collider.r;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "sprite.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#ifndef BULLET_H
|
||||
#define BULLET_H
|
||||
@@ -20,41 +20,41 @@
|
||||
class Bullet
|
||||
{
|
||||
private:
|
||||
int mPosX; // Posición en el eje X
|
||||
int mPosY; // Posición en el eje Y
|
||||
Uint8 mWidth; // Ancho del objeto
|
||||
Uint8 mHeight; // Alto del objeto
|
||||
int mVelX; // Velocidad en el eje X
|
||||
int mVelY; // Velocidad en el eje Y
|
||||
int mKind; // Tipo de objeto
|
||||
int mOwner; // Identificador del dueño del objeto
|
||||
Sprite *mSprite; // Sprite con los graficos y métodos de pintado
|
||||
circle_t mCollider; // Circulo de colisión del objeto
|
||||
// Objetos y punteros
|
||||
Sprite *sprite; // Sprite con los graficos y métodos de pintado
|
||||
|
||||
// Variables
|
||||
int posX; // Posición en el eje X
|
||||
int posY; // Posición en el eje Y
|
||||
Uint8 width; // Ancho del objeto
|
||||
Uint8 height; // Alto del objeto
|
||||
int velX; // Velocidad en el eje X
|
||||
int velY; // Velocidad en el eje Y
|
||||
int kind; // Tipo de objeto
|
||||
int owner; // Identificador del dueño del objeto
|
||||
circle_t collider; // Circulo de colisión del objeto
|
||||
|
||||
// Alinea el circulo de colisión con el objeto
|
||||
void shiftColliders();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Bullet();
|
||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Bullet();
|
||||
|
||||
// Iniciador
|
||||
void init(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza la posición y estado del objeto
|
||||
Uint8 move();
|
||||
|
||||
// Deshabilita el objeto
|
||||
void erase();
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool isEnabled();
|
||||
|
||||
// Comprueba si el objeto está activo
|
||||
bool isActive();
|
||||
// Deshabilita el objeto
|
||||
void disable();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosX();
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#include "const.h"
|
||||
#include "coffeedrop.h"
|
||||
|
||||
#ifndef UNUSED
|
||||
|
||||
// Constructor
|
||||
CoffeeDrop::CoffeeDrop()
|
||||
{
|
||||
mPosX = 0;
|
||||
mPosY = 0;
|
||||
mWidth = 8;
|
||||
mHeight = 8;
|
||||
mVelX = 0;
|
||||
mVelY = 0;
|
||||
mGravity = 0.1f;
|
||||
mFloor = 0;
|
||||
mEnabled = false;
|
||||
mSprite = new Sprite();
|
||||
mAlpha = 128;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
CoffeeDrop::~CoffeeDrop()
|
||||
{
|
||||
delete mSprite;
|
||||
}
|
||||
|
||||
// Inicializador
|
||||
void CoffeeDrop::init(LTexture *texture, SDL_Renderer *renderer, float x, float y, float velX, float velY, int floor)
|
||||
{
|
||||
mEnabled = true;
|
||||
mPosX = x;
|
||||
mPosY = y;
|
||||
mVelX = velX;
|
||||
mVelY = velY;
|
||||
mFloor = floor;
|
||||
|
||||
mSprite->setRenderer(renderer);
|
||||
mSprite->setTexture(texture);
|
||||
mSprite->setSpriteClip(256, 97, mWidth, mHeight);
|
||||
mSprite->setPosX(x);
|
||||
mSprite->setPosY(y);
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void CoffeeDrop::update()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
mVelY += mGravity;
|
||||
mPosX += mVelX;
|
||||
mPosY += mVelY;
|
||||
|
||||
mSprite->setPosX((int)mPosX);
|
||||
mSprite->setPosY((int)mPosY);
|
||||
|
||||
if ((mPosY > mFloor) || (mPosX > PLAY_AREA_RIGHT) || ((mPosX - mWidth) < PLAY_AREA_LEFT))
|
||||
mEnabled = false;
|
||||
|
||||
mAlpha -= 2;
|
||||
if (mAlpha == 0)
|
||||
mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta el objeto
|
||||
void CoffeeDrop::render()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
mSprite->getTexture()->setAlpha(mAlpha);
|
||||
mSprite->render();
|
||||
mSprite->getTexture()->setAlpha(255);
|
||||
}
|
||||
}
|
||||
|
||||
// Deshabilita el objeto
|
||||
void CoffeeDrop::disable()
|
||||
{
|
||||
mEnabled = false;
|
||||
}
|
||||
|
||||
// Comprueba si està habilitado
|
||||
bool CoffeeDrop::isEnabled()
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "sprite.h"
|
||||
|
||||
#ifndef COFFEEDROP_H
|
||||
#define COFFEEDROP_H
|
||||
|
||||
#ifndef UNUSED
|
||||
|
||||
// Clase CoffeeDrop. Gotas de café que aparecen al explotar un globo
|
||||
class CoffeeDrop
|
||||
{
|
||||
private:
|
||||
float mPosX; // Posicion en el eje X del objeto
|
||||
float mPosY; // Posicion en el eje Y del objeto
|
||||
Uint8 mWidth; // Ancho del sprite
|
||||
Uint8 mHeight; // Alto del sprite
|
||||
float mVelX; // Velocidad en el eje X
|
||||
float mVelY; // Velocidad en el eje Y
|
||||
float mGravity; // Aceleración en el eje Y
|
||||
int mFloor; // Punto donde se encuentra el suelo y desaparecen
|
||||
bool mEnabled; // Si esta habilitado. Sirve para saber si se pinta, se actualiza o se puede usar
|
||||
Sprite *mSprite; // Puntero al sprite con los graficos
|
||||
Uint8 mAlpha;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
CoffeeDrop();
|
||||
|
||||
// Destructor
|
||||
~CoffeeDrop();
|
||||
|
||||
// Inicializador
|
||||
void init(LTexture *texture, SDL_Renderer *renderer, float x, float y, float velX, float velY, int floor);
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// Pinta el objeto
|
||||
void render();
|
||||
|
||||
// Deshabilita el objeto
|
||||
void disable();
|
||||
|
||||
// Comprueba si està habilitado
|
||||
bool isEnabled();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
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
|
||||
510
source/common/animatedsprite.cpp
Normal file
@@ -0,0 +1,510 @@
|
||||
#include "animatedsprite.h"
|
||||
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
||||
{
|
||||
// Copia los punteros
|
||||
setTexture(texture);
|
||||
setRenderer(renderer);
|
||||
|
||||
// Carga las animaciones
|
||||
if (file != "")
|
||||
{
|
||||
loadFromFile(file);
|
||||
}
|
||||
|
||||
else if (buffer)
|
||||
{
|
||||
loadFromVector(buffer);
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
currentAnimation = 0;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
AnimatedSprite::~AnimatedSprite()
|
||||
{
|
||||
for (auto &a : animation)
|
||||
{
|
||||
a.frames.clear();
|
||||
}
|
||||
animation.clear();
|
||||
}
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int AnimatedSprite::getIndex(std::string name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
for (auto a : animation)
|
||||
{
|
||||
index++;
|
||||
if (a.name == name)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Calcula el frame correspondiente a la animación
|
||||
void AnimatedSprite::animate()
|
||||
{
|
||||
if (!enabled || animation.at(currentAnimation).speed == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcula el frame actual a partir del contador
|
||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed;
|
||||
|
||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||
// en función de la variable loop y coloca el nuevo frame
|
||||
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size())
|
||||
{
|
||||
if (animation.at(currentAnimation).loop == -1)
|
||||
{ // Si no hay loop, deja el último frame
|
||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size();
|
||||
animation.at(currentAnimation).completed = true;
|
||||
}
|
||||
else
|
||||
{ // Si hay loop, vuelve al frame indicado
|
||||
animation.at(currentAnimation).counter = 0;
|
||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop;
|
||||
}
|
||||
}
|
||||
// En caso contrario
|
||||
else
|
||||
{
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
||||
|
||||
// Incrementa el contador de la animacion
|
||||
animation.at(currentAnimation).counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
void AnimatedSprite::setCurrentFrame(int num)
|
||||
{
|
||||
// Descarta valores fuera de rango
|
||||
if (num >= (int)animation.at(currentAnimation).frames.size())
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
animation.at(currentAnimation).counter = animation.at(currentAnimation).speed * num;
|
||||
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
||||
}
|
||||
|
||||
// Establece el valor del contador
|
||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
||||
{
|
||||
animation.at(getIndex(name)).counter = num;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
||||
{
|
||||
animation.at(getIndex(name)).counter = speed;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||
{
|
||||
animation.at(index).counter = speed;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
||||
{
|
||||
animation.at(getIndex(name)).loop = loop;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||
{
|
||||
animation.at(index).loop = loop;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
||||
{
|
||||
animation.at(getIndex(name)).completed = value;
|
||||
}
|
||||
|
||||
// OLD - Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||
{
|
||||
animation.at(index).completed = value;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool AnimatedSprite::animationIsCompleted()
|
||||
{
|
||||
return animation.at(currentAnimation).completed;
|
||||
}
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
||||
{
|
||||
return animation.at(getIndex(name)).frames.at(index);
|
||||
}
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
||||
{
|
||||
return animation.at(indexA).frames.at(indexF);
|
||||
}
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool AnimatedSprite::loadFromFile(std::string filePath)
|
||||
{
|
||||
int framesPerRow = 0;
|
||||
int frameWidth = 0;
|
||||
int frameHeight = 0;
|
||||
int maxTiles = 0;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::ifstream file(filePath);
|
||||
std::string line;
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
std::cout << "Loading animation from file: " << filePath.c_str() << std::endl;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||
if (line == "[animation]")
|
||||
{
|
||||
t_animation buffer;
|
||||
buffer.counter = 0;
|
||||
buffer.currentFrame = 0;
|
||||
buffer.completed = false;
|
||||
|
||||
do
|
||||
{
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "name")
|
||||
{
|
||||
buffer.name = line.substr(pos + 1, line.length());
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "speed")
|
||||
{
|
||||
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "loop")
|
||||
{
|
||||
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frames")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(line.substr(pos + 1, line.length()));
|
||||
std::string tmp;
|
||||
SDL_Rect rect = {0, 0, frameWidth, frameHeight};
|
||||
while (getline(ss, tmp, ','))
|
||||
{
|
||||
// Comprueba que el tile no sea mayor que el maximo indice permitido
|
||||
const int numTile = std::stoi(tmp) > maxTiles ? 0 : std::stoi(tmp);
|
||||
rect.x = (numTile % framesPerRow) * frameWidth;
|
||||
rect.y = (numTile / framesPerRow) * frameHeight;
|
||||
buffer.frames.push_back(rect);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
} while (line != "[/animation]");
|
||||
|
||||
// Añade la animación al vector de animaciones
|
||||
animation.push_back(buffer);
|
||||
}
|
||||
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else
|
||||
{
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "framesPerRow")
|
||||
{
|
||||
framesPerRow = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frameWidth")
|
||||
{
|
||||
frameWidth = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frameHeight")
|
||||
{
|
||||
frameHeight = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Normaliza valores
|
||||
if (framesPerRow == 0 && frameWidth > 0)
|
||||
{
|
||||
framesPerRow = texture->getWidth() / frameWidth;
|
||||
}
|
||||
|
||||
if (maxTiles == 0 && frameWidth > 0 && frameHeight > 0)
|
||||
{
|
||||
const int w = texture->getWidth() / frameWidth;
|
||||
const int h = texture->getHeight() / frameHeight;
|
||||
maxTiles = w * h;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
file.close();
|
||||
}
|
||||
// El fichero no se puede abrir
|
||||
else
|
||||
{
|
||||
printf("Warning: Unable to open %s file\n", filename.c_str());
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Pone un valor por defecto
|
||||
setRect({0, 0, frameWidth, frameHeight});
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Carga la animación desde un vector
|
||||
bool AnimatedSprite::loadFromVector(std::vector<std::string> *source)
|
||||
{
|
||||
// Inicializa variables
|
||||
int framesPerRow = 0;
|
||||
int frameWidth = 0;
|
||||
int frameHeight = 0;
|
||||
int maxTiles = 0;
|
||||
|
||||
// Indicador de éxito en el proceso
|
||||
bool success = true;
|
||||
std::string line;
|
||||
|
||||
// Recorre todo el vector
|
||||
int index = 0;
|
||||
while (index < (int)source->size())
|
||||
{
|
||||
// Lee desde el vector
|
||||
line = source->at(index);
|
||||
|
||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||
if (line == "[animation]")
|
||||
{
|
||||
t_animation buffer;
|
||||
buffer.counter = 0;
|
||||
buffer.currentFrame = 0;
|
||||
buffer.completed = false;
|
||||
|
||||
do
|
||||
{
|
||||
// Aumenta el indice para leer la siguiente linea
|
||||
index++;
|
||||
line = source->at(index);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "name")
|
||||
{
|
||||
buffer.name = line.substr(pos + 1, line.length());
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "speed")
|
||||
{
|
||||
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "loop")
|
||||
{
|
||||
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frames")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(line.substr(pos + 1, line.length()));
|
||||
std::string tmp;
|
||||
SDL_Rect rect = {0, 0, frameWidth, frameHeight};
|
||||
while (getline(ss, tmp, ','))
|
||||
{
|
||||
// Comprueba que el tile no sea mayor que el maximo indice permitido
|
||||
const int numTile = std::stoi(tmp) > maxTiles ? 0 : std::stoi(tmp);
|
||||
rect.x = (numTile % framesPerRow) * frameWidth;
|
||||
rect.y = (numTile / framesPerRow) * frameHeight;
|
||||
buffer.frames.push_back(rect);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
} while (line != "[/animation]");
|
||||
|
||||
// Añade la animación al vector de animaciones
|
||||
animation.push_back(buffer);
|
||||
}
|
||||
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else
|
||||
{
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
|
||||
// Procesa las dos subcadenas
|
||||
if (pos != (int)line.npos)
|
||||
{
|
||||
if (line.substr(0, pos) == "framesPerRow")
|
||||
{
|
||||
framesPerRow = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frameWidth")
|
||||
{
|
||||
frameWidth = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else if (line.substr(0, pos) == "frameHeight")
|
||||
{
|
||||
frameHeight = std::stoi(line.substr(pos + 1, line.length()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Normaliza valores
|
||||
if (framesPerRow == 0 && frameWidth > 0)
|
||||
{
|
||||
framesPerRow = texture->getWidth() / frameWidth;
|
||||
}
|
||||
|
||||
if (maxTiles == 0 && frameWidth > 0 && frameHeight > 0)
|
||||
{
|
||||
const int w = texture->getWidth() / frameWidth;
|
||||
const int h = texture->getHeight() / frameHeight;
|
||||
maxTiles = w * h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Una vez procesada la linea, aumenta el indice para pasar a la siguiente
|
||||
index++;
|
||||
}
|
||||
|
||||
// Pone un valor por defecto
|
||||
setRect({0, 0, frameWidth, frameHeight});
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void AnimatedSprite::setCurrentAnimation(std::string name)
|
||||
{
|
||||
const int newAnimation = getIndex(name);
|
||||
if (currentAnimation != newAnimation)
|
||||
{
|
||||
currentAnimation = newAnimation;
|
||||
animation.at(currentAnimation).currentFrame = 0;
|
||||
animation.at(currentAnimation).counter = 0;
|
||||
animation.at(currentAnimation).completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void AnimatedSprite::setCurrentAnimation(int index)
|
||||
{
|
||||
const int newAnimation = index;
|
||||
if (currentAnimation != newAnimation)
|
||||
{
|
||||
currentAnimation = newAnimation;
|
||||
animation.at(currentAnimation).currentFrame = 0;
|
||||
animation.at(currentAnimation).counter = 0;
|
||||
animation.at(currentAnimation).completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void AnimatedSprite::update()
|
||||
{
|
||||
animate();
|
||||
MovingSprite::update();
|
||||
}
|
||||
|
||||
// Establece el rectangulo para un frame de una animación
|
||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||
{
|
||||
animation.at(index_animation).frames.push_back({x, y, w, h});
|
||||
}
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void AnimatedSprite::setAnimationCounter(int value)
|
||||
{
|
||||
for (auto &a : animation)
|
||||
{
|
||||
a.counter = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Reinicia la animación
|
||||
void AnimatedSprite::resetAnimation()
|
||||
{
|
||||
animation.at(currentAnimation).currentFrame = 0;
|
||||
animation.at(currentAnimation).counter = 0;
|
||||
animation.at(currentAnimation).completed = false;
|
||||
}
|
||||
@@ -1,84 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "movingsprite.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
#ifndef ANIMATEDSPRITE_H
|
||||
#define ANIMATEDSPRITE_H
|
||||
|
||||
// Clase AnimatedSprite
|
||||
class AnimatedSprite : public MovingSprite
|
||||
{
|
||||
private:
|
||||
struct t_animation
|
||||
{
|
||||
std::string name; // Nombre de la animacion
|
||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||
int speed; // Velocidad de la animación
|
||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
||||
bool completed; // Indica si ha finalizado la animación
|
||||
int currentFrame; // Frame actual
|
||||
int counter; // Contador para las animaciones
|
||||
};
|
||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||
int currentAnimation; // Animacion activa
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "");
|
||||
|
||||
// Destructor
|
||||
~AnimatedSprite();
|
||||
|
||||
// Calcula el frame correspondiente a la animación actual
|
||||
void animate();
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void setCurrentFrame(int num);
|
||||
|
||||
// Establece el valor del contador
|
||||
void setAnimationCounter(std::string name, int num);
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void setAnimationSpeed(std::string name, int speed);
|
||||
void setAnimationSpeed(int index, int speed);
|
||||
|
||||
// Establece el frame al que vuelve la animación al finalizar
|
||||
void setAnimationLoop(std::string name, int loop);
|
||||
void setAnimationLoop(int index, int loop);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAnimationCompleted(std::string name, bool value);
|
||||
void setAnimationCompleted(int index, bool value);
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool animationIsCompleted();
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect getAnimationClip(std::string name, Uint8 index);
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int getIndex(std::string name);
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool load(std::string filePath);
|
||||
|
||||
// Establece la animacion actual
|
||||
void setCurrentAnimation(std::string name = "default");
|
||||
void setCurrentAnimation(int index = 0);
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// OLD - Establece el rectangulo para un frame de una animación
|
||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void setAnimationCounter(int value);
|
||||
};
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "movingsprite.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef ANIMATEDSPRITE_H
|
||||
#define ANIMATEDSPRITE_H
|
||||
|
||||
// Clase AnimatedSprite
|
||||
class AnimatedSprite : public MovingSprite
|
||||
{
|
||||
private:
|
||||
struct t_animation
|
||||
{
|
||||
std::string name; // Nombre de la animacion
|
||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||
int speed; // Velocidad de la animación
|
||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
||||
bool completed; // Indica si ha finalizado la animación
|
||||
int currentFrame; // Frame actual
|
||||
int counter; // Contador para las animaciones
|
||||
};
|
||||
|
||||
// Variables
|
||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||
int currentAnimation; // Animacion activa
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~AnimatedSprite();
|
||||
|
||||
// Calcula el frame correspondiente a la animación actual
|
||||
void animate();
|
||||
|
||||
// Obtiene el numero de frames de la animación actual
|
||||
int getNumFrames();
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void setCurrentFrame(int num);
|
||||
|
||||
// Establece el valor del contador
|
||||
void setAnimationCounter(std::string name, int num);
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void setAnimationSpeed(std::string name, int speed);
|
||||
void setAnimationSpeed(int index, int speed);
|
||||
|
||||
// Establece el frame al que vuelve la animación al finalizar
|
||||
void setAnimationLoop(std::string name, int loop);
|
||||
void setAnimationLoop(int index, int loop);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAnimationCompleted(std::string name, bool value);
|
||||
void setAnimationCompleted(int index, bool value);
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool animationIsCompleted();
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect getAnimationClip(std::string name, Uint8 index);
|
||||
SDL_Rect getAnimationClip(int indexA, Uint8 indexF);
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int getIndex(std::string name);
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool loadFromFile(std::string filePath);
|
||||
|
||||
// Carga la animación desde un vector
|
||||
bool loadFromVector(std::vector<std::string> *source);
|
||||
|
||||
// Establece la animacion actual
|
||||
void setCurrentAnimation(std::string name = "default");
|
||||
void setCurrentAnimation(int index = 0);
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// OLD - Establece el rectangulo para un frame de una animación
|
||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void setAnimationCounter(int value);
|
||||
|
||||
// Reinicia la animación
|
||||
void resetAnimation();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "asset.h"
|
||||
|
||||
// Constructor
|
||||
Asset::Asset(std::string path)
|
||||
Asset::Asset(std::string executablePath)
|
||||
{
|
||||
executablePath = path;
|
||||
longest_name = 0;
|
||||
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
||||
longestName = 0;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -13,7 +13,7 @@ Asset::~Asset()
|
||||
}
|
||||
|
||||
// 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;
|
||||
temp.file = executablePath + file;
|
||||
@@ -22,7 +22,7 @@ void Asset::add(std::string file, enum assetType_e type, bool required)
|
||||
fileList.push_back(temp);
|
||||
|
||||
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
|
||||
@@ -106,7 +106,7 @@ bool Asset::checkFile(std::string path)
|
||||
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());
|
||||
|
||||
return success;
|
||||
@@ -7,7 +7,7 @@
|
||||
#ifndef ASSET_H
|
||||
#define ASSET_H
|
||||
|
||||
enum assetType_e
|
||||
enum assetType
|
||||
{
|
||||
t_bitmap,
|
||||
t_music,
|
||||
@@ -29,11 +29,11 @@ private:
|
||||
struct item_t
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
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::string executablePath;
|
||||
@@ -46,13 +46,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Asset(std::string path);
|
||||
Asset(std::string executablePath);
|
||||
|
||||
// Destructor
|
||||
~Asset();
|
||||
|
||||
// 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
|
||||
std::string get(std::string text);
|
||||
@@ -5,38 +5,38 @@
|
||||
Input::Input(std::string file)
|
||||
{
|
||||
// Fichero gamecontrollerdb.txt
|
||||
mDBpath = file;
|
||||
dbPath = file;
|
||||
|
||||
// Inicializa las variables
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
mKeyBindings[i].scancode = 0;
|
||||
mKeyBindings[i].active = false;
|
||||
keyBindings_t kb;
|
||||
kb.scancode = 0;
|
||||
kb.active = false;
|
||||
keyBindings.resize(17, kb);
|
||||
|
||||
mGameControllerBindings[i].button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
mGameControllerBindings[i].active = false;
|
||||
}
|
||||
GameControllerBindings_t gcb;
|
||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
gcb.active = false;
|
||||
gameControllerBindings.resize(17, gcb);
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
discoverGameController();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Input::~Input()
|
||||
{
|
||||
for (int i = 0; i < mNumGamepads; i++)
|
||||
mConnectedControllers[i] = nullptr;
|
||||
}
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||
{
|
||||
mKeyBindings[input].scancode = code;
|
||||
keyBindings.at(input).scancode = code;
|
||||
}
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||
{
|
||||
mGameControllerBindings[input].button = button;
|
||||
gameControllerBindings.at(input).button = button;
|
||||
}
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
@@ -48,24 +48,28 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
if (device == INPUT_USE_ANY)
|
||||
index = 0;
|
||||
|
||||
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
|
||||
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||
{
|
||||
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
if (repeat)
|
||||
{
|
||||
if (mKeystates[mKeyBindings[input].scancode] != 0)
|
||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
||||
{
|
||||
successKeyboard = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
successKeyboard = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mKeyBindings[input].active)
|
||||
if (!keyBindings.at(input).active)
|
||||
{
|
||||
if (mKeystates[mKeyBindings[input].scancode] != 0)
|
||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
||||
{
|
||||
mKeyBindings[input].active = true;
|
||||
keyBindings.at(input).active = true;
|
||||
successKeyboard = true;
|
||||
}
|
||||
else
|
||||
@@ -75,9 +79,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mKeystates[mKeyBindings[input].scancode] == 0)
|
||||
if (keyStates[keyBindings.at(input).scancode] == 0)
|
||||
{
|
||||
mKeyBindings[input].active = false;
|
||||
keyBindings.at(input).active = false;
|
||||
successKeyboard = false;
|
||||
}
|
||||
else
|
||||
@@ -93,18 +97,22 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||
{
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
successGameController = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mGameControllerBindings[input].active)
|
||||
if (!gameControllerBindings.at(input).active)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||
{
|
||||
mGameControllerBindings[input].active = true;
|
||||
gameControllerBindings.at(input).active = true;
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
@@ -114,9 +122,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) == 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
||||
{
|
||||
mGameControllerBindings[input].active = false;
|
||||
gameControllerBindings.at(input).active = false;
|
||||
successGameController = false;
|
||||
}
|
||||
else
|
||||
@@ -130,51 +138,98 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
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
|
||||
bool Input::discoverGameController()
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
}
|
||||
|
||||
if (SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()) < 0)
|
||||
printf("Error, could not load %s file: %s\n", mDBpath.c_str(), SDL_GetError());
|
||||
if (SDL_GameControllerAddMappingsFromFile(dbPath.c_str()) < 0)
|
||||
{
|
||||
printf("Error, could not load %s file: %s\n", dbPath.c_str(), SDL_GetError());
|
||||
}
|
||||
|
||||
int nJoysticks = SDL_NumJoysticks();
|
||||
mNumGamepads = 0;
|
||||
const int nJoysticks = SDL_NumJoysticks();
|
||||
numGamepads = 0;
|
||||
|
||||
// Cuenta el numero de mandos
|
||||
for (int i = 0; i < nJoysticks; i++)
|
||||
for (int i = 0; i < nJoysticks; ++i)
|
||||
{
|
||||
if (SDL_IsGameController(i))
|
||||
mNumGamepads++;
|
||||
{
|
||||
numGamepads++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\nChecking for game controllers...\n");
|
||||
printf("%i joysticks found, %i are gamepads\n", nJoysticks, mNumGamepads);
|
||||
printf("%i joysticks found, %i are gamepads\n", nJoysticks, numGamepads);
|
||||
|
||||
if (mNumGamepads > 0)
|
||||
if (numGamepads > 0)
|
||||
{
|
||||
found = true;
|
||||
|
||||
for (int i = 0; i < mNumGamepads; i++)
|
||||
for (int i = 0; i < numGamepads; i++)
|
||||
{
|
||||
// Abre el mando y lo añade a la lista
|
||||
SDL_GameController *pad = SDL_GameControllerOpen(i);
|
||||
if (SDL_GameControllerGetAttached(pad) == 1)
|
||||
{
|
||||
mConnectedControllers.push_back(pad);
|
||||
std::string separator(" #");
|
||||
connectedControllers.push_back(pad);
|
||||
const std::string separator(" #");
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
name.resize(25);
|
||||
name = name + separator + std::to_string(i);
|
||||
std::cout << name << std::endl;
|
||||
mControllerNames.push_back(name);
|
||||
controllerNames.push_back(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//mGameController = mConnectedControllers[0];
|
||||
SDL_GameControllerEventState(SDL_ENABLE);
|
||||
}
|
||||
|
||||
@@ -184,23 +239,31 @@ bool Input::discoverGameController()
|
||||
// Comprueba si hay algun mando conectado
|
||||
bool Input::gameControllerFound()
|
||||
{
|
||||
if (mNumGamepads > 0)
|
||||
if (numGamepads > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string Input::getControllerName(int index)
|
||||
{
|
||||
if (mNumGamepads > 0)
|
||||
return mControllerNames[index];
|
||||
if (numGamepads > 0)
|
||||
{
|
||||
return controllerNames.at(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int Input::getNumControllers()
|
||||
{
|
||||
return mNumGamepads;
|
||||
return numGamepads;
|
||||
}
|
||||
@@ -1,87 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_UP 1
|
||||
#define INPUT_DOWN 2
|
||||
#define INPUT_LEFT 3
|
||||
#define INPUT_RIGHT 4
|
||||
#define INPUT_ACCEPT 5
|
||||
#define INPUT_CANCEL 6
|
||||
#define INPUT_BUTTON_1 7
|
||||
#define INPUT_BUTTON_2 8
|
||||
#define INPUT_BUTTON_3 9
|
||||
#define INPUT_BUTTON_4 10
|
||||
#define INPUT_BUTTON_5 11
|
||||
#define INPUT_BUTTON_6 12
|
||||
#define INPUT_BUTTON_7 13
|
||||
#define INPUT_BUTTON_8 14
|
||||
#define INPUT_BUTTON_PAUSE 15
|
||||
#define INPUT_BUTTON_ESCAPE 16
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
struct keyBindings_t
|
||||
{
|
||||
Uint8 scancode; // Scancode asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
keyBindings_t mKeyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
|
||||
struct GameControllerBindings_t
|
||||
{
|
||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
|
||||
std::vector<SDL_GameController *> mConnectedControllers; // Vector con todos los mandos conectados
|
||||
std::vector<std::string> mControllerNames; // Vector con los nombres de los mandos
|
||||
int mNumGamepads; // Numero de mandos conectados
|
||||
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
bool discoverGameController();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
||||
|
||||
// Comprueba si hay algun mando conectado
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_UP 1
|
||||
#define INPUT_DOWN 2
|
||||
#define INPUT_LEFT 3
|
||||
#define INPUT_RIGHT 4
|
||||
#define INPUT_ACCEPT 5
|
||||
#define INPUT_CANCEL 6
|
||||
#define INPUT_BUTTON_1 7
|
||||
#define INPUT_BUTTON_2 8
|
||||
#define INPUT_BUTTON_3 9
|
||||
#define INPUT_BUTTON_4 10
|
||||
#define INPUT_BUTTON_5 11
|
||||
#define INPUT_BUTTON_6 12
|
||||
#define INPUT_BUTTON_7 13
|
||||
#define INPUT_BUTTON_8 14
|
||||
#define INPUT_BUTTON_PAUSE 15
|
||||
#define INPUT_BUTTON_ESCAPE 16
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
struct keyBindings_t
|
||||
{
|
||||
Uint8 scancode; // Scancode asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
struct GameControllerBindings_t
|
||||
{
|
||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
|
||||
std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
|
||||
int numGamepads; // Numero de mandos conectados
|
||||
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
bool discoverGameController();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
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
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,23 +1,65 @@
|
||||
#include "const.h"
|
||||
#include "menu.h"
|
||||
|
||||
// Constructor
|
||||
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
|
||||
// Inicializa punteros
|
||||
soundMove = nullptr;
|
||||
soundAccept = nullptr;
|
||||
soundCancel = nullptr;
|
||||
|
||||
init();
|
||||
// Inicializa variables
|
||||
name = "";
|
||||
selector.index = 0;
|
||||
itemSelected = MENU_NO_OPTION;
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = 0;
|
||||
rectBG.rect = {0, 0, 0, 0};
|
||||
rectBG.color = {0, 0, 0};
|
||||
rectBG.a = 0;
|
||||
backgroundType = MENU_BACKGROUND_SOLID;
|
||||
isCenteredOnX = false;
|
||||
isCenteredOnY = false;
|
||||
areElementsCenteredOnX = false;
|
||||
centerX = 0;
|
||||
centerY = 0;
|
||||
widestItem = 0;
|
||||
colorGreyed = {128, 128, 128};
|
||||
defaultActionWhenCancel = 0;
|
||||
font_png = "";
|
||||
font_txt = "";
|
||||
|
||||
// Selector
|
||||
selector.originY = 0;
|
||||
selector.targetY = 0;
|
||||
selector.despY = 0;
|
||||
selector.originH = 0;
|
||||
selector.targetH = 0;
|
||||
selector.incH = 0;
|
||||
selector.y = 0.0f;
|
||||
selector.h = 0.0f;
|
||||
selector.numJumps = 8;
|
||||
selector.moving = false;
|
||||
selector.resizing = false;
|
||||
selector.rect = {0, 0, 0, 0};
|
||||
selector.color = {0, 0, 0};
|
||||
selector.itemColor = {0, 0, 0};
|
||||
selector.a = 255;
|
||||
|
||||
// Inicializa las variables desde un fichero
|
||||
if (file != "")
|
||||
{
|
||||
load(file);
|
||||
}
|
||||
reorganize();
|
||||
|
||||
// Deja el cursor en el primer elemento
|
||||
reset();
|
||||
}
|
||||
|
||||
Menu::~Menu()
|
||||
@@ -56,7 +98,7 @@ bool Menu::load(std::string file_path)
|
||||
// Indica si se ha creado ya el objeto de texto
|
||||
bool textAllocated = false;
|
||||
|
||||
std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
const std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::string line;
|
||||
std::ifstream file(file_path);
|
||||
|
||||
@@ -78,7 +120,7 @@ bool Menu::load(std::string file_path)
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
// Lee la siguiente linea
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
@@ -118,7 +160,7 @@ bool Menu::load(std::string file_path)
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
printf("Closing file %s\n\n", filename.c_str());
|
||||
printf("Closing file %s\n", filename.c_str());
|
||||
file.close();
|
||||
}
|
||||
// El fichero no se puede abrir
|
||||
@@ -165,6 +207,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
||||
else if ((var == "") || (var == "[/item]"))
|
||||
{
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
@@ -309,48 +352,6 @@ bool Menu::setVars(std::string var, std::string value)
|
||||
return success;
|
||||
}
|
||||
|
||||
// Inicializa las variables
|
||||
void Menu::init()
|
||||
{
|
||||
// Inicia variables
|
||||
name = "";
|
||||
selector.index = 0;
|
||||
itemSelected = MENU_NO_OPTION;
|
||||
x = 0;
|
||||
y = 0;
|
||||
rectBG.rect = {0, 0, 0, 0};
|
||||
rectBG.color = {0, 0, 0};
|
||||
rectBG.a = 0;
|
||||
backgroundType = MENU_BACKGROUND_SOLID;
|
||||
isCenteredOnX = false;
|
||||
isCenteredOnY = false;
|
||||
areElementsCenteredOnX = false;
|
||||
centerX = 0;
|
||||
centerY = 0;
|
||||
widestItem = 0;
|
||||
colorGreyed = {128, 128, 128};
|
||||
defaultActionWhenCancel = 0;
|
||||
font_png = "";
|
||||
font_txt = "";
|
||||
|
||||
// Selector
|
||||
selector.originY = 0;
|
||||
selector.targetY = 0;
|
||||
selector.despY = 0;
|
||||
selector.originH = 0;
|
||||
selector.targetH = 0;
|
||||
selector.incH = 0;
|
||||
selector.y = 0.0f;
|
||||
selector.h = 0.0f;
|
||||
selector.numJumps = 8;
|
||||
selector.moving = false;
|
||||
selector.resizing = false;
|
||||
selector.rect = {0, 0, 0, 0};
|
||||
selector.color = {0, 0, 0};
|
||||
selector.itemColor = {0, 0, 0};
|
||||
selector.a = 255;
|
||||
}
|
||||
|
||||
// Carga los ficheros de audio
|
||||
void Menu::loadAudioFile(std::string file, int sound)
|
||||
{
|
||||
@@ -403,7 +404,8 @@ void Menu::updateSelector()
|
||||
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
|
||||
{
|
||||
@@ -431,7 +433,8 @@ void Menu::updateSelector()
|
||||
selector.resizing = false;
|
||||
}
|
||||
}
|
||||
if (selector.incH < 0) // Decrece
|
||||
|
||||
else if (selector.incH < 0) // Decrece
|
||||
{
|
||||
if (selector.h < selector.targetH) // Ha llegado al destino
|
||||
{
|
||||
@@ -454,7 +457,7 @@ void Menu::setSelectorPos(int index)
|
||||
if (index < (int)item.size())
|
||||
{
|
||||
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.x = rectBG.rect.x;
|
||||
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
||||
@@ -482,10 +485,17 @@ void Menu::reset()
|
||||
{
|
||||
itemSelected = MENU_NO_OPTION;
|
||||
selector.index = 0;
|
||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
||||
selector.originH = selector.targetH = item[0].rect.h;
|
||||
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
||||
selector.originH = selector.targetH = item.at(0).rect.h;
|
||||
selector.moving = false;
|
||||
selector.resizing = false;
|
||||
|
||||
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||
if (!item.at(selector.index).selectable)
|
||||
{
|
||||
increaseSelectorIndex();
|
||||
setSelectorPos(selector.index);
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
||||
@@ -513,18 +523,18 @@ void Menu::reorganize()
|
||||
bool Menu::increaseSelectorIndex()
|
||||
{
|
||||
// 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);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
++selector.index %= item.size();
|
||||
while (!item[selector.index].selectable)
|
||||
while (!item.at(selector.index).selectable)
|
||||
{
|
||||
++selector.index %= item.size();
|
||||
}
|
||||
|
||||
// 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.targetH = getSelectorHeight(selector.index);
|
||||
@@ -543,24 +553,24 @@ bool Menu::increaseSelectorIndex()
|
||||
bool Menu::decreaseSelectorIndex()
|
||||
{
|
||||
// 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);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
if (selector.index == 0)
|
||||
{
|
||||
selector.index = item.size();
|
||||
selector.index = item.size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
selector.index--;
|
||||
}
|
||||
|
||||
while (!item[selector.index].selectable)
|
||||
while (!item.at(selector.index).selectable)
|
||||
{
|
||||
if (selector.index == 0)
|
||||
{
|
||||
selector.index = item.size();
|
||||
selector.index = item.size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -569,7 +579,7 @@ bool Menu::decreaseSelectorIndex()
|
||||
}
|
||||
|
||||
// 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.targetH = getSelectorHeight(selector.index);
|
||||
@@ -603,8 +613,6 @@ void Menu::render()
|
||||
|
||||
// Renderiza el rectangulo del selector
|
||||
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_RenderFillRect(renderer, &temp);
|
||||
|
||||
@@ -621,40 +629,74 @@ void Menu::render()
|
||||
if (i == selector.index)
|
||||
{
|
||||
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
|
||||
// No seleccionable
|
||||
{
|
||||
if ((item[i].linkedUp) && (i == selector.index + 1))
|
||||
{ // No seleccionable
|
||||
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
void Menu::setRectSize()
|
||||
void Menu::setRectSize(int w, int h)
|
||||
{
|
||||
rectBG.rect.w = findWidth() + text->getCharacterSize();
|
||||
rectBG.rect.h = findHeight() + text->getCharacterSize();
|
||||
// Establece el ancho
|
||||
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
|
||||
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
|
||||
rectBG.rect.y = y - (text->getCharacterSize() / 2);
|
||||
@@ -687,10 +729,28 @@ void Menu::setSelectorTextColor(color_t color)
|
||||
void Menu::centerMenuOnX(int value)
|
||||
{
|
||||
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
|
||||
x = (value) - (findWidth() / 2);
|
||||
// Establece la nueva posición centrada en funcion del elemento más ancho o del ancho fijo del menu
|
||||
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
|
||||
for (auto &i : item)
|
||||
@@ -700,6 +760,12 @@ void Menu::centerMenuOnX(int value)
|
||||
|
||||
// Recalcula el rectangulo de fondo
|
||||
setRectSize();
|
||||
|
||||
// Vuelve a centrar los elementos si fuera el caso
|
||||
if (areElementsCenteredOnX)
|
||||
{
|
||||
centerMenuElementsOnX();
|
||||
}
|
||||
}
|
||||
|
||||
// Centra el menu respecto un punto en el eje Y
|
||||
@@ -733,14 +799,13 @@ void Menu::centerMenuElementsOnX()
|
||||
void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown)
|
||||
{
|
||||
item_t temp;
|
||||
// Si es el primer item coge la posición en el eje Y del propio menu
|
||||
if (item.size() == 0)
|
||||
{
|
||||
|
||||
if (item.empty())
|
||||
{ // Si es el primer item coge la posición en el eje Y del propio menu
|
||||
temp.rect.y = y;
|
||||
}
|
||||
else
|
||||
// En caso contrario, coge la posición en el eje Y a partir del elemento anterior
|
||||
{
|
||||
{ // En caso contrario, coge la posición en el eje Y a partir del último elemento
|
||||
temp.rect.y = item.back().rect.y + item.back().rect.h + item.back().hPaddingDown;
|
||||
}
|
||||
|
||||
@@ -751,13 +816,14 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
||||
temp.linkedDown = linkedDown;
|
||||
|
||||
item.push_back(temp);
|
||||
|
||||
setItemCaption(item.size() - 1, text);
|
||||
|
||||
if (item.size() > 0)
|
||||
if (item.size() > 1)
|
||||
{
|
||||
if (item[item.size() - 1].linkedDown)
|
||||
if (item.at(item.size() - 2).linkedDown)
|
||||
{
|
||||
item[item.size()].linkedUp = true;
|
||||
item.back().linkedUp = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,13 +834,10 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
||||
// Cambia el texto de un item
|
||||
void Menu::setItemCaption(int index, std::string text)
|
||||
{
|
||||
item[index].label = text;
|
||||
item[index].rect.w = this->text->lenght(item[index].label);
|
||||
item[index].rect.h = this->text->getCharacterSize();
|
||||
item.at(index).label = text;
|
||||
item.at(index).rect.w = this->text->lenght(item.at(index).label);
|
||||
item.at(index).rect.h = this->text->getCharacterSize();
|
||||
reorganize();
|
||||
|
||||
const std::string texto = item[index].label + ":" + std::to_string(item[index].rect.w);
|
||||
printf("Adding menu item -> %s\n", texto.c_str());
|
||||
}
|
||||
|
||||
// Establece el indice del itemm que se usará por defecto al cancelar el menu
|
||||
@@ -850,42 +913,42 @@ int Menu::findHeight()
|
||||
// Recoloca los elementos del menu en el eje Y
|
||||
void Menu::replaceElementsOnY()
|
||||
{
|
||||
item[0].rect.y = y;
|
||||
item.at(0).rect.y = y;
|
||||
|
||||
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
|
||||
void Menu::setSelectable(int index, bool value)
|
||||
{
|
||||
item[index].selectable = value;
|
||||
item.at(index).selectable = value;
|
||||
}
|
||||
|
||||
// Establece el estado agrisado de un item
|
||||
void Menu::setGreyed(int index, bool value)
|
||||
{
|
||||
item[index].greyed = value;
|
||||
item.at(index).greyed = value;
|
||||
}
|
||||
|
||||
// Establece el estado de enlace de un item
|
||||
void Menu::setLinkedDown(int index, bool value)
|
||||
{
|
||||
item[index].linkedDown = value;
|
||||
item.at(index).linkedDown = value;
|
||||
}
|
||||
|
||||
// Calcula la altura del selector
|
||||
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
|
||||
{
|
||||
return item[value].rect.h;
|
||||
return item.at(value).rect.h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,6 +976,6 @@ void Menu::setText(std::string font_png, std::string font_txt)
|
||||
{
|
||||
if (!text)
|
||||
{
|
||||
text = new Text(asset->get(font_png), asset->get(font_txt), renderer);
|
||||
text = new Text(font_png, font_txt, renderer);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <vector>
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "asset.h"
|
||||
#include "input.h"
|
||||
#include "utils.h"
|
||||
#include "jail_audio.h"
|
||||
#include <sstream>
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
@@ -68,6 +68,13 @@ private:
|
||||
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
|
||||
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
|
||||
@@ -85,10 +92,6 @@ private:
|
||||
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu
|
||||
JA_Sound soundCancel; // Sonido al cancelar el menu
|
||||
JA_Sound soundMove; // Sonido al mover el selector
|
||||
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
|
||||
rectangle_t rectBG; // Rectangulo de fondo 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
|
||||
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
|
||||
void reorganize();
|
||||
|
||||
@@ -143,7 +140,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file="");
|
||||
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file = "");
|
||||
|
||||
// Destructor
|
||||
~Menu();
|
||||
@@ -179,7 +176,7 @@ public:
|
||||
void setSelectorTextColor(color_t color);
|
||||
|
||||
// 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
|
||||
void centerMenuOnY(int value);
|
||||
@@ -219,6 +216,9 @@ public:
|
||||
|
||||
// Establece la fuente de texto que se utilizará
|
||||
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
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "const.h"
|
||||
#include "movingsprite.h"
|
||||
|
||||
// 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
|
||||
this->texture = texture;
|
||||
@@ -45,17 +44,12 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
|
||||
spriteClip = {0, 0, w, h};
|
||||
|
||||
// Establece el centro de rotación
|
||||
center = {0, 0};
|
||||
center = nullptr;
|
||||
|
||||
// Establece el tipo de volteado
|
||||
currentFlip = SDL_FLIP_NONE;
|
||||
};
|
||||
|
||||
// Destructor
|
||||
MovingSprite::~MovingSprite()
|
||||
{
|
||||
}
|
||||
|
||||
// Reinicia todas las variables
|
||||
void MovingSprite::clear()
|
||||
{
|
||||
@@ -73,7 +67,7 @@ void MovingSprite::clear()
|
||||
|
||||
angle = 0.0; // Angulo para dibujarlo
|
||||
rotateEnabled = false; // Indica si ha de rotar
|
||||
center = {0, 0}; // Centro de rotación
|
||||
center = nullptr; // Centro de rotación
|
||||
rotateSpeed = 0; // Velocidad de giro
|
||||
rotateAmount = 0.0; // Cantidad de grados a girar en cada iteración
|
||||
counter = 0; // Contador interno
|
||||
@@ -101,7 +95,9 @@ void MovingSprite::move()
|
||||
void MovingSprite::render()
|
||||
{
|
||||
if (enabled)
|
||||
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, ¢er, currentFlip);
|
||||
{
|
||||
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, center, currentFlip);
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
@@ -158,11 +154,13 @@ double MovingSprite::getAngle()
|
||||
return angle;
|
||||
}
|
||||
|
||||
// Establece la posición del objeto
|
||||
void MovingSprite::setPos(SDL_Rect rect)
|
||||
// Establece la posición y el tamaño del objeto
|
||||
void MovingSprite::setRect(SDL_Rect rect)
|
||||
{
|
||||
x = (float)rect.x;
|
||||
y = (float)rect.y;
|
||||
w = rect.w;
|
||||
h = rect.h;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
@@ -265,7 +263,14 @@ void MovingSprite::setRotate(bool value)
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::setRotateSpeed(int value)
|
||||
{
|
||||
rotateSpeed = value;
|
||||
if (value < 1)
|
||||
{
|
||||
rotateSpeed = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotateSpeed = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
@@ -324,15 +329,6 @@ SDL_Rect MovingSprite::getRect()
|
||||
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
|
||||
void MovingSprite::undoMove()
|
||||
{
|
||||
@@ -1,173 +1,167 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "sprite.h"
|
||||
|
||||
#ifndef MOVINGSPRITE_H
|
||||
#define MOVINGSPRITE_H
|
||||
|
||||
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
|
||||
class MovingSprite : public Sprite
|
||||
{
|
||||
protected:
|
||||
float x; // Posición en el eje X
|
||||
float y; // Posición en el eje Y
|
||||
|
||||
float xPrev; // Posición anterior en el eje X
|
||||
float yPrev; // Posición anterior en el eje Y
|
||||
|
||||
float vx; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float vy; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
|
||||
float ax; // Aceleración en el eje X. Variación de la velocidad
|
||||
float ay; // Aceleración en el eje Y. Variación de la velocidad
|
||||
|
||||
float zoomW; // Zoom aplicado a la anchura
|
||||
float zoomH; // Zoom aplicado a la altura
|
||||
|
||||
double angle; // Angulo para dibujarlo
|
||||
bool rotateEnabled; // Indica si ha de rotar
|
||||
int rotateSpeed; // Velocidad de giro
|
||||
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||
int counter; // Contador interno
|
||||
SDL_Point center; // Centro de rotación
|
||||
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||
|
||||
public:
|
||||
// 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);
|
||||
|
||||
// Destructor
|
||||
~MovingSprite();
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
// Rota el sprite
|
||||
void rotate();
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
void update();
|
||||
|
||||
// Reinicia todas las variables
|
||||
void clear();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomW();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomH();
|
||||
|
||||
// Obten el valor de la variable
|
||||
double getAngle();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getRotate();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getRotateSpeed();
|
||||
|
||||
// Establece la posición del objeto
|
||||
void setPos(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomW(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomH(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAngle(double vaue);
|
||||
|
||||
// Incrementa el valor de la variable
|
||||
void incAngle(double value);
|
||||
|
||||
// Decrementa el valor de la variable
|
||||
void decAngle(double value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotate(bool value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateSpeed(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateAmount(double value);
|
||||
|
||||
// Quita el efecto de rotación y deja el sprite en su angulo inicial.
|
||||
void disableRotate();
|
||||
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlip(SDL_RendererFlip flip);
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void flip();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
SDL_RendererFlip getFlip();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Establece los valores de posición y tamaño del sprite
|
||||
void setRect(SDL_Rect rect);
|
||||
|
||||
// Deshace el último movimiento
|
||||
void undoMove();
|
||||
|
||||
// Deshace el último movimiento en el eje X
|
||||
void undoMoveX();
|
||||
|
||||
// Deshace el último movimiento en el eje Y
|
||||
void undoMoveY();
|
||||
|
||||
// Pone a cero las velocidades de desplacamiento
|
||||
void clearVel();
|
||||
|
||||
// Devuelve el incremento en el eje X en pixels
|
||||
int getIncX();
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "sprite.h"
|
||||
|
||||
#ifndef MOVINGSPRITE_H
|
||||
#define MOVINGSPRITE_H
|
||||
|
||||
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
|
||||
class MovingSprite : public Sprite
|
||||
{
|
||||
protected:
|
||||
float x; // Posición en el eje X
|
||||
float y; // Posición en el eje Y
|
||||
|
||||
float xPrev; // Posición anterior en el eje X
|
||||
float yPrev; // Posición anterior en el eje Y
|
||||
|
||||
float vx; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float vy; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
|
||||
float ax; // Aceleración en el eje X. Variación de la velocidad
|
||||
float ay; // Aceleración en el eje Y. Variación de la velocidad
|
||||
|
||||
float zoomW; // Zoom aplicado a la anchura
|
||||
float zoomH; // Zoom aplicado a la altura
|
||||
|
||||
double angle; // Angulo para dibujarlo
|
||||
bool rotateEnabled; // Indica si ha de rotar
|
||||
int rotateSpeed; // Velocidad de giro
|
||||
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||
int counter; // Contador interno
|
||||
SDL_Point *center; // Centro de rotación
|
||||
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||
|
||||
public:
|
||||
// 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, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
// Rota el sprite
|
||||
void rotate();
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
void update();
|
||||
|
||||
// Reinicia todas las variables
|
||||
void clear();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomW();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomH();
|
||||
|
||||
// Obten el valor de la variable
|
||||
double getAngle();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getRotate();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getRotateSpeed();
|
||||
|
||||
// Establece la posición y el tamaño del objeto
|
||||
void setRect(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomW(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomH(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAngle(double vaue);
|
||||
|
||||
// Incrementa el valor de la variable
|
||||
void incAngle(double value);
|
||||
|
||||
// Decrementa el valor de la variable
|
||||
void decAngle(double value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotate(bool value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateSpeed(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateAmount(double value);
|
||||
|
||||
// Quita el efecto de rotación y deja el sprite en su angulo inicial.
|
||||
void disableRotate();
|
||||
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlip(SDL_RendererFlip flip);
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void flip();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
SDL_RendererFlip getFlip();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Deshace el último movimiento
|
||||
void undoMove();
|
||||
|
||||
// Deshace el último movimiento en el eje X
|
||||
void undoMoveX();
|
||||
|
||||
// Deshace el último movimiento en el eje Y
|
||||
void undoMoveY();
|
||||
|
||||
// Pone a cero las velocidades de desplacamiento
|
||||
void clearVel();
|
||||
|
||||
// Devuelve el incremento en el eje X en pixels
|
||||
int getIncX();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -21,8 +21,10 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
||||
|
||||
// Crea la textura donde se dibujan los graficos del juego
|
||||
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());
|
||||
}
|
||||
|
||||
// Establece el modo de video
|
||||
setVideoMode(options->fullScreenMode);
|
||||
@@ -59,14 +61,14 @@ void Screen::start()
|
||||
void Screen::blit()
|
||||
{
|
||||
// Vuelve a dejar el renderizador en modo normal
|
||||
SDL_SetRenderTarget(renderer, NULL);
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
|
||||
// Borra el contenido previo
|
||||
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// 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
|
||||
SDL_RenderPresent(renderer);
|
||||
@@ -344,7 +346,7 @@ void Screen::renderSpectrumFade()
|
||||
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
||||
const int max = spectrumColor.size() - 1;
|
||||
const int index = max + (0 - max) * step;
|
||||
const color_t c = spectrumColor[index];
|
||||
const color_t c = spectrumColor.at(index);
|
||||
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
||||
}
|
||||
|
||||