Compare commits
9 Commits
e61daeb92e
...
2024-12-31
| Author | SHA1 | Date | |
|---|---|---|---|
| 40dfc32e84 | |||
| 4cd1d91560 | |||
| e43badd703 | |||
| 71dcf9cf87 | |||
| 3a8521a1da | |||
| 74d9c9a2b9 | |||
| 9532caace8 | |||
| 0bbd14067a | |||
| cfaa143c44 |
156
Makefile
156
Makefile
@@ -1,59 +1,63 @@
|
|||||||
# Directorios
|
# Directorios
|
||||||
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||||
DIR_SOURCES:= $(addsuffix /, $(DIR_ROOT)source)
|
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
||||||
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
TARGET_NAME := coffee_crisis_arcade_edition
|
TARGET_NAME := coffee_crisis_arcade_edition
|
||||||
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
TARGET_FILE := $(DIR_BIN)$(TARGET_NAME)
|
||||||
APP_NAME := Coffee Crisis Arcade Edition
|
APP_NAME := Coffee Crisis Arcade Edition
|
||||||
RELEASE_FOLDER:= ccae_release
|
RELEASE_FOLDER := ccae_release
|
||||||
RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
||||||
VERSION := v0.01
|
RESOURCE_FILE := release/coffee.res
|
||||||
|
VERSION := 2024-12-31
|
||||||
|
|
||||||
# Nombres para los ficheros de lanzamiento
|
# Nombres para los ficheros de lanzamiento
|
||||||
WINDOWS_RELEASE := $(TARGET_FILE)-$(VERSION)-win32-x64.zip
|
WINDOWS_RELEASE := $(TARGET_NAME)-$(VERSION)-win32-x64.zip
|
||||||
MACOS_INTEL_RELEASE := $(TARGET_FILE)-$(VERSION)-macos-intel.dmg
|
MACOS_INTEL_RELEASE := $(TARGET_FILE)-$(VERSION)-macos-intel.dmg
|
||||||
MACOS_APPLE_SILICON_RELEASE:= $(TARGET_FILE)-$(VERSION)-macos-apple-silicon.dmg
|
MACOS_APPLE_SILICON_RELEASE := $(TARGET_FILE)-$(VERSION)-macos-apple-silicon.dmg
|
||||||
LINUX_RELEASE := $(TARGET_FILE)-$(VERSION)-linux.tar.gz
|
LINUX_RELEASE := $(TARGET_FILE)-$(VERSION)-linux.tar.gz
|
||||||
|
RASPI_RELEASE := $(TARGET_FILE)-$(VERSION)-raspberry.tar.gz
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
INCLUDES:= -I$(DIR_SOURCES)
|
INCLUDES := -I$(DIR_SOURCES)
|
||||||
|
|
||||||
# Variables según el sistema operativo
|
# Variables según el sistema operativo
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
FixPath = $(subst /,\,$1)
|
FixPath = $(subst /,\\,$1)
|
||||||
SOURCES := source/*.cpp
|
SOURCES := source/*.cpp
|
||||||
CXXFLAGS:= -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
|
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
|
||||||
CXXFLAGS_DEBUG:= -std=c++20 -Wall -g
|
CXXFLAGS_DEBUG := -std=c++20 -Wall -g
|
||||||
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
|
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
|
||||||
RM = del /Q
|
RM := del /Q
|
||||||
MKD:= mkdir
|
MKDIR := mkdir
|
||||||
else
|
else
|
||||||
FixPath = $1
|
FixPath = $1
|
||||||
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
|
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
|
||||||
SOURCES := source/*.cpp
|
SOURCES := source/*.cpp
|
||||||
CXXFLAGS:= -std=c++20 -Wall -Os -ffunction-sections -fdata-sections
|
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections
|
||||||
CXXFLAGS_DEBUG:= -std=c++20 -Wall -g
|
CXXFLAGS_DEBUG := -std=c++20 -Wall -g
|
||||||
LDFLAGS := -lSDL2
|
LDFLAGS := -lSDL2
|
||||||
RM = rm -f
|
RMFILE := rm -f
|
||||||
MKD:= mkdir -p
|
RMDIR := rm -rdf
|
||||||
UNAME_S := $(shell uname -s)
|
MKDIR := mkdir -p
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S),Linux)
|
ifeq ($(UNAME_S),Linux)
|
||||||
LDFLAGS += -lGL
|
LDFLAGS += -lGL
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
CXXFLAGS += -Wno-deprecated
|
CXXFLAGS += -Wno-deprecated
|
||||||
CXXFLAGS_DEBUG += -Wno-deprecated
|
CXXFLAGS_DEBUG += -Wno-deprecated
|
||||||
LDFLAGS += -framework OpenGL
|
LDFLAGS += -framework OpenGL
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Rules
|
# Reglas para compilación
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE).exe"
|
windres release/coffee.rc -O coff -o $(RESOURCE_FILE)
|
||||||
|
$(CXX) $(SOURCES) $(RESOURCE_FILE) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(TARGET_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
windows_rec:
|
windows_rec:
|
||||||
@@ -80,12 +84,13 @@ windows_release:
|
|||||||
powershell Copy-Item "release\*.dll" -Destination "$(RELEASE_FOLDER)"
|
powershell Copy-Item "release\*.dll" -Destination "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE).exe"
|
windres release/coffee.rc -O coff -o $(RESOURCE_FILE)
|
||||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(TARGET_FILE).exe" --strip-unneeded
|
$(CXX) $(SOURCES) $(RESOURCE_FILE) $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE).exe"
|
||||||
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
# Crea el fichero .zip
|
# Crea el fichero .zip
|
||||||
powershell if (Test-Path $(WINDOWS_RELEASE)) {Remove-Item $(WINDOWS_RELEASE)}
|
powershell if (Test-Path "$(WINDOWS_RELEASE)") {Remove-Item "$(WINDOWS_RELEASE)"}
|
||||||
powershell Compress-Archive -Path "$(RELEASE_FOLDER)"/* -DestinationPath $(WINDOWS_RELEASE)
|
powershell Compress-Archive -Path "$(RELEASE_FOLDER)"/* -DestinationPath "$(WINDOWS_RELEASE)"
|
||||||
|
|
||||||
# Elimina la carpeta temporal 'RELEASE_FOLDER'
|
# Elimina la carpeta temporal 'RELEASE_FOLDER'
|
||||||
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
|
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
|
||||||
@@ -98,17 +103,17 @@ macos_debug:
|
|||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
# Elimina datos de compilaciones anteriores
|
# Elimina datos de compilaciones anteriores
|
||||||
rm -rdf "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
rm -rdf Frameworks
|
$(RMDIR) Frameworks
|
||||||
rm -f tmp.dmg
|
$(RMFILE) tmp.dmg
|
||||||
rm -f "$(MACOS_INTEL_RELEASE)"
|
$(RMFILE) "$(MACOS_INTEL_RELEASE)"
|
||||||
rm -f "$(MACOS_APPLE_SILICON_RELEASE)"
|
$(RMFILE) "$(MACOS_APPLE_SILICON_RELEASE)"
|
||||||
|
|
||||||
# Crea la carpeta temporal para hacer el trabajo y las carpetas obligatorias para crear una app de macos
|
# Crea la carpeta temporal para hacer el trabajo y las carpetas obligatorias para crear una app de macos
|
||||||
mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Frameworks"
|
||||||
mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS"
|
||||||
mkdir -p "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
$(MKDIR) "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
mkdir -p Frameworks
|
$(MKDIR) Frameworks
|
||||||
|
|
||||||
# Copia carpetas y ficheros
|
# Copia carpetas y ficheros
|
||||||
cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
cp -R data "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Resources"
|
||||||
@@ -123,24 +128,24 @@ macos_release:
|
|||||||
ln -s /Applications "$(RELEASE_FOLDER)"/Applications
|
ln -s /Applications "$(RELEASE_FOLDER)"/Applications
|
||||||
|
|
||||||
# Compila la versión para procesadores Intel
|
# Compila la versión para procesadores Intel
|
||||||
$(CXX) $(SOURCES) -D MACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_FILE)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
$(CXX) $(SOURCES) -D MACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
||||||
|
|
||||||
# Empaqueta el .dmg de la versión Intel
|
# Empaqueta el .dmg de la versión Intel
|
||||||
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
||||||
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_INTEL_RELEASE)"
|
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_INTEL_RELEASE)"
|
||||||
rm -f tmp.dmg
|
$(RMFILE) tmp.dmg
|
||||||
|
|
||||||
# Compila la versión para procesadores Apple Silicon
|
# Compila la versión para procesadores Apple Silicon
|
||||||
$(CXX) $(SOURCES) -D MACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_FILE)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
$(CXX) $(SOURCES) -D MACOS_BUNDLE -D SDL_DISABLE_IMMINTRIN_H $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||||
|
|
||||||
# Empaqueta el .dmg de la versión Apple Silicon
|
# Empaqueta el .dmg de la versión Apple Silicon
|
||||||
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
||||||
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_APPLE_SILICON_RELEASE)"
|
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_APPLE_SILICON_RELEASE)"
|
||||||
rm -f tmp.dmg
|
$(RMFILE) tmp.dmg
|
||||||
|
|
||||||
# Elimina las carpetas temporales
|
# Elimina las carpetas temporales
|
||||||
$(RM) Frameworks
|
$(RMDIR) Frameworks
|
||||||
$(RM) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||||
@@ -151,10 +156,10 @@ linux_debug:
|
|||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RM) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Crea la carpeta temporal para realizar el lanzamiento
|
# Crea la carpeta temporal para realizar el lanzamiento
|
||||||
mkdir -p "$(RELEASE_FOLDER)"
|
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Copia ficheros
|
# Copia ficheros
|
||||||
cp -R data "$(RELEASE_FOLDER)"
|
cp -R data "$(RELEASE_FOLDER)"
|
||||||
@@ -166,11 +171,11 @@ linux_release:
|
|||||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
||||||
|
|
||||||
# Empaqueta ficheros
|
# Empaqueta ficheros
|
||||||
$(RM) "$(LINUX_RELEASE)"
|
$(RMFILE) "$(LINUX_RELEASE)"
|
||||||
cd "$(RELEASE_FOLDER)" && tar -czvf "../$(LINUX_RELEASE)" *
|
cd "$(RELEASE_FOLDER)" && tar -czvf "$(LINUX_RELEASE)" *
|
||||||
|
|
||||||
# Elimina la carpeta temporal
|
# Elimina la carpeta temporal
|
||||||
$(RM) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
raspi:
|
raspi:
|
||||||
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(TARGET_FILE)
|
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(TARGET_FILE)
|
||||||
@@ -179,12 +184,35 @@ raspi:
|
|||||||
raspi_debug:
|
raspi_debug:
|
||||||
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE -D DEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE -D DEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
anbernic:
|
raspi_release:
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RM) "$(RELEASE_FOLDER)"_anbernic
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Crea la carpeta temporal para realizar el lanzamiento
|
# Crea la carpeta temporal para realizar el lanzamiento
|
||||||
mkdir -p "$(RELEASE_FOLDER)"_anbernic
|
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
|
# Copia ficheros
|
||||||
|
cp -R data "$(RELEASE_FOLDER)"
|
||||||
|
cp LICENSE "$(RELEASE_FOLDER)"
|
||||||
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
|
# Complia
|
||||||
|
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)"
|
||||||
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
||||||
|
|
||||||
|
# Empaqueta ficheros
|
||||||
|
$(RMFILE) "$(LINUX_RELEASE)"
|
||||||
|
cd "$(RELEASE_FOLDER)" && tar -czvf "$(RASPI_RELEASE)" *
|
||||||
|
|
||||||
|
# Elimina la carpeta temporal
|
||||||
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
|
anbernic:
|
||||||
|
# Elimina carpetas previas
|
||||||
|
$(RMDIR) "$(RELEASE_FOLDER)"_anbernic
|
||||||
|
|
||||||
|
# Crea la carpeta temporal para realizar el lanzamiento
|
||||||
|
$(MKDIR) "$(RELEASE_FOLDER)"_anbernic
|
||||||
|
|
||||||
# Copia ficheros
|
# Copia ficheros
|
||||||
cp -R data "$(RELEASE_FOLDER)"_anbernic
|
cp -R data "$(RELEASE_FOLDER)"_anbernic
|
||||||
|
|||||||
2
release/coffee.rc
Normal file
2
release/coffee.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// coffee.rc
|
||||||
|
IDI_ICON1 ICON "icon.ico"
|
||||||
BIN
release/coffee.res
Normal file
BIN
release/coffee.res
Normal file
Binary file not shown.
BIN
release/icon.ico
Normal file
BIN
release/icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[])
|
|||||||
section::name = section::Name::GAME;
|
section::name = section::Name::GAME;
|
||||||
section::options = section::Options::GAME_PLAY_1P;
|
section::options = section::Options::GAME_PLAY_1P;
|
||||||
#elif DEBUG
|
#elif DEBUG
|
||||||
section::name = section::Name::GAME;
|
section::name = section::Name::LOGO;
|
||||||
#else // NORMAL GAME
|
#else // NORMAL GAME
|
||||||
section::name = section::Name::LOGO;
|
section::name = section::Name::LOGO;
|
||||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||||
|
|||||||
@@ -68,11 +68,9 @@ Game::Game(int player_id, int current_stage, bool demo)
|
|||||||
|
|
||||||
fade_in_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
fade_in_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||||
fade_in_->setPost(0);
|
fade_in_->setPost(0);
|
||||||
fade_in_->setType(FadeType::VENETIAN);
|
fade_in_->setType(FadeType::RANDOM_SQUARE);
|
||||||
fade_in_->setMode(FadeMode::IN);
|
fade_in_->setMode(FadeMode::IN);
|
||||||
fade_in_->activate();
|
fade_in_->activate();
|
||||||
// JA_PlaySound(Resource::get()->getSound("fade_in.wav"));
|
|
||||||
// playMusic();
|
|
||||||
|
|
||||||
fade_out_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
fade_out_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||||
fade_out_->setPost(param.fade.post_duration);
|
fade_out_->setPost(param.fade.post_duration);
|
||||||
@@ -943,15 +941,12 @@ void Game::fillCanvas()
|
|||||||
background_->render();
|
background_->render();
|
||||||
renderItems();
|
renderItems();
|
||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
tabe_->render();
|
|
||||||
balloon_manager_->render();
|
balloon_manager_->render();
|
||||||
|
tabe_->render();
|
||||||
renderBullets();
|
renderBullets();
|
||||||
renderPathSprites();
|
renderPathSprites();
|
||||||
renderPlayers();
|
renderPlayers();
|
||||||
|
|
||||||
auto sprite = std::make_unique<Sprite>(Resource::get()->getTexture("game_text_game_over"));
|
|
||||||
sprite->render();
|
|
||||||
|
|
||||||
// Deja el renderizador apuntando donde estaba
|
// Deja el renderizador apuntando donde estaba
|
||||||
SDL_SetRenderTarget(renderer_, temp);
|
SDL_SetRenderTarget(renderer_, temp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -416,7 +416,6 @@ void Intro::render()
|
|||||||
void Intro::run()
|
void Intro::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(Resource::get()->getMusic("intro.ogg"), 0);
|
JA_PlayMusic(Resource::get()->getMusic("intro.ogg"), 0);
|
||||||
|
|
||||||
while (section::name == section::Name::INTRO)
|
while (section::name == section::Name::INTRO)
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct JA_Channel_t {
|
|||||||
|
|
||||||
struct JA_Music_t {
|
struct JA_Music_t {
|
||||||
int samples {0};
|
int samples {0};
|
||||||
|
Uint32 length {0};
|
||||||
int pos {0};
|
int pos {0};
|
||||||
int times {0};
|
int times {0};
|
||||||
short* output {NULL};
|
short* output {NULL};
|
||||||
@@ -60,13 +61,13 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
|
|||||||
volume = JA_musicVolume * (1.0 - percent);
|
volume = JA_musicVolume * (1.0 - percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int size = SDL_min(len, (current_music->samples-current_music->pos)*2);
|
const int size = SDL_min(len, current_music->length - current_music->pos);
|
||||||
SDL_MixAudioFormat(stream, (Uint8*)(current_music->output+current_music->pos), AUDIO_S16, size, volume);
|
SDL_MixAudioFormat(stream, (Uint8*)(current_music->output)+current_music->pos, AUDIO_S16, size, volume);
|
||||||
current_music->pos += size/2;
|
current_music->pos += size;
|
||||||
if (size < len) {
|
if (size < len) {
|
||||||
if (current_music->times != 0) {
|
if (current_music->times != 0) {
|
||||||
SDL_MixAudioFormat(stream+size, (Uint8*)current_music->output, AUDIO_S16, len-size, volume);
|
SDL_MixAudioFormat(stream+size, (Uint8*)current_music->output, AUDIO_S16, len-size, volume);
|
||||||
current_music->pos = (len-size)/2;
|
current_music->pos = len-size;
|
||||||
if (current_music->times > 0) current_music->times--;
|
if (current_music->times > 0) current_music->times--;
|
||||||
} else {
|
} else {
|
||||||
current_music->pos = 0;
|
current_music->pos = 0;
|
||||||
@@ -136,12 +137,14 @@ JA_Music_t *JA_LoadMusic(Uint8* buffer, Uint32 length)
|
|||||||
SDL_Log("Music length: %f\n", float(music->samples)/float(JA_freq));
|
SDL_Log("Music length: %f\n", float(music->samples)/float(JA_freq));
|
||||||
if (cvt.needed) {
|
if (cvt.needed) {
|
||||||
cvt.len = music->samples * chan * 2;
|
cvt.len = music->samples * chan * 2;
|
||||||
|
music->length = cvt.len;
|
||||||
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
||||||
SDL_memcpy(cvt.buf, music->output, cvt.len);
|
SDL_memcpy(cvt.buf, music->output, cvt.len);
|
||||||
SDL_ConvertAudio(&cvt);
|
SDL_ConvertAudio(&cvt);
|
||||||
free(music->output);
|
free(music->output);
|
||||||
music->output = (short*)cvt.buf;
|
music->output = (short*)cvt.buf;
|
||||||
}
|
}
|
||||||
|
music->length = music->samples * chan * 2;
|
||||||
music->pos = 0;
|
music->pos = 0;
|
||||||
music->state = JA_MUSIC_STOPPED;
|
music->state = JA_MUSIC_STOPPED;
|
||||||
|
|
||||||
@@ -316,6 +319,19 @@ int JA_PlaySound(JA_Sound_t *sound, const int loop)
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop)
|
||||||
|
{
|
||||||
|
if (!JA_soundEnabled) return -1;
|
||||||
|
|
||||||
|
if (channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return -1;
|
||||||
|
|
||||||
|
channels[channel].sound = sound;
|
||||||
|
channels[channel].times = loop;
|
||||||
|
channels[channel].pos = 0;
|
||||||
|
channels[channel].state = JA_CHANNEL_PLAYING;
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
void JA_DeleteSound(JA_Sound_t *sound)
|
void JA_DeleteSound(JA_Sound_t *sound)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
|
|||||||
JA_Sound_t *JA_LoadSound(Uint8* buffer, Uint32 length);
|
JA_Sound_t *JA_LoadSound(Uint8* buffer, Uint32 length);
|
||||||
JA_Sound_t *JA_LoadSound(const char* filename);
|
JA_Sound_t *JA_LoadSound(const char* filename);
|
||||||
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
|
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
|
||||||
|
int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop = 0);
|
||||||
void JA_PauseChannel(const int channel);
|
void JA_PauseChannel(const int channel);
|
||||||
void JA_ResumeChannel(const int channel);
|
void JA_ResumeChannel(const int channel);
|
||||||
void JA_StopChannel(const int channel);
|
void JA_StopChannel(const int channel);
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ void Logo::render()
|
|||||||
void Logo::run()
|
void Logo::run()
|
||||||
{
|
{
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
JA_FadeOutMusic(500);
|
JA_FadeOutMusic(300);
|
||||||
|
|
||||||
while (section::name == section::Name::LOGO)
|
while (section::name == section::Name::LOGO)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,12 +161,14 @@ std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom,
|
|||||||
auto texture = std::make_shared<Texture>(renderer);
|
auto texture = std::make_shared<Texture>(renderer);
|
||||||
auto width = lenght(text, kerning) * zoom;
|
auto width = lenght(text, kerning) * zoom;
|
||||||
auto height = box_height_ * zoom;
|
auto height = box_height_ * zoom;
|
||||||
|
auto temp = SDL_GetRenderTarget(renderer);
|
||||||
texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
zoom == 1 ? write(0, 0, text, kerning) : write2X(0, 0, text, kerning);
|
zoom == 1 ? write(0, 0, text, kerning) : write2X(0, 0, text, kerning);
|
||||||
|
SDL_SetRenderTarget(renderer, temp);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|||||||
103
source/title.cpp
103
source/title.cpp
@@ -33,7 +33,8 @@ Title::Title()
|
|||||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||||
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
||||||
define_buttons_(std::make_unique<DefineButtons>()),
|
define_buttons_(std::make_unique<DefineButtons>()),
|
||||||
num_controllers_(Input::get()->getNumControllers())
|
num_controllers_(Input::get()->getNumControllers()),
|
||||||
|
state_(TitleState::LOGO_ANIMATING)
|
||||||
{
|
{
|
||||||
// Configura objetos
|
// Configura objetos
|
||||||
game_logo_->enable();
|
game_logo_->enable();
|
||||||
@@ -73,9 +74,8 @@ void Title::update()
|
|||||||
// Actualiza las variables de globalInputs
|
// Actualiza las variables de globalInputs
|
||||||
globalInputs::update();
|
globalInputs::update();
|
||||||
|
|
||||||
// Comprueba el fundido y si se ha acabado
|
// Comprueba el fundido
|
||||||
fade_->update();
|
fade_->update();
|
||||||
// JA_SetMusicVolume(100 - fade_->getValue());
|
|
||||||
if (fade_->hasEnded())
|
if (fade_->hasEnded())
|
||||||
{
|
{
|
||||||
if (post_fade_ == -1)
|
if (post_fade_ == -1)
|
||||||
@@ -90,18 +90,19 @@ void Title::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sección 1 - Titulo animandose
|
// Establece la lógica según el estado
|
||||||
if (section::options == section::Options::TITLE_1)
|
switch (state_)
|
||||||
|
{
|
||||||
|
case TitleState::LOGO_ANIMATING:
|
||||||
{
|
{
|
||||||
game_logo_->update();
|
game_logo_->update();
|
||||||
if (game_logo_->hasFinished())
|
if (game_logo_->hasFinished())
|
||||||
{
|
{
|
||||||
section::options = section::Options::TITLE_2;
|
state_ = TitleState::LOGO_FINISHED;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case TitleState::LOGO_FINISHED:
|
||||||
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
|
|
||||||
else if (section::options == section::Options::TITLE_2)
|
|
||||||
{
|
{
|
||||||
// El contador solo sube si no estamos definiendo botones
|
// El contador solo sube si no estamos definiendo botones
|
||||||
counter_ = define_buttons_->isEnabled() ? 0 : counter_ + 1;
|
counter_ = define_buttons_->isEnabled() ? 0 : counter_ + 1;
|
||||||
@@ -109,10 +110,7 @@ void Title::update()
|
|||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||||
{
|
{
|
||||||
if (!fade_->isEnabled())
|
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||||
{
|
|
||||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el logo con el título del juego
|
// Actualiza el logo con el título del juego
|
||||||
@@ -126,6 +124,27 @@ void Title::update()
|
|||||||
fade_->activate();
|
fade_->activate();
|
||||||
post_fade_ = -1;
|
post_fade_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TitleState::START_HAS_BEEN_PRESSED:
|
||||||
|
{
|
||||||
|
// Actualiza el logo con el título del juego
|
||||||
|
game_logo_->update();
|
||||||
|
|
||||||
|
// Actualiza el mosaico de fondo
|
||||||
|
tiled_bg_->update();
|
||||||
|
|
||||||
|
if (counter_ == 100)
|
||||||
|
{
|
||||||
|
fade_->activate();
|
||||||
|
}
|
||||||
|
++counter_;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,16 +164,10 @@ void Title::render()
|
|||||||
// Dibuja el logo con el título del juego
|
// Dibuja el logo con el título del juego
|
||||||
game_logo_->render();
|
game_logo_->render();
|
||||||
|
|
||||||
if (section::options == section::Options::TITLE_2)
|
constexpr Color shadow = Color(0x14, 0x87, 0xc4);
|
||||||
|
|
||||||
|
if (state_ != TitleState::LOGO_ANIMATING)
|
||||||
{
|
{
|
||||||
constexpr Color shadow = Color(0x14, 0x87, 0xc4);
|
|
||||||
|
|
||||||
// 'PRESS TO PLAY'
|
|
||||||
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
|
||||||
{
|
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mini logo
|
// Mini logo
|
||||||
const int pos1 = (param.game.height / 5 * 4) + BLOCK;
|
const int pos1 = (param.game.height / 5 * 4) + BLOCK;
|
||||||
const int pos2 = pos1 + mini_logo_sprite_->getHeight() + 3;
|
const int pos2 = pos1 + mini_logo_sprite_->getHeight() + 3;
|
||||||
@@ -165,6 +178,24 @@ void Title::render()
|
|||||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, pos2, TEXT_COPYRIGHT, 1, no_color, 1, shadow);
|
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, pos2, TEXT_COPYRIGHT, 1, no_color, 1, shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state_ == TitleState::LOGO_FINISHED)
|
||||||
|
{
|
||||||
|
// 'PRESS TO PLAY'
|
||||||
|
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
||||||
|
{
|
||||||
|
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state_ == TitleState::START_HAS_BEEN_PRESSED)
|
||||||
|
{
|
||||||
|
// 'PRESS TO PLAY'
|
||||||
|
if (counter_ % 10 > 4 && !define_buttons_->isEnabled())
|
||||||
|
{
|
||||||
|
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Define Buttons
|
// Define Buttons
|
||||||
define_buttons_->render();
|
define_buttons_->render();
|
||||||
|
|
||||||
@@ -246,29 +277,28 @@ void Title::checkEvents()
|
|||||||
// Comprueba las entradas
|
// Comprueba las entradas
|
||||||
void Title::checkInput()
|
void Title::checkInput()
|
||||||
{
|
{
|
||||||
// Comprueba los controladores solo si no se estan definiendo los botones
|
// Comprueba las entradas solo si no se estan definiendo los botones
|
||||||
if (!define_buttons_->isEnabled())
|
if (!define_buttons_->isEnabled())
|
||||||
{
|
{
|
||||||
// Comprueba los métodos de control
|
// Comprueba todos los métodos de control
|
||||||
for (const auto &controller : options.controllers)
|
for (const auto &controller : options.controllers)
|
||||||
{
|
{
|
||||||
|
// START
|
||||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||||
!Input::get()->checkInput(InputType::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
!Input::get()->checkInput(InputType::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||||
{
|
{
|
||||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
if (state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP)
|
||||||
{
|
{
|
||||||
if (!fade_->isEnabled())
|
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
||||||
{
|
JA_FadeOutMusic(1500);
|
||||||
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
post_fade_ = controller.player_id;
|
||||||
JA_FadeOutMusic(1500);
|
state_ = TitleState::START_HAS_BEEN_PRESSED;
|
||||||
fade_->activate();
|
counter_ = 0;
|
||||||
post_fade_ = controller.player_id;
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
|
// SWAP_CONTROLLERS
|
||||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||||
Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||||
{
|
{
|
||||||
@@ -276,7 +306,7 @@ void Title::checkInput()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si algun mando quiere ser configurado
|
// CONFIG
|
||||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||||
Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||||
{
|
{
|
||||||
@@ -355,7 +385,6 @@ void Title::showControllers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::string spaces(lang::getText(100).length() + 3, ' ');
|
// Muestra la notificación
|
||||||
// std::string kb_text = spaces + lang::getText(69);
|
|
||||||
Notifier::get()->showText({text.at(0), text.at(1)});
|
Notifier::get()->showText({text.at(0), text.at(1)});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
|
|||||||
- Dibujar el tileado de fondo
|
- Dibujar el tileado de fondo
|
||||||
- Redifinir los botones de los mandos de juego
|
- Redifinir los botones de los mandos de juego
|
||||||
|
|
||||||
Esta clase tiene dos estados:
|
Esta clase tiene tres estados:
|
||||||
- El titulo está animandose, con el fondo estático
|
- El titulo está animandose, con el fondo estático
|
||||||
- El titulo ya está en su sitio y el fondo se está animando
|
- El titulo ya está en su sitio y el fondo se está animando
|
||||||
|
- Se ha pulsado el botón de start
|
||||||
|
|
||||||
Por razones de diseño, no se permite saltarse la animación del titulo, aunque es
|
Por razones de diseño, no se permite saltarse la animación del titulo, aunque es
|
||||||
configurable mediante un define
|
configurable mediante un define
|
||||||
@@ -39,6 +40,14 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
|
|||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// Enumeraciones
|
||||||
|
enum class TitleState
|
||||||
|
{
|
||||||
|
LOGO_ANIMATING,
|
||||||
|
LOGO_FINISHED,
|
||||||
|
START_HAS_BEEN_PRESSED,
|
||||||
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::shared_ptr<Text> text_; // Objeto de texto para poder escribir textos en pantalla
|
std::shared_ptr<Text> text_; // Objeto de texto para poder escribir textos en pantalla
|
||||||
std::unique_ptr<Fade> fade_; // Objeto para realizar fundidos en pantalla
|
std::unique_ptr<Fade> fade_; // Objeto para realizar fundidos en pantalla
|
||||||
@@ -53,6 +62,7 @@ private:
|
|||||||
section::Name next_section_; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
section::Name next_section_; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
||||||
int post_fade_ = 0; // Opción a realizar cuando termina el fundido
|
int post_fade_ = 0; // Opción a realizar cuando termina el fundido
|
||||||
int num_controllers_; // Número de mandos conectados
|
int num_controllers_; // Número de mandos conectados
|
||||||
|
TitleState state_; // Estado en el que se encuentra la sección
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
Reference in New Issue
Block a user