Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e73a3159f |
@@ -10,7 +10,7 @@ if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Establecer estándar de C++
|
# Establecer estándar de C++
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
# Configuración global de flags de compilación
|
# Configuración global de flags de compilación
|
||||||
|
|||||||
23
Makefile
23
Makefile
@@ -11,15 +11,18 @@ macosIntelRelease = $(executable)-$(version)-macos-intel.dmg
|
|||||||
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
||||||
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
||||||
|
|
||||||
|
# Specify the C++ standard
|
||||||
|
cpp_standard = c++20
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
windres release/coffee.rc -O coff -o $(resource_file)
|
windres release/coffee.rc -O coff -o $(resource_file)
|
||||||
g++ $(source) $(resource_file) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable).exe"
|
g++ $(source) $(resource_file) -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -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
|
strip -s -R .comment -R .gnu.version "$(executable).exe" --strip-unneeded
|
||||||
|
|
||||||
windows_debug:
|
windows_debug:
|
||||||
@echo off
|
@echo off
|
||||||
g++ $(source) -D DEBUG -D PAUSE -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
|
g++ $(source) -D DEBUG -D PAUSE -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
|
||||||
|
|
||||||
windows_release:
|
windows_release:
|
||||||
@@ -38,7 +41,7 @@ windows_release:
|
|||||||
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
|
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) $(resource_file) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
|
g++ $(source) $(resource_file) -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
||||||
|
|
||||||
# Create ZIP
|
# Create ZIP
|
||||||
@@ -49,10 +52,10 @@ windows_release:
|
|||||||
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
clang++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
clang++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
||||||
|
|
||||||
macos_debug:
|
macos_debug:
|
||||||
clang++ $(source) -D DEBUG -D PAUSE -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
clang++ $(source) -D DEBUG -D PAUSE -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
# Remove data and possible data from previous builds
|
# Remove data and possible data from previous builds
|
||||||
@@ -83,7 +86,7 @@ macos_release:
|
|||||||
ln -s /Applications "$(releaseFolder)"/Applications
|
ln -s /Applications "$(releaseFolder)"/Applications
|
||||||
|
|
||||||
# Build INTEL
|
# Build INTEL
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -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
|
# Build INTEL DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -91,7 +94,7 @@ macos_release:
|
|||||||
rm -f tmp.dmg
|
rm -f tmp.dmg
|
||||||
|
|
||||||
# Build APPLE SILICON
|
# Build APPLE SILICON
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -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
|
# Build APPLE SILICON DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -103,11 +106,11 @@ macos_release:
|
|||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
||||||
|
|
||||||
linux_debug:
|
linux_debug:
|
||||||
g++ $(source) -D DEBUG -D PAUSE -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
g++ $(source) -D DEBUG -D PAUSE -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
@@ -123,7 +126,7 @@ linux_release:
|
|||||||
cp README.md "$(releaseFolder)"
|
cp README.md "$(releaseFolder)"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
||||||
|
|
||||||
# Pack files
|
# Pack files
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <iostream> // for cout
|
#include <iostream> // for cout
|
||||||
#include <string> // for basic_string, operator+, char_t...
|
#include <string> // for basic_string, operator+, char_t...
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
#include <memory>
|
||||||
#include "asset.h" // for Asset, assetType
|
#include "asset.h" // for Asset, assetType
|
||||||
#include "const.h" // for SECTION_PROG_LOGO, GAMECANVAS_H...
|
#include "const.h" // for SECTION_PROG_LOGO, GAMECANVAS_H...
|
||||||
#include "game.h" // for Game
|
#include "game.h" // for Game
|
||||||
@@ -35,8 +36,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Director::Director(int argc, char *argv[])
|
Director::Director(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
|
std::cout << "Game start" << std::endl;
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section = new section_t();
|
section = new section_t();
|
||||||
section->name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
@@ -99,6 +101,8 @@ Director::~Director()
|
|||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
std::cout << "\nBye!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el objeto input
|
// Inicializa el objeto input
|
||||||
@@ -416,7 +420,7 @@ void Director::initOptions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void Director::checkProgramArguments(int argc, char *argv[])
|
void Director::checkProgramArguments(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
// Establece la ruta del programa
|
// Establece la ruta del programa
|
||||||
executablePath = argv[0];
|
executablePath = argv[0];
|
||||||
@@ -639,34 +643,30 @@ bool Director::saveConfigFile()
|
|||||||
|
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(renderer, screen, asset, input, section);
|
auto logo = std::make_unique<Logo>(renderer, screen, asset, input, section);
|
||||||
logo->run();
|
logo->run();
|
||||||
delete logo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
intro = new Intro(renderer, screen, asset, input, lang, section);
|
auto intro = std::make_unique<Intro>(renderer, screen, asset, input, lang, section);
|
||||||
intro->run();
|
intro->run();
|
||||||
delete intro;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::runTitle()
|
void Director::runTitle()
|
||||||
{
|
{
|
||||||
title = new Title(renderer, screen, input, asset, options, lang, section);
|
auto title = std::make_unique<Title>(renderer, screen, input, asset, options, lang, section);
|
||||||
title->run();
|
title->run();
|
||||||
delete title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
const int numPlayers = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
const int numPlayers = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||||
game = new Game(numPlayers, 0, renderer, screen, asset, lang, input, false, options, section);
|
auto game = std::make_unique<Game>(numPlayers, 0, renderer, screen, asset, lang, input, false, options, section);
|
||||||
game->run();
|
game->run();
|
||||||
delete game;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::run()
|
int Director::run()
|
||||||
{
|
{
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
while (section->name != SECTION_PROG_QUIT)
|
while (section->name != SECTION_PROG_QUIT)
|
||||||
@@ -690,6 +690,8 @@ void Director::run()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ private:
|
|||||||
SDL_Window *window; // La ventana donde dibujamos
|
SDL_Window *window; // La ventana donde dibujamos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Logo *logo; // Objeto para la sección del logo
|
|
||||||
Intro *intro; // Objeto para la sección de la intro
|
|
||||||
Title *title; // Objeto para la sección del titulo y el menu de opciones
|
|
||||||
Game *game; // Objeto para la sección del juego
|
|
||||||
Input *input; // Objeto Input para gestionar las entradas
|
Input *input; // Objeto Input para gestionar las entradas
|
||||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
@@ -63,7 +59,7 @@ private:
|
|||||||
bool saveConfigFile();
|
bool saveConfigFile();
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void checkProgramArguments(int argc, char *argv[]);
|
void checkProgramArguments(int argc, const char *argv[]);
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void createSystemFolder(const std::string &folder);
|
void createSystemFolder(const std::string &folder);
|
||||||
@@ -82,11 +78,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Director(int argc, char *argv[]);
|
Director(int argc, const char *argv[]);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Director();
|
~Director();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
void run();
|
int run();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,24 +39,14 @@ Reescribiendo el código el 27/09/2022
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream> // for char_traits, basic_ostream, operator<<, endl
|
#include <memory>
|
||||||
#include "director.h" // for Director
|
#include "director.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::cout << "Starting the game..." << std::endl
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
// Crea el objeto Director
|
// Crea el objeto Director
|
||||||
Director *director = new Director(argc, argv);
|
auto director = std::make_unique<Director>(argc, const_cast<const char **>(argv));
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
director->run();
|
return director->run();
|
||||||
|
|
||||||
// Destruye el objeto Director
|
|
||||||
delete director;
|
|
||||||
|
|
||||||
std::cout << "\nShutting down the game..." << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user