diff --git a/Makefile b/Makefile index ae06009..b668a54 100644 --- a/Makefile +++ b/Makefile @@ -20,11 +20,9 @@ C_FLAGS = \ INCLUDE_FLAGS = -Iinclude -EXTERNAL_ENGINE = -Iexternal/engine EXTERNAL_RAYGUI = -Iexternal/raygui EXTERNAL_RINI = -Iexternal/rini EXTERNAL_FLAGS = \ - $(EXTERNAL_ENGINE) \ $(EXTERNAL_RINI) \ $(EXTERNAL_RAYGUI) diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..7c4ab3f --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,684 @@ +[ + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/app.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/app.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameBirds.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameBirds.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGame.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGame.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameEnemies.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameEnemies.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameFloor.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameFloor.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameIslands.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameIslands.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGamePlayer.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGamePlayer.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameShip.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameShip.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appGameShoot.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appGameShoot.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appLogo.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appLogo.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appMenu.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appMenu.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appMenuMainBackground.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appMenuMainBackground.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appMenuMain.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appMenuMain.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appMenuSettings.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appMenuSettings.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/appState.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/appState.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineAnimation.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineAnimation.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineArray.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineArray.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineCamera.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineCamera.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineConfig.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineConfig.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineFont.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineFont.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineGamegui.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineGamegui.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineGui.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineGui.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineInput.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineInput.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineObject.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineObject.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/enginePhysics.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/enginePhysics.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/enginePostfx.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/enginePostfx.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineRectangle.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineRectangle.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineSoundtrack.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineSoundtrack.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineSprite.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineSprite.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/engineVector.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/engineVector.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + }, + { + "arguments": [ + "/usr/bin/gcc", + "-c", + "-std=c99", + "-g", + "-Wall", + "-Wpedantic", + "-Wshadow", + "-Wstrict-prototypes", + "-Wno-unknown-pragmas", + "-Iinclude", + "-Iexternal/rini", + "-Iexternal/raygui", + "-o", + "bin/osx/game", + "src/main.c" + ], + "directory": "/home/huaqo/dev/the-last-hive", + "file": "/home/huaqo/dev/the-last-hive/src/main.c", + "output": "/home/huaqo/dev/the-last-hive/bin/osx/game" + } +] diff --git a/config/ships.ini b/config/ships.ini new file mode 100644 index 0000000..caf9f9b --- /dev/null +++ b/config/ships.ini @@ -0,0 +1,8 @@ +# ship_start +start_id = 0 +start_path = assets/ship_start.png +start_frameSize = 16 +start_spped_0 = 0 +start_speed_1 = 5 +start_speed_2 = 10 +start_rotationSpeed = 50 diff --git a/include/app.h b/include/app.h index 1d2836f..f7fa9a3 100644 --- a/include/app.h +++ b/include/app.h @@ -1,271 +1,215 @@ #ifndef APPTYPES_H #define APPTYPES_H -//INCLUDES// -#include +// INCLUDES// #include +#include -//DEFINES// -#define TEXT_COLOR_DARK (Color){ 182, 137, 98, 255} -#define TEXT_COLOR_LIGHT (Color){ 243, 229, 194, 255} +// DEFINES// +#define TEXT_COLOR_DARK (Color){182, 137, 98, 255} +#define TEXT_COLOR_LIGHT (Color){243, 229, 194, 255} -//ENUMS// -typedef enum -{ - MENU_CURSOR_TEX, - MENU_BIG_BUTTONS_TEX, - MENU_BOARD_TEX, - MENU_CLOUD_BACKGROUND, - MENU_CLOUD_MIDGROUND, - MENU_CLOUD_FOREGROUND, - MENU_TEX_COUNT +// ENUMS// +typedef enum { + MENU_CURSOR_TEX, + MENU_BIG_BUTTONS_TEX, + MENU_BOARD_TEX, + MENU_CLOUD_BACKGROUND, + MENU_CLOUD_MIDGROUND, + MENU_CLOUD_FOREGROUND, + MENU_TEX_COUNT } MenuTextureID; -typedef enum -{ - MENU_MUSIC, - MENU_SOUNDTRACK_COUNT -} MenuSoundtrackID; +typedef enum { MENU_MUSIC, MENU_SOUNDTRACK_COUNT } MenuSoundtrackID; -typedef enum -{ - HOVER_SOUND, - CLICK_SOUND, - MENU_SOUND_COUNT -} MenuSoundID; +typedef enum { HOVER_SOUND, CLICK_SOUND, MENU_SOUND_COUNT } MenuSoundID; -typedef enum MenuView { - MAIN = 0, - SETTINGS = 1 -} MenuView; +typedef enum MenuView { MAIN = 0, SETTINGS = 1 } MenuView; -typedef enum -{ - START_SHIP, - PLAYER_TEX_COUNT -} playerTextureID; +typedef enum { START_SHIP, PLAYER_TEX_COUNT } playerTextureID; -typedef enum { - ANCHOR, - SLOW_AHEAD, - FAST_AHEAD, - SPEED_COUNT -} playerSpeedID; +typedef enum { ANCHOR, SLOW_AHEAD, FAST_AHEAD, SPEED_COUNT } playerSpeedID; +typedef enum { ISLAND, ISLANDS_TEX_COUNT } islandsTextureID; -typedef enum -{ - ISLAND, - ISLANDS_TEX_COUNT -} islandsTextureID; +typedef enum { POST_FX, SHADER_COUNT } ShaderID; -typedef enum -{ - POST_FX, - SHADER_COUNT -} ShaderID; +typedef enum { BEE_AMBIENT, SOUNDTRACK_COUNT } SoundtrackID; -typedef enum -{ - BEE_AMBIENT, - SOUNDTRACK_COUNT -} SoundtrackID; +typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View; -typedef enum View { - LOGO = 0, - MENU = 1, - GAMEPLAY = 2 -} View; - -//STRUCTS// +// STRUCTS// typedef struct { - int frameCounter; - int positionX; - int positionY; - int lettersCount; - int topSideRecWidth; - int leftSideRecHeight; - int bottomSideRecWidth; - int rightSideRecHeight; - int state; - float alpha; + int frameCounter; + int positionX; + int positionY; + int lettersCount; + int topSideRecWidth; + int leftSideRecHeight; + int bottomSideRecWidth; + int rightSideRecHeight; + int state; + float alpha; } LogoState; typedef struct { - Sprite sprite; - float scrolling; - float scale; - float scrollSpeed; - Vector2 pos; + Sprite sprite; + float scrolling; + float scale; + float scrollSpeed; + Vector2 pos; } Background; typedef struct { - Assets assets; - Mouse mouse; - Texture2D textures[MENU_TEX_COUNT]; - Sound sounds[MENU_SOUND_COUNT]; - Soundtrack soundtracks[MENU_SOUNDTRACK_COUNT]; - ImageElement board; - ImageButton playButton; - ImageButton quitButton; - ImageButton settingsButton; - int menuScale; - Background background; - Background midground; - Background foreground; + Assets assets; + Mouse mouse; + Texture2D textures[MENU_TEX_COUNT]; + Sound sounds[MENU_SOUND_COUNT]; + Soundtrack soundtracks[MENU_SOUNDTRACK_COUNT]; + ImageElement board; + ImageButton playButton; + ImageButton quitButton; + ImageButton settingsButton; + int menuScale; + Background background; + Background midground; + Background foreground; } MenuMain; -typedef struct -{ - Button showFPS; - Button limitFPS; - Button soundtrackOn; +typedef struct { + Button showFPS; + Button limitFPS; + Button soundtrackOn; } MenuSettings; - -typedef struct -{ - MenuView menuView; - MenuMain menuMain; - MenuSettings menuSettings; +typedef struct { + MenuView menuView; + MenuMain menuMain; + MenuSettings menuSettings; } MenuState; - -typedef struct -{ - Sprite sprite; - Rectangle bounds; - Shader shader; - float time; +typedef struct { + Sprite sprite; + Rectangle bounds; + Shader shader; + float time; } Floor; -typedef struct -{ - Sprite sprite; - Animation animation; - Physics physics; - float rotation; +typedef struct { + Sprite sprite; + Animation animation; + Physics physics; + float rotation; } Player; -typedef enum -{ - BOAT, - ENEMIES_TEX_COUNT -} enemiesTextureID; +typedef enum { BOAT, ENEMIES_TEX_COUNT } enemiesTextureID; -typedef enum -{ - START, - SHIP_COUNT -} shipID; +typedef enum { START, SHIP_COUNT } shipID; -typedef struct -{ - int id; - char* assetPath; - int frameSize; - int speed0; - int speed1; - int speed2; - int rotationSpeed; -}Ship; +typedef struct { + int id; + char *assetPath; + int frameSize; + int speed0; + int speed1; + int speed2; + int rotationSpeed; +} Ship; #define MAX_ENEMIES 100 -typedef struct -{ - Config config; - int count; - Sprite sprite[MAX_ENEMIES]; - Animation animation[MAX_ENEMIES]; - Physics physics[MAX_ENEMIES]; - bool arrived[MAX_ENEMIES]; - Vector2 destPos[MAX_ENEMIES]; +typedef struct { + Config config; + int count; + Sprite sprite[MAX_ENEMIES]; + Animation animation[MAX_ENEMIES]; + Physics physics[MAX_ENEMIES]; + bool arrived[MAX_ENEMIES]; + Vector2 destPos[MAX_ENEMIES]; } Enemies; -typedef enum -{ - FLYING, - BIRDS_TEX_COUNT -} birdsTextureID; +typedef enum { FLYING, BIRDS_TEX_COUNT } birdsTextureID; #define MAX_BIRDS 100 typedef struct { - int count; - Sprite sprite[MAX_BIRDS]; - Animation animation[MAX_BIRDS]; - Physics physics[MAX_BIRDS]; - bool arrived[MAX_BIRDS]; - Vector2 destPos[MAX_BIRDS]; + int count; + Sprite sprite[MAX_BIRDS]; + Animation animation[MAX_BIRDS]; + Physics physics[MAX_BIRDS]; + bool arrived[MAX_BIRDS]; + Vector2 destPos[MAX_BIRDS]; } Birds; typedef struct { - Sprite sprite; - Animation animation; - Physics physics; + Sprite sprite; + Animation animation; + Physics physics; } Islands; -typedef struct -{ - Assets assets; - PostProcessing postFX[SHADER_COUNT]; - Soundtrack soundtracks[SOUNDTRACK_COUNT]; - RenderTexture2D target; - Floor floor; - Birds birds; - Enemies enemies; - Islands islands; - Mouse mouse; - Image image; -} GameState; - -typedef struct { - View currentView; - bool running; - bool gameStarted; -} State; - -typedef struct { - bool showFPS; - bool limitFPS; - bool soundtrackOn; -} Flags; - -typedef struct { - Config config; - State state; - Flags flags; - Window window; - Font font; - LogoState logo; - MenuState menu; - GameState game; -} App; - #define MAX_PROJECTILES 10 typedef struct { - Physics physics[MAX_PROJECTILES]; - bool active[MAX_PROJECTILES]; - float radius[MAX_PROJECTILES]; -} Projectile; + Physics physics[MAX_PROJECTILES]; + bool active[MAX_PROJECTILES]; + float radius[MAX_PROJECTILES]; +} Projectiles; -//FUNCTIONS// +typedef struct { + Assets assets; + PostProcessing postFX[SHADER_COUNT]; + Soundtrack soundtracks[SOUNDTRACK_COUNT]; + RenderTexture2D target; + Floor floor; + Birds birds; + Enemies enemies; + Islands islands; + Mouse mouse; + Image image; + Projectiles projectiles; +} GameState; + +typedef struct { + View currentView; + bool running; + bool gameStarted; +} State; + +typedef struct { + bool showFPS; + bool limitFPS; + bool soundtrackOn; +} Flags; + +typedef struct { + Config config; + State state; + Flags flags; + Window window; + Font font; + LogoState logo; + MenuState menu; + GameState game; +} App; + +// FUNCTIONS// void InitLogo(LogoState *l); void UpdateLogo(LogoState *l, View *currentView, bool *running); void RenderLogo(const LogoState *l, Flags *flags); -void InitBackground(float scrollSpeed, Background *bg, Texture2D *texture, const TextureAsset *backgroundAsset); +void InitBackground(float scrollSpeed, Background *bg, Texture2D *texture, + const TextureAsset *backgroundAsset); void UpdateBackground(Background *bg); void RenderBackground(Background *bg); void InitMenuMain(MenuMain *m); -void UpdateMenuMain(MenuMain *m, State *state, Flags *flags, MenuView *menuView); +void UpdateMenuMain(MenuMain *m, State *state, Flags *flags, + MenuView *menuView); void RenderMenuMain(MenuMain *m, Font *font, const char *title, Flags *flags); void CleanupMenuMain(MenuMain *m); void InitMenuSettings(MenuSettings *s); -void UpdateMenuSettings(MenuSettings *s, MenuView *menuView, State *state, Flags *flags); +void UpdateMenuSettings(MenuSettings *s, MenuView *menuView, State *state, + Flags *flags); void RenderMenuSettings(MenuSettings *s, Flags *flags); void CleanupMenuSettings(MenuSettings *s); @@ -280,7 +224,7 @@ void RenderFloor(Floor *floor); void UnloadFloor(Floor *floor); playerSpeedID GetPlayerSpeedID(float speed); -Player* GetPlayer(void); +Player *GetPlayer(void); void CreatePlayer(void); void UpdatePlayer(void); void RenderPlayer(void); @@ -297,6 +241,10 @@ Islands CreateIslands(void); void UpdateIslands(Islands *islands); void RenderIslands(Islands *islands); +Projectiles CreateProjectiles(void); +void UpdateProjectiles(Projectiles *projectiles); +void RenderProjectiles(Projectiles *projectiles); + void InitGame(App *app); void UpdateGame(App *app); void RenderComponents(App *app); @@ -311,4 +259,4 @@ void InitApp(App *app); void UpdateApp(App *app); void CleanupApp(App *app); -#endif //APPTYPES_H +#endif // APPTYPES_H diff --git a/src/app.c b/src/app.c index bb752b2..df5d782 100644 --- a/src/app.c +++ b/src/app.c @@ -1,56 +1,51 @@ #include "app.h" -void ConfigApp(App* app){ - InitConfig(&app->config, "config/config.ini"); - app->state.currentView = GetConfigInt(&app->config, "startView"); - app->flags.showFPS = GetConfigInt(&app->config, "showFPS"); - app->flags.limitFPS = GetConfigInt(&app->config, "limitFPS"); - app->flags.soundtrackOn = GetConfigInt(&app->config, "soundtrackOn"); - app->window.title = GetConfigString(&app->config, "windowTitle"); - app->window.width = GetConfigInt(&app->config, "windowWidth"); - app->window.height = GetConfigInt(&app->config, "windowHeight"); +void ConfigApp(App *app) { + InitConfig(&app->config, "config/config.ini"); + app->state.currentView = GetConfigInt(&app->config, "startView"); + app->flags.showFPS = GetConfigInt(&app->config, "showFPS"); + app->flags.limitFPS = GetConfigInt(&app->config, "limitFPS"); + app->flags.soundtrackOn = GetConfigInt(&app->config, "soundtrackOn"); + app->window.title = GetConfigString(&app->config, "windowTitle"); + app->window.width = GetConfigInt(&app->config, "windowWidth"); + app->window.height = GetConfigInt(&app->config, "windowHeight"); } -void InitApp(App *app){ - InitFont(&app->font, GetConfigString(&app->config, "fontPath")); - InitLogo(&app->logo); - InitMenu(&app->menu); - InitGame(app); +void InitApp(App *app) { + InitFont(&app->font, GetConfigString(&app->config, "fontPath")); + InitLogo(&app->logo); + InitMenu(&app->menu); + InitGame(app); } -void UpdateApp(App *app){ +void UpdateApp(App *app) { - app->state.running = true; - app->state.gameStarted = false; + app->state.running = true; + app->state.gameStarted = false; - while (app->state.running) - { - switch (app->state.currentView) - { - case LOGO: - { - UpdateLogo(&app->logo, &app->state.currentView, &app->state.running); - RenderLogo(&app->logo, &app->flags); - }break; - case MENU: - { - UpdateMenu(&app->menu, &app->state, &app->flags); - RenderMenu(&app->menu, &app->font, app->window.title, &app->flags); - }break; - case GAMEPLAY: - { - UpdateGame(app); - RenderGame(app); - }break; - default: break; - } + while (app->state.running) { + switch (app->state.currentView) { + case LOGO: { + UpdateLogo(&app->logo, &app->state.currentView, &app->state.running); + RenderLogo(&app->logo, &app->flags); + } break; + case MENU: { + UpdateMenu(&app->menu, &app->state, &app->flags); + RenderMenu(&app->menu, &app->font, app->window.title, &app->flags); + } break; + case GAMEPLAY: { + UpdateGame(app); + RenderGame(app); + } break; + default: + break; } + } } -void CleanupApp(App *app){ - CleanupMenu(&app->menu); - CleanupGame(app); - CleanupFont(&app->font); - CleanUpConfig(&app->config); +void CleanupApp(App *app) { + CleanupMenu(&app->menu); + CleanupGame(app); + CleanupFont(&app->font); + CleanUpConfig(&app->config); } - diff --git a/src/appGame.c b/src/appGame.c index 237d0ac..0c25625 100644 --- a/src/appGame.c +++ b/src/appGame.c @@ -1,145 +1,120 @@ #include "app.h" -const ShaderAsset shaderAssets[SHADER_COUNT] = { - {"shaders/postfx.fs"} -}; +const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}}; -const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = { - {"assets/sea.mp3"} -}; +const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {{"assets/sea.mp3"}}; +void InitGame(App *app) { -void InitGame(App *app) -{ - SetRandomSeed(1234); GameState *g = &app->game; - g->assets = (Assets){ - .shaderAssets = shaderAssets, - .soundtrackAssets = soundtrackAssets - }; + g->assets = (Assets){.shaderAssets = shaderAssets, + .soundtrackAssets = soundtrackAssets}; - for (int i = 0; i < SHADER_COUNT; i++) - { - g->postFX[i] = CreatePostFX(g->assets.shaderAssets[i].path); + for (int i = 0; i < SHADER_COUNT; i++) { + g->postFX[i] = CreatePostFX(g->assets.shaderAssets[i].path); } - for (int i = 0; i < SOUNDTRACK_COUNT; i++) - { - g->soundtracks[i] = LoadSoundtrack(g->assets.soundtrackAssets[i].path); + for (int i = 0; i < SOUNDTRACK_COUNT; i++) { + g->soundtracks[i] = LoadSoundtrack(g->assets.soundtrackAssets[i].path); } - g->target = LoadRenderTexture(app->window.width, app->window.height); CreatePlayer(); - Player* player = GetPlayer(); + Player *player = GetPlayer(); CreateCamera(player->physics.position, 10.0f); g->birds = CreateBirds(); g->enemies = CreateEnemies(); g->islands = CreateIslands(); g->floor = CreateFloor(); + g->projectiles = CreateProjectiles(); Texture2D mouseTexture = LoadTexture("assets/mouse.png"); g->mouse = CreateMouse(0.10f, 5.0f, 10.0f, &mouseTexture); } -void StartGame(App *app) -{ - if(!app->state.gameStarted){ - app->state.gameStarted = true; - } +void StartGame(App *app) { + if (!app->state.gameStarted) { + app->state.gameStarted = true; + } } +void UpdateGame(App *app) { + GameState *g = &app->game; + if (app->flags.limitFPS) { + SetTargetFPS(60); + } else { + SetTargetFPS(0); + } -void UpdateGame(App *app) -{ - GameState *g = &app->game; - if (app->flags.limitFPS){ - SetTargetFPS(60); - } else { - SetTargetFPS(0); - } + StartGame(app); - StartGame(app); + OnEscapeChangeView(app, MENU); + OnWindowClosedStoppApp(app); - OnEscapeChangeView(app, MENU); - OnWindowClosedStoppApp(app); + for (int i = 0; i < SHADER_COUNT; i++) { + UpdatePostFX(&g->postFX[i]); + } + for (int i = 0; i < SOUNDTRACK_COUNT; i++) { + UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn); + } - for (int i = 0; i < SHADER_COUNT; i++) - { - UpdatePostFX(&g->postFX[i]); - } - for (int i = 0; i < SOUNDTRACK_COUNT; i++) - { - UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn); - } - - UpdateMouse(&g->mouse); - Player* player = GetPlayer(); - UpdateCamera2D(&player->physics.position, &g->mouse); - UpdateFloor(&g->floor); - UpdatePlayer(); - UpdateBirds(&g->birds); - UpdateEnemies(&g->enemies); - UpdateIslands(&g->islands); + UpdateMouse(&g->mouse); + Player *player = GetPlayer(); + UpdateCamera2D(&player->physics.position, &g->mouse); + UpdateFloor(&g->floor); + UpdatePlayer(); + UpdateBirds(&g->birds); + UpdateEnemies(&g->enemies); + UpdateIslands(&g->islands); } -void RenderComponents(App *app) -{ - GameState *g = &app->game; - RenderFloor(&g->floor); - RenderPlayer(); - RenderEnemies(&g->enemies); - RenderBirds(&g->birds); - RenderIslands(&g->islands); +void RenderComponents(App *app) { + GameState *g = &app->game; + RenderFloor(&g->floor); + RenderPlayer(); + RenderEnemies(&g->enemies); + RenderBirds(&g->birds); + RenderIslands(&g->islands); } -void RenderGame(App *app) -{ - GameState *g = &app->game; - - BeginTextureMode(g->target); - ClearBackground(BLACK); - Camera2D *camera = GetCamera(); - BeginMode2D(*camera); - RenderComponents(app); - EndMode2D(); - DrawTextureRec - ( - g->mouse.cursorTexture, - (Rectangle){0, 0, g->mouse.cursorTexture.width, g->mouse.cursorTexture.height}, - (Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, - WHITE - ); - EndTextureMode(); +void RenderGame(App *app) { + GameState *g = &app->game; - BeginDrawing(); - ClearBackground(BLACK); - for (int i = 0; i < SHADER_COUNT; i++) - { - RenderPostFX(&g->postFX[i], &g->target); - } + BeginTextureMode(g->target); + ClearBackground(BLACK); + Camera2D *camera = GetCamera(); + BeginMode2D(*camera); + RenderComponents(app); + EndMode2D(); + DrawTextureRec( + g->mouse.cursorTexture, + (Rectangle){0, 0, g->mouse.cursorTexture.width, + g->mouse.cursorTexture.height}, + (Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, WHITE); + EndTextureMode(); - if (app->flags.showFPS) - { - DrawFPS(10, 10); - } + BeginDrawing(); + ClearBackground(BLACK); + for (int i = 0; i < SHADER_COUNT; i++) { + RenderPostFX(&g->postFX[i], &g->target); + } - EndDrawing(); + if (app->flags.showFPS) { + DrawFPS(10, 10); + } + + EndDrawing(); } -void CleanupGame(App *app) -{ - GameState *g = &app->game; - for (int i = 0; i < SHADER_COUNT; i++) - { - UnloadPostFX(&g->postFX[i]); - } - for (int i = 0; i < SOUNDTRACK_COUNT; i++) - { - UnloadMusicStream(g->soundtracks[i].music); - } - UnloadRenderTexture(g->target); +void CleanupGame(App *app) { + GameState *g = &app->game; + for (int i = 0; i < SHADER_COUNT; i++) { + UnloadPostFX(&g->postFX[i]); + } + for (int i = 0; i < SOUNDTRACK_COUNT; i++) { + UnloadMusicStream(g->soundtracks[i].music); + } + UnloadRenderTexture(g->target); } - diff --git a/src/appGameIslands.c b/src/appGameIslands.c index 6398757..172b21f 100644 --- a/src/appGameIslands.c +++ b/src/appGameIslands.c @@ -1,47 +1,39 @@ #include "app.h" const TextureAsset islandsTextureAssets[ISLANDS_TEX_COUNT] = { - {"assets/island.png", 16.0f, 16.0f, 0.0f} -}; + {"assets/island.png", 16.0f, 16.0f, 0.0f}}; -Islands CreateIslands(void){ - TextureAsset islandAsset = islandsTextureAssets[ISLAND]; - Texture2D texture = LoadTexture(islandAsset.path); - float frameWidth = islandAsset.frameWidth; - float rotation = islandAsset.rotation; - - Sprite islandSprite = { - .texture = texture, - .frameSize = {frameWidth, frameWidth}, - .sourceRec = {0.0f, 0.0f, frameWidth, frameWidth}, - .destRec = {GetScreenWidth()/2, 0.0f, frameWidth, frameWidth}, - .origin = {frameWidth / 2, frameWidth / 2}, - .rotation = rotation, - .color = WHITE - }; +Islands CreateIslands(void) { + TextureAsset islandAsset = islandsTextureAssets[ISLAND]; + Texture2D texture = LoadTexture(islandAsset.path); + float frameWidth = islandAsset.frameWidth; + float rotation = islandAsset.rotation; - Physics islandPhysics = { - .position = (Vector2){-100.0f, 0.0f}, - .direction = (Vector2){0.0f, 0.0f}, - .speed = 10.0f - }; + Sprite islandSprite = { + .texture = texture, + .frameSize = {frameWidth, frameWidth}, + .sourceRec = {0.0f, 0.0f, frameWidth, frameWidth}, + .destRec = {GetScreenWidth() / 2, 0.0f, frameWidth, frameWidth}, + .origin = {frameWidth / 2, frameWidth / 2}, + .rotation = rotation, + .color = WHITE}; - return (Islands){ - .sprite = islandSprite, - .physics = islandPhysics - }; - + Physics islandPhysics = {.position = (Vector2){-100.0f, 0.0f}, + .direction = (Vector2){0.0f, 0.0f}, + .speed = 10.0f}; + + return (Islands){.sprite = islandSprite, .physics = islandPhysics}; } -void UpdateIslands(Islands *islands){ - - UpdatePhysics(&islands->physics, (Vector2){0.0f,0.0f}); +void UpdateIslands(Islands *islands) { + + UpdatePhysics(&islands->physics, (Vector2){0.0f, 0.0f}); UpdateSpriteDestRec(&islands->sprite, &islands->physics.position); UpdateAnimation(&islands->animation, GetFrameTime()); - UpdateSpriteSourceRec(&islands->sprite, &(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame, islands->sprite.frameSize.y}); -} - -void RenderIslands(Islands *islands){ - RenderSprite(&islands->sprite); + UpdateSpriteSourceRec( + &islands->sprite, + &(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame, + islands->sprite.frameSize.y}); } +void RenderIslands(Islands *islands) { RenderSprite(&islands->sprite); } diff --git a/src/appGameProjectiles.c b/src/appGameProjectiles.c new file mode 100644 index 0000000..c202aac --- /dev/null +++ b/src/appGameProjectiles.c @@ -0,0 +1,7 @@ +#include "app.h" + +Projectiles CreateProjectiles(void) {} + +void UpdateProjectiles(Projectiles *projectiles) {} + +void RenderProjectiles(Projectiles *projectiles) {} diff --git a/src/appGameShip.c b/src/appGameShip.c new file mode 100644 index 0000000..0487067 --- /dev/null +++ b/src/appGameShip.c @@ -0,0 +1,7 @@ +#include "app.h" + +Ship InitShip(int shipID) { + Config config; + InitConfig(&config, "config/ships.ini"); + Ship ship; +} diff --git a/src/appGameShoot.c b/src/appGameShoot.c deleted file mode 100644 index 90353e2..0000000 --- a/src/appGameShoot.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "app.h" - -