From c1a24481266dfc9f0efa8b1601a5b0bdee92aa81 Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Sun, 2 Nov 2025 11:23:26 +0100 Subject: [PATCH] big refactor: i see i need header files --- Makefile | 6 +- external/engine/asset.h | 30 -- external/engine/engine.h | 21 -- external/engine/window.h | 10 - include/appColors.h | 7 - include/appGameAssets.h | 25 -- include/appMenuAssets.h | 43 --- include/appMenuView.h | 10 - include/appSettings.h | 9 - include/appState.h | 16 -- include/appTypes.h | 257 ++++++++++++++++++ include/engine.h | 232 ++++++++++++++++ include/app.h => src/app.c | 31 +-- include/appGame.h => src/appGame.c | 69 +++-- include/appGameBirds.h => src/appGameBirds.c | 16 +- include/appGameFloor.h => src/appGameFloor.c | 14 +- .../appGameIslands.h => src/appGameIslands.c | 17 +- .../appGamePlayer.h => src/appGamePlayer.c | 26 +- include/appLogo.h => src/appLogo.c | 17 +- include/appMenu.h => src/appMenu.c | 15 +- include/appMenuMain.h => src/appMenuMain.c | 39 ++- .../appMenuMainBackground.c | 12 +- .../appMenuSettings.c | 12 +- .../animation.h => src/engineAnimation.c | 14 +- external/engine/array.h => src/engineArray.c | 26 +- .../engine/camera.h => src/engineCamera.c | 8 +- .../engine/config.h => src/engineConfig.c | 12 +- external/engine/font.h => src/engineFont.c | 4 +- .../engine/gamegui.h => src/engineGamegui.c | 29 +- external/engine/gui.h => src/engineGui.c | 11 +- external/engine/input.h => src/engineInput.c | 20 +- .../engine/object.h => src/engineObject.c | 18 +- .../engine/physics.h => src/enginePhysics.c | 14 +- .../engine/postfx.h => src/enginePostfx.c | 12 +- .../soundtrack.h => src/engineSoundtrack.c | 11 +- .../engine/sprite.h => src/engineSprite.c | 17 +- .../engine/vector.h => src/engineVector.c | 9 +- src/main.c | 3 +- 38 files changed, 582 insertions(+), 560 deletions(-) delete mode 100644 external/engine/asset.h delete mode 100644 external/engine/engine.h delete mode 100644 external/engine/window.h delete mode 100644 include/appColors.h delete mode 100644 include/appGameAssets.h delete mode 100644 include/appMenuAssets.h delete mode 100644 include/appMenuView.h delete mode 100644 include/appSettings.h delete mode 100644 include/appState.h create mode 100644 include/appTypes.h create mode 100644 include/engine.h rename include/app.h => src/app.c (72%) rename include/appGame.h => src/appGame.c (61%) rename include/appGameBirds.h => src/appGameBirds.c (87%) rename include/appGameFloor.h => src/appGameFloor.c (95%) rename include/appGameIslands.h => src/appGameIslands.c (85%) rename include/appGamePlayer.h => src/appGamePlayer.c (89%) rename include/appLogo.h => src/appLogo.c (91%) rename include/appMenu.h => src/appMenu.c (76%) rename include/appMenuMain.h => src/appMenuMain.c (91%) rename include/appMenuMainBackground.h => src/appMenuMainBackground.c (88%) rename include/appMenuSettings.h => src/appMenuSettings.c (88%) rename external/engine/animation.h => src/engineAnimation.c (61%) rename external/engine/array.h => src/engineArray.c (82%) rename external/engine/camera.h => src/engineCamera.c (91%) rename external/engine/config.h => src/engineConfig.c (91%) rename external/engine/font.h => src/engineFont.c (80%) rename external/engine/gamegui.h => src/engineGamegui.c (85%) rename external/engine/gui.h => src/engineGui.c (78%) rename external/engine/input.h => src/engineInput.c (81%) rename external/engine/object.h => src/engineObject.c (93%) rename external/engine/physics.h => src/enginePhysics.c (79%) rename external/engine/postfx.h => src/enginePostfx.c (88%) rename external/engine/soundtrack.h => src/engineSoundtrack.c (81%) rename external/engine/sprite.h => src/engineSprite.c (86%) rename external/engine/vector.h => src/engineVector.c (74%) diff --git a/Makefile b/Makefile index e4493f1..4e08792 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,11 @@ EXTERNAL_FLAGS = \ $(EXTERNAL_RAYGUI) ifeq ($(OS), Windows_NT) - SRC = src\main.c + SRC = $(wildcard src\*.c) TARGET = bin\win\game.exe RAYLIB_FLAGS = -I%RAYLIB% -L%RAYLIB% -lraylib -lopengl32 -lgdi32 -lwinmm else - SRC = src/main.c + SRC = $(wildcard src/*.c) TARGET = bin/osx/game RAYLIB_FLAGS = $(shell pkg-config --libs --cflags raylib) endif @@ -47,4 +47,4 @@ clean: rm -f $(TARGET) run: clean build - ./$(TARGET) \ No newline at end of file + ./$(TARGET) diff --git a/external/engine/asset.h b/external/engine/asset.h deleted file mode 100644 index 697cf75..0000000 --- a/external/engine/asset.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef ASSET_H -#define ASSET_H - -typedef struct { - const char* path; - float frameWidth; - float frameHeight; - float rotation; -} TextureAsset; - -typedef struct { - const char* path; -} ShaderAsset; - -typedef struct { - const char* path; -} SoundtrackAsset; - -typedef struct { - const char* path; -} SoundAsset; - -typedef struct { - const TextureAsset *textureAssets; - const ShaderAsset *shaderAssets; - const SoundtrackAsset *soundtrackAssets; - const SoundAsset *soundAssets; -} Assets; - -#endif // ASSET_H diff --git a/external/engine/engine.h b/external/engine/engine.h deleted file mode 100644 index 7e82549..0000000 --- a/external/engine/engine.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ENGINE_H -#define ENGINE_H - -#include "animation.h" -//#include "array.h" -#include "asset.h" -#include "camera.h" -#include "config.h" -#include "gamegui.h" -#include "gui.h" -#include "input.h" -#include "object.h" -#include "physics.h" -#include "postfx.h" -#include "soundtrack.h" -#include "sprite.h" -#include "vector.h" -#include "window.h" -#include "font.h" - -#endif //ENGINE_H diff --git a/external/engine/window.h b/external/engine/window.h deleted file mode 100644 index b56ab8e..0000000 --- a/external/engine/window.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DISPLAY_H -#define DISPLAY_H - -typedef struct { - int width; - int height; - const char* title; -} Window; - -#endif // DISPLAY_H diff --git a/include/appColors.h b/include/appColors.h deleted file mode 100644 index c047f77..0000000 --- a/include/appColors.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef APPCOLORS_H -#define APPCOLORS_H - -#define TEXT_COLOR_DARK (Color){ 182, 137, 98, 255} -#define TEXT_COLOR_LIGHT (Color){ 243, 229, 194, 255} - -#endif // APPCOLORS_H diff --git a/include/appGameAssets.h b/include/appGameAssets.h deleted file mode 100644 index 0214303..0000000 --- a/include/appGameAssets.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef APPGAMEASSETS_H -#define APPGAMEASSETS_H - - -typedef enum -{ - POST_FX, - SHADER_COUNT -} ShaderID; - -const ShaderAsset shaderAssets[SHADER_COUNT] = { - {"shaders/postfx.fs"}}; - - -typedef enum -{ - BEE_AMBIENT, - SOUNDTRACK_COUNT -} SoundtrackID; - -const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = { - {"assets/sea.mp3"}}; - - -#endif // APPGAMEASSETS_H diff --git a/include/appMenuAssets.h b/include/appMenuAssets.h deleted file mode 100644 index 04dedcd..0000000 --- a/include/appMenuAssets.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef APPMENUASSETS_H -#define APPMENUASSETS_H - -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; - -const TextureAsset menuTextureAssets[MENU_TEX_COUNT] = { - {"assets/mouse.png", 16.0f, 16.0f, 0.0f}, - {"assets/buttons.png", 288.0f/3, 96.0f/3, 0.0f}, - {"assets/menu_board.png", 128.0f, 144.0f, 0.0f}, - {"assets/cloud_background.png", 576.0f, 324.0f, 0.0f}, - {"assets/cloud_midground.png", 576.0f, 324.0f, 0.0f}, - {"assets/cloud_foreground.png", 576.0f, 324.0f, 0.0f}}; - -typedef enum -{ - MENU_MUSIC, - MENU_SOUNDTRACK_COUNT -} MenuSoundtrackID; - -const SoundtrackAsset menuSoundtrackAssets[MENU_SOUNDTRACK_COUNT] = { - {"assets/merrygoround.wav"}}; - -typedef enum -{ - HOVER_SOUND, - CLICK_SOUND, - MENU_SOUND_COUNT -} MenuSoundID; - -const SoundAsset menuSoundAssets[MENU_SOUND_COUNT] = { - {"assets/button_hover.wav"}, - {"assets/button_click.wav"}}; - -#endif // APPMENUASSETS_H diff --git a/include/appMenuView.h b/include/appMenuView.h deleted file mode 100644 index c4fa242..0000000 --- a/include/appMenuView.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef APPMENUVIEW_H -#define APPMENUVIEW_H - -typedef enum MenuView { - MAIN = 0, - SETTINGS = 1 -} MenuView; - -#endif // MENUVIEW_H - diff --git a/include/appSettings.h b/include/appSettings.h deleted file mode 100644 index 6991cf3..0000000 --- a/include/appSettings.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef APPSETTINGS_H -#define APPSETTINGS_H - -typedef struct { - bool showFPS; - bool soundtrackOn; -} Flags; - -#endif // APPSETTINGS_H diff --git a/include/appState.h b/include/appState.h deleted file mode 100644 index e484fea..0000000 --- a/include/appState.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef APPSTATE_H -#define APPSTATE_H - -typedef enum View { - LOGO = 0, - MENU = 1, - GAMEPLAY = 2 -} View; - -typedef struct { - View currentView; - bool running; - bool gameStarted; -} State; - -#endif // APPSTATE_H diff --git a/include/appTypes.h b/include/appTypes.h new file mode 100644 index 0000000..38cbe9f --- /dev/null +++ b/include/appTypes.h @@ -0,0 +1,257 @@ +#ifndef APPTYPES_H +#define APPTYPES_H + +//INCLUDES// +#include +#include + +//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 +} MenuTextureID; + +typedef enum +{ + MENU_MUSIC, + MENU_SOUNDTRACK_COUNT +} MenuSoundtrackID; + +typedef enum +{ + HOVER_SOUND, + CLICK_SOUND, + MENU_SOUND_COUNT +} MenuSoundID; + +typedef enum MenuView { + MAIN = 0, + SETTINGS = 1 +} MenuView; + +typedef enum +{ + START_SHIP, + PLAYER_TEX_COUNT +} playerTextureID; + +typedef enum { + ANCHOR, + SLOW_AHEAD, + FAST_AHEAD, + SPEED_COUNT +} playerSpeedID; + +typedef enum +{ + FLYING, + BIRDS_TEX_COUNT +} birdsTextureID; + +typedef enum +{ + ISLAND, + ISLANDS_TEX_COUNT +} islandsTextureID; + +typedef enum +{ + POST_FX, + SHADER_COUNT +} ShaderID; + +typedef enum +{ + BEE_AMBIENT, + SOUNDTRACK_COUNT +} SoundtrackID; + +typedef enum View { + LOGO = 0, + MENU = 1, + GAMEPLAY = 2 +} View; + +//STRUCTS// +typedef struct { + 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; +} 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; +} MenuMain; + +typedef struct +{ + Button showFPS; + Button soundtrackOn; + +} MenuSettings; + + +typedef struct +{ + MenuView menuView; + MenuMain menuMain; + MenuSettings menuSettings; +} MenuState; + + +typedef struct +{ + Sprite sprite; + Rectangle bounds; + Shader shader; + float time; +} Floor; + +typedef struct +{ + Sprite sprite; + Animation animation; + Physics physics; + float rotation; +} Player; + +typedef struct { + Sprite sprite; + Animation animation; + Physics physics; +} Birds; + +typedef struct { + Sprite sprite; + Animation animation; + Physics physics; +} Islands; + +typedef struct +{ + Assets assets; + PostProcessing postFX[SHADER_COUNT]; + Soundtrack soundtracks[SOUNDTRACK_COUNT]; + RenderTexture2D target; + Floor floor; + Player player; + Birds birds; + Islands islands; + Camera2D camera; + Mouse mouse; + Image image; +} GameState; + +typedef struct { + View currentView; + bool running; + bool gameStarted; +} State; + +typedef struct { + bool showFPS; + 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 UpdateBackground(Background *bg); +void RenderBackground(Background *bg); + +void InitMenuMain(MenuMain *m); +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, Flags *flags); +void RenderMenuSettings(MenuSettings *s, Flags *flags); +void CleanupMenuSettings(MenuSettings *s); + +void InitMenu(MenuState *m); +void UpdateMenu(MenuState *m, State *state, Flags *flags); +void RenderMenu(MenuState *m, Font *font, const char *title, Flags *flags); +void CleanupMenu(MenuState *m); + +Floor CreateFloor(void); +void UpdateFloor(Floor *floor, const Camera2D *camera); +void RenderFloor(Floor *floor); +void UnloadFloor(Floor *floor); + +playerSpeedID GetPlayerSpeedID(float speed); +Player CreatePlayer(void); +void UpdatePlayer(Player *player); +void RenderPlayer(Player *player); + +Birds CreateBirds(void); +void UpdateBirds(Birds *birds); +void RenderBirds(Birds *birds); + +Islands CreateIslands(void); +void UpdateIslands(Islands *islands); +void RenderIslands(Islands *islands); + +void InitGame(App *app); +void UpdateGame(App *app); +void RenderComponents(App *app); +void RenderGame(App *app); +void CleanupGame(App *app); + +void ConfigApp(App *app); +void InitApp(App *app); +void UpdateApp(App *app); +void CleanupApp(App *app); + +#endif //APPTYPES_H diff --git a/include/engine.h b/include/engine.h new file mode 100644 index 0000000..cd2a728 --- /dev/null +++ b/include/engine.h @@ -0,0 +1,232 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct +{ + Texture2D texture; + Rectangle sourceRec; + Rectangle destRec; + Vector2 frameSize; + Vector2 origin; + float rotation; + Color color; +} Sprite; + +typedef struct { + int state; + int currentFrame; + int maxFrame; + int framesCounter; + int framesSpeed; + float animTimer; +} Animation; + +typedef struct { + void** elements; + unsigned int count; + unsigned int capacity; +} Array; + +typedef struct { + const char* path; + float frameWidth; + float frameHeight; + float rotation; +} TextureAsset; + +typedef struct { + const char* path; +} ShaderAsset; + +typedef struct { + const char* path; +} SoundtrackAsset; + +typedef struct { + const char* path; +} SoundAsset; + +typedef struct { + const TextureAsset *textureAssets; + const ShaderAsset *shaderAssets; + const SoundtrackAsset *soundtrackAssets; + const SoundAsset *soundAssets; +} Assets; + +typedef struct { + char *path; + rini_config rini; +} Config; + +typedef enum { + NOT_CLICKED, + HOVER, + CLICKED +} ButtonState; + +typedef struct +{ + Sprite sprite; + Vector2 notClicked; + Vector2 hover; + Vector2 clicked; + bool isHovered; + bool isClicked; +} ImageButton; + +typedef struct +{ + Sprite sprite; +} ImageElement; + +typedef struct +{ + Rectangle rec; + char *text; +} Button; + +typedef struct { + Vector2 screenPosition; + Vector2 worldPosition; + float zoomSpeed; + float minZoom; + float maxZoom; + float scaleFactor; + float wheelMove; + bool leftButton; + bool rightButton; + Texture2D cursorTexture; +} Mouse; + +typedef struct { + Sprite sprite; + Vector2 position; +} Object; + +typedef struct { + Object *data; + const Object *prototype; + size_t count; +} ObjectArray; + +typedef struct +{ + Vector2 position; + Vector2 direction; + Vector2 velocity; + float speed; +} Physics; + +typedef struct { + Shader shader; + int resolutionLoc; + int strengthLoc; + float strength; +} PostProcessing; + +typedef struct { + Music music; + bool playing; + bool paused; +} Soundtrack; + +typedef struct { + Vector2 *data; + size_t count; +} Vector2Array; + +typedef struct { + int width; + int height; + const char* title; +} Window; + +void UpdateAnimation(Animation *animation, float deltaTime); + +Array* CreateArray(unsigned int initCapacity); +int AddElementToArray(Array* array, void* element); +int RemoveElementFromArray(Array* array, unsigned int index); +void* GetRandomElementFromArray(Array* array); +void UpdateArray(Array* array, void (*updateFunc)(void*)); +void RenderArray(Array* array, void (*renderFunc)(void*)); +void FreeArray(Array** array); + +Camera2D CreateCamera(Vector2 playerPosition, float initZoom); +void UpdateCameraTarget(Camera2D *camera, Vector2 *position, const float smoothness); +void UpdateCameraZoom(Camera2D *camera, const float *scaleFactor, const float *minZoom, const float *maxZoom); +void UpdateCamera2D(Camera2D* camera, Vector2* position, Mouse* mouse); + +void InitConfig(Config *config, const char* path); +int GetConfigInt(Config *config, const char *key); +int GetConfigIntOrDefault(Config *config, const char *key, int default_value); +const char* GetConfigString(Config *config, const char *key); +const char* GetConfigStringOrDefault(Config *config, const char *key, const char *default_value); +const char* GetConfigDescription(Config *config, const char *key); +int SetConfigInt(Config *config, const char *key, int value, const char *desc); +int SetConfigString(Config *config, const char *key, const char *text, const char *desc); +int SetConfigDescription(Config *config, const char *key, const char *desc); +int AddCommentLine(Config *config, const char *comment); +void SaveConfig(Config *config); +void CleanUpConfig(Config *config); + +void InitFont(Font *font, const char* path); +void CleanupFont(Font *font); + +ImageButton CreateImageButton(ButtonState state, Texture2D *texture, const TextureAsset *asset, Vector2 *source, Vector2 *clicked, Vector2 *hover, Rectangle *destRec); +ImageElement CreateImageElement(Texture2D *texture, const TextureAsset *asset, Vector2 *source, Rectangle *destRec); +int isImageButtonClicked(ImageButton *b, Sound soundHover, Sound soundClick); +void renderImageButton(ImageButton *b); +void renderImageElement(ImageElement *e); + +Button initButton(char *text, Vector2 dimensions, Vector2 position); +int isButtonClicked(Button *b); +void renderButton(Button *b); + +Mouse CreateMouse(float zoomSpeed, float minZoom, float maxZoom, Texture2D *texture); +void UpdateMouseScreen(Mouse *mouse); +void UpdateMouse(Mouse *mouse, Camera2D *camera); +Vector2 GetDirectionVector(void); + +ObjectArray CreateObjectArray(const Object *prototype, const size_t count); +Object* GetRandomObject(ObjectArray *objects); +void AddObjectToArray(ObjectArray *objects, const Object *prototype, Vector2 position); +void SetPositionForObjectArray(ObjectArray *objects, const Vector2Array *positions); +void SetRandomPositionForObjectArray(ObjectArray *objects, const Rectangle bounds); +void SwapAndPopObjectsArrayOnRecCollision(ObjectArray *objects, const Rectangle rec); +void SwapAndPopObjectsArrayOnPointCollision(ObjectArray *objects, const Vector2 point); +void RenderObjectArray(const ObjectArray *objects); + +void UpdatePhysicsDirection(Vector2 *direction, Vector2 vector); +void UpdatePhysicsVelocity(Vector2 *velocity, Vector2 *direction, float *speed); +void UpdatePhysicsPosition(Vector2 *position, Vector2 *velocity); +void UpdatePhysicsSpeed(float *speed, float *newSpeed); +void UpdatePhysics(Physics *physics, Vector2 direction); + +PostProcessing CreatePostFX(const char* shaderPath); +void UpdatePostFX(PostProcessing *postFX); +void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target); +void UnloadPostFX(PostProcessing *postFX); + +Soundtrack LoadSoundtrack(const char* musicPath); +void UpdateSoundtrack(Soundtrack *soundtrack, bool playing); + +void UpdateSpriteSourceRec(Sprite *sprite, const Vector2 *vector); +void UpdateSpriteDestRec(Sprite *sprite, const Vector2 *vector); +void UpdateSpriteRotation(Sprite *sprite, Vector2 *vector); +void RenderSprite(const Sprite *sprite); +void PrintSprite(const Sprite *sprite); + +bool IsVectorZero(Vector2 v); +Vector2 GetRandomVector(const Rectangle bounds); + +#endif //ENGINE_H + diff --git a/include/app.h b/src/app.c similarity index 72% rename from include/app.h rename to src/app.c index 38bba22..2152194 100644 --- a/include/app.h +++ b/src/app.c @@ -1,26 +1,6 @@ -#ifndef APP_H -#define APP_H - #include -#include "appState.h" -#include "appSettings.h" -#include "appColors.h" - -#include "appLogo.h" -#include "appMenu.h" -#include "appGame.h" - -typedef struct { - Config config; - State state; - Flags flags; - Window window; - Font font; - LogoState logo; - MenuState menu; - GameState game; -} App; +#include "appTypes.h" void ConfigApp(App* app){ InitConfig(&app->config, "config/config.ini"); @@ -36,7 +16,7 @@ void InitApp(App *app){ InitFont(&app->font, "assets/font.fnt"); InitLogo(&app->logo); InitMenu(&app->menu); - InitGame(&app->game,&app->window); + InitGame(app); } void UpdateApp(App *app){ @@ -60,8 +40,8 @@ void UpdateApp(App *app){ }break; case GAMEPLAY: { - UpdateGame(&app->game, &app->state, &app->flags); - RenderGame(&app->game, &app->state, &app->flags); + UpdateGame(app); + RenderGame(app); }break; default: break; } @@ -70,9 +50,8 @@ void UpdateApp(App *app){ void CleanupApp(App *app){ CleanupMenu(&app->menu); - CleanupGame(&app->game); + CleanupGame(app); CleanupFont(&app->font); CleanUpConfig(&app->config); } -#endif //APP_H diff --git a/include/appGame.h b/src/appGame.c similarity index 61% rename from include/appGame.h rename to src/appGame.c index e45058f..121fe11 100644 --- a/include/appGame.h +++ b/src/appGame.c @@ -1,30 +1,17 @@ -#ifndef APPGAME_H -#define APPGAME_H +#include "appTypes.h" + +const ShaderAsset shaderAssets[SHADER_COUNT] = { + {"shaders/postfx.fs"}}; -#include "appGameFloor.h" -#include "appGamePlayer.h" -#include "appGameBirds.h" -#include "appGameIslands.h" -#include "appGameAssets.h" -typedef struct -{ - Assets assets; - PostProcessing postFX[SHADER_COUNT]; - Soundtrack soundtracks[SOUNDTRACK_COUNT]; - RenderTexture2D target; - Floor floor; - Player player; - Birds birds; - Islands islands; - Camera2D camera; - Mouse mouse; - Image image; -} GameState; +const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = { + {"assets/sea.mp3"}}; -void InitGame(GameState *g, Window *window) + +void InitGame(App *app) { + GameState *g = &app->game; g->assets = (Assets){ .shaderAssets = shaderAssets, .soundtrackAssets = soundtrackAssets @@ -40,7 +27,7 @@ void InitGame(GameState *g, Window *window) g->soundtracks[i] = LoadSoundtrack(g->assets.soundtrackAssets[i].path); } - g->target = LoadRenderTexture(window->width, window->height); + g->target = LoadRenderTexture(app->window.width, app->window.height); g->player = CreatePlayer(); g->birds = CreateBirds(); g->islands = CreateIslands(); @@ -51,10 +38,11 @@ void InitGame(GameState *g, Window *window) g->mouse = CreateMouse(0.10f, 5.0f, 10.0f, &mouseTexture); } -void UpdateGame(GameState *g, State *state, Flags *flags) +void UpdateGame(App *app) { - if(!state->gameStarted){ - state->gameStarted = true; + GameState *g = &app->game; + if(!app->state.gameStarted){ + app->state.gameStarted = true; } if (GetFPS() <= 60) @@ -64,12 +52,12 @@ void UpdateGame(GameState *g, State *state, Flags *flags) if (IsKeyPressed(KEY_ESCAPE)) { - state->currentView = MENU; + app->state.currentView = MENU; } if (WindowShouldClose() && !IsKeyPressed(KEY_ESCAPE)) { - state->running = false; + app->state.running = false; } for (int i = 0; i < SHADER_COUNT; i++) @@ -78,7 +66,7 @@ void UpdateGame(GameState *g, State *state, Flags *flags) } for (int i = 0; i < SOUNDTRACK_COUNT; i++) { - UpdateSoundtrack(&g->soundtracks[i], flags->soundtrackOn); + UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn); } UpdateMouse(&g->mouse, &g->camera); @@ -89,22 +77,31 @@ void UpdateGame(GameState *g, State *state, Flags *flags) UpdateIslands(&g->islands); } -void RenderComponents(GameState *g) +void RenderComponents(App *app) { + GameState *g = &app->game; RenderFloor(&g->floor); RenderPlayer(&g->player); RenderBirds(&g->birds); RenderIslands(&g->islands); } -void RenderGame(GameState *g, const State *appState, Flags *flags) +void RenderGame(App *app) { + GameState *g = &app->game; + BeginTextureMode(g->target); ClearBackground(BLACK); BeginMode2D(g->camera); - RenderComponents(g); + 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); + 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(); BeginDrawing(); @@ -114,7 +111,7 @@ void RenderGame(GameState *g, const State *appState, Flags *flags) RenderPostFX(&g->postFX[i], &g->target); } - if (flags->showFPS) + if (app->flags.showFPS) { DrawFPS(10, 10); } @@ -122,8 +119,9 @@ void RenderGame(GameState *g, const State *appState, Flags *flags) EndDrawing(); } -void CleanupGame(GameState *g) +void CleanupGame(App *app) { + GameState *g = &app->game; for (int i = 0; i < SHADER_COUNT; i++) { UnloadPostFX(&g->postFX[i]); @@ -135,4 +133,3 @@ void CleanupGame(GameState *g) UnloadRenderTexture(g->target); } -#endif // APPGAME_H diff --git a/include/appGameBirds.h b/src/appGameBirds.c similarity index 87% rename from include/appGameBirds.h rename to src/appGameBirds.c index d5616fe..90c7579 100644 --- a/include/appGameBirds.h +++ b/src/appGameBirds.c @@ -1,17 +1,4 @@ -#ifndef APPGAMEBIRDS_H -#define APPGAMEBIRDS_H - -typedef struct { - Sprite sprite; - Animation animation; - Physics physics; -} Birds; - -typedef enum -{ - FLYING, - BIRDS_TEX_COUNT -} birdsTextureID; +#include "appTypes.h" const TextureAsset birdsTextureAssets[BIRDS_TEX_COUNT] = { {"assets/birds.png", 16.0f, 16.0f, 45.0f} @@ -68,4 +55,3 @@ void RenderBirds(Birds *birds){ RenderSprite(&birds->sprite); } -#endif // APPGAMEBIRDS_H diff --git a/include/appGameFloor.h b/src/appGameFloor.c similarity index 95% rename from include/appGameFloor.h rename to src/appGameFloor.c index 6cd3079..2aea7c6 100644 --- a/include/appGameFloor.h +++ b/src/appGameFloor.c @@ -1,14 +1,4 @@ -#ifndef APPGAMEFloor_H -#define APPGAMEFloor_H - - -typedef struct -{ - Sprite sprite; - Rectangle bounds; - Shader shader; - float time; -} Floor; +#include "appTypes.h" Floor CreateFloor(void) { @@ -98,5 +88,3 @@ void UnloadFloor(Floor *floor) UnloadShader(floor->shader); } -#endif // APPGAMEFLOOR_H - diff --git a/include/appGameIslands.h b/src/appGameIslands.c similarity index 85% rename from include/appGameIslands.h rename to src/appGameIslands.c index 10ee0cd..45b591e 100644 --- a/include/appGameIslands.h +++ b/src/appGameIslands.c @@ -1,17 +1,4 @@ -#ifndef APPGAMEISLANDS_H -#define APPGAMEISLANDS_H - -typedef struct { - Sprite sprite; - Animation animation; - Physics physics; -} Islands; - -typedef enum -{ - ISLAND, - ISLANDS_TEX_COUNT -} islandsTextureID; +#include "appTypes.h" const TextureAsset islandsTextureAssets[ISLANDS_TEX_COUNT] = { {"assets/island.png", 16.0f, 16.0f, 0.0f} @@ -58,5 +45,3 @@ void RenderIslands(Islands *islands){ RenderSprite(&islands->sprite); } -#endif // APPGAMEISLANDS_H - diff --git a/include/appGamePlayer.h b/src/appGamePlayer.c similarity index 89% rename from include/appGamePlayer.h rename to src/appGamePlayer.c index 3f95e43..4c7a7d7 100644 --- a/include/appGamePlayer.h +++ b/src/appGamePlayer.c @@ -1,22 +1,10 @@ -#ifndef APPGAMEPLAYER_H -#define APPGAMEPLAYER_H - -typedef enum -{ - START_SHIP, - PLAYER_TEX_COUNT -} playerTextureID; +#include "appTypes.h" const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = { {"assets/ship_start.png", 16.0f, 16.0f, 0.0f} }; -typedef enum { - ANCHOR, - SLOW_AHEAD, - FAST_AHEAD, - SPEED_COUNT -} playerSpeedID; + float playerSpeeds[SPEED_COUNT] = { 0.0f, @@ -33,15 +21,6 @@ playerSpeedID GetPlayerSpeedID(float speed) { return ANCHOR; } - -typedef struct -{ - Sprite sprite; - Animation animation; - Physics physics; - float rotation; -} Player; - Player CreatePlayer(void) { @@ -142,4 +121,3 @@ void RenderPlayer(Player *player){ RenderSprite(&player->sprite); } -#endif // APPGAMEPLAYER_H diff --git a/include/appLogo.h b/src/appLogo.c similarity index 91% rename from include/appLogo.h rename to src/appLogo.c index d66b1a8..3787c00 100644 --- a/include/appLogo.h +++ b/src/appLogo.c @@ -1,18 +1,4 @@ -#ifndef APPLOGO_H -#define APPLOGO_H - -typedef struct { - int frameCounter; - int positionX; - int positionY; - int lettersCount; - int topSideRecWidth; - int leftSideRecHeight; - int bottomSideRecWidth; - int rightSideRecHeight; - int state; - float alpha; -} LogoState; +#include "appTypes.h" void InitLogo(LogoState *l) { SetTargetFPS(60); @@ -114,4 +100,3 @@ void RenderLogo(const LogoState *l, Flags *flags) { EndDrawing(); } -#endif // APPLOGO_H diff --git a/include/appMenu.h b/src/appMenu.c similarity index 76% rename from include/appMenu.h rename to src/appMenu.c index 9979567..f059b58 100644 --- a/include/appMenu.h +++ b/src/appMenu.c @@ -1,16 +1,4 @@ -#ifndef APPMENU_H -#define APPMENU_H - -#include -#include -#include - -typedef struct -{ - MenuView menuView; - MenuMain menuMain; - MenuSettings menuSettings; -} MenuState; +#include "appTypes.h" void InitMenu(MenuState *m) { @@ -59,4 +47,3 @@ void CleanupMenu(MenuState *m) CleanupMenuMain(&m->menuMain); } -#endif // APPMENU_H diff --git a/include/appMenuMain.h b/src/appMenuMain.c similarity index 91% rename from include/appMenuMain.h rename to src/appMenuMain.c index 9682213..556b224 100644 --- a/include/appMenuMain.h +++ b/src/appMenuMain.c @@ -1,25 +1,23 @@ -#ifndef APPMENUMAIN_H -#define APPMENUMAIN_H +#include "appTypes.h" -#include "appMenuAssets.h" -#include "appMenuView.h" -#include "appMenuMainBackground.h" -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; -} MenuMain; +const TextureAsset menuTextureAssets[MENU_TEX_COUNT] = { + {"assets/mouse.png", 16.0f, 16.0f, 0.0f}, + {"assets/buttons.png", 288.0f/3, 96.0f/3, 0.0f}, + {"assets/menu_board.png", 128.0f, 144.0f, 0.0f}, + {"assets/cloud_background.png", 576.0f, 324.0f, 0.0f}, + {"assets/cloud_midground.png", 576.0f, 324.0f, 0.0f}, + {"assets/cloud_foreground.png", 576.0f, 324.0f, 0.0f}}; + + +const SoundtrackAsset menuSoundtrackAssets[MENU_SOUNDTRACK_COUNT] = { + {"assets/merrygoround.wav"}}; + + +const SoundAsset menuSoundAssets[MENU_SOUND_COUNT] = { + {"assets/button_hover.wav"}, + {"assets/button_click.wav"}}; + void InitMenuMain(MenuMain *m){ @@ -208,4 +206,3 @@ void CleanupMenuMain(MenuMain *m){ } } -#endif //APPMENUMAIN_H diff --git a/include/appMenuMainBackground.h b/src/appMenuMainBackground.c similarity index 88% rename from include/appMenuMainBackground.h rename to src/appMenuMainBackground.c index 1de26f5..1cd99aa 100644 --- a/include/appMenuMainBackground.h +++ b/src/appMenuMainBackground.c @@ -1,13 +1,4 @@ -#ifndef APPMENUMAINBACKGROUND_H -#define APPMENUMAINBACKGROUND_H - -typedef struct { - Sprite sprite; - float scrolling; - float scale; - float scrollSpeed; - Vector2 pos; -} Background; +#include "appTypes.h" void InitBackground(float scrollSpeed, Background *bg, Texture2D *texture, const TextureAsset *backgroundAsset){ bg->scrolling = 0.0f; @@ -65,4 +56,3 @@ void RenderBackground(Background *bg){ } -#endif // APPMENUMAINBACKGROUND_H diff --git a/include/appMenuSettings.h b/src/appMenuSettings.c similarity index 88% rename from include/appMenuSettings.h rename to src/appMenuSettings.c index 6201bbf..6e497bf 100644 --- a/include/appMenuSettings.h +++ b/src/appMenuSettings.c @@ -1,13 +1,4 @@ -#ifndef APPMENUSETTINGS_H -#define APPMENUSETTINGS_H - - -typedef struct -{ - Button showFPS; - Button soundtrackOn; - -} MenuSettings; +#include "appTypes.h" void InitMenuSettings(MenuSettings *s) { @@ -65,4 +56,3 @@ void ClenupMenuSettings(MenuSettings *s){ } -#endif // APPMENUSETTINGS_H diff --git a/external/engine/animation.h b/src/engineAnimation.c similarity index 61% rename from external/engine/animation.h rename to src/engineAnimation.c index b2a85a9..cf6cd30 100644 --- a/external/engine/animation.h +++ b/src/engineAnimation.c @@ -1,14 +1,4 @@ -#ifndef ANIMATION_H -#define ANIMATION_H - -typedef struct { - int state; - int currentFrame; - int maxFrame; - int framesCounter; - int framesSpeed; - float animTimer; -} Animation; +#include "engine.h" void UpdateAnimation(Animation *animation, float deltaTime) { animation->animTimer += deltaTime; @@ -25,5 +15,3 @@ void UpdateAnimation(Animation *animation, float deltaTime) { animation->currentFrame = 0; } } - -#endif // ANIMATION_H diff --git a/external/engine/array.h b/src/engineArray.c similarity index 82% rename from external/engine/array.h rename to src/engineArray.c index 3fb9465..fb51f39 100644 --- a/external/engine/array.h +++ b/src/engineArray.c @@ -1,13 +1,7 @@ -#ifndef ARRAY_H -#define ARRAY_H +#include "engine.h" -typedef struct { - void** elements; - unsigned int count; - unsigned int capacity; -} Array; - -Array* CreateArray(unsigned int initCapacity){ +Array* CreateArray(unsigned int initCapacity) +{ Array* array = malloc(sizeof(Array)); if (!array) return NULL; @@ -22,7 +16,8 @@ Array* CreateArray(unsigned int initCapacity){ return array; } -int AddElementToArray(Array* array, void* element){ +int AddElementToArray(Array* array, void* element) +{ if(array->count >= array->capacity) { unsigned int newCapacity = array->capacity * 2; void** newElements = realloc(array->elements, sizeof(void*) * newCapacity); @@ -48,7 +43,8 @@ int AddElementToArray(Array* array, void* element){ // } // SWAP AND POP REMOVE -int RemoveElementFromArray(Array* array, unsigned int index) { +int RemoveElementFromArray(Array* array, unsigned int index) +{ if (index >= array->count) return 0; array->elements[index] = array->elements[array->count - 1]; @@ -58,7 +54,8 @@ int RemoveElementFromArray(Array* array, unsigned int index) { return 1; } -void* GetRandomElementFromArray(Array* array){ +void* GetRandomElementFromArray(Array* array) +{ if (array == NULL || array->elements == NULL || array->count == 0) { return NULL; } @@ -82,7 +79,8 @@ void RenderArray(Array* array, void (*renderFunc)(void*)) } } -void FreeArray(Array** array) { +void FreeArray(Array** array) +{ if (!array || !*array) return; free((*array)->elements); @@ -92,5 +90,3 @@ void FreeArray(Array** array) { *array = NULL; } - -#endif // ARRAY_H diff --git a/external/engine/camera.h b/src/engineCamera.c similarity index 91% rename from external/engine/camera.h rename to src/engineCamera.c index fbee385..979a6a9 100644 --- a/external/engine/camera.h +++ b/src/engineCamera.c @@ -1,8 +1,4 @@ -#ifndef CAMERA_H -#define CAMERA_H - -#include "input.h" -#include +#include "engine.h" Camera2D CreateCamera(Vector2 playerPosition, float initZoom){ int windowWidth = GetScreenWidth(); @@ -29,5 +25,3 @@ void UpdateCamera2D(Camera2D* camera, Vector2* position, Mouse* mouse){ UpdateCameraZoom(camera, &mouse->scaleFactor, &mouse->minZoom, &mouse->maxZoom); } - -#endif // CAMERA_H diff --git a/external/engine/config.h b/src/engineConfig.c similarity index 91% rename from external/engine/config.h rename to src/engineConfig.c index 0d6eeca..76f7ce4 100644 --- a/external/engine/config.h +++ b/src/engineConfig.c @@ -1,16 +1,7 @@ -#ifndef CONFIG_H -#define CONFIG_H - #define RINI_IMPLEMENTATION #define RINI_VALUE_DELIMITER '=' -#include -#include - -typedef struct { - char *path; - rini_config rini; -} Config; +#include "engine.h" void InitConfig(Config *config, const char* path) { config->rini = rini_load_config(path); @@ -63,4 +54,3 @@ void CleanUpConfig(Config *config) { rini_unload_config(&config->rini); } -#endif // CONFIG_H diff --git a/external/engine/font.h b/src/engineFont.c similarity index 80% rename from external/engine/font.h rename to src/engineFont.c index c4ee09e..c7acecf 100644 --- a/external/engine/font.h +++ b/src/engineFont.c @@ -1,5 +1,4 @@ -#ifndef FONT_H -#define FONT_H +#include "engine.h" void InitFont(Font *font, const char* path){ *font = LoadFont(path); @@ -10,4 +9,3 @@ void CleanupFont(Font *font){ UnloadFont(*font); } -#endif //FONT_H diff --git a/external/engine/gamegui.h b/src/engineGamegui.c similarity index 85% rename from external/engine/gamegui.h rename to src/engineGamegui.c index 492c485..e1e4b29 100644 --- a/external/engine/gamegui.h +++ b/src/engineGamegui.c @@ -1,29 +1,4 @@ -#ifndef GAMEGUI_H -#define GAMEGUI_H - -#include "sprite.h" -#include - -typedef enum { - NOT_CLICKED, - HOVER, - CLICKED -} ButtonState; - -typedef struct -{ - Sprite sprite; - Vector2 notClicked; - Vector2 hover; - Vector2 clicked; - bool isHovered; - bool isClicked; -} ImageButton; - -typedef struct -{ - Sprite sprite; -} ImageElement; +#include "engine.h" ImageButton CreateImageButton(ButtonState state, Texture2D *texture, const TextureAsset *asset, Vector2 *source, Vector2 *clicked, Vector2 *hover, Rectangle *destRec){ return (ImageButton){ @@ -95,5 +70,3 @@ void renderImageElement(ImageElement *e){ RenderSprite(&e->sprite); } - -#endif // GAMEGUI_H diff --git a/external/engine/gui.h b/src/engineGui.c similarity index 78% rename from external/engine/gui.h rename to src/engineGui.c index cd73a3a..6b9454e 100644 --- a/external/engine/gui.h +++ b/src/engineGui.c @@ -1,14 +1,6 @@ -#ifndef GUI_H -#define GUI_H - #define RAYGUI_IMPLEMENTATION -#include -typedef struct -{ - Rectangle rec; - char *text; -} Button; +#include "engine.h" Button initButton(char *text, Vector2 dimensions, Vector2 position) { @@ -29,4 +21,3 @@ void renderButton(Button *b) GuiButton(b->rec, b->text); } -#endif // GUI_H diff --git a/external/engine/input.h b/src/engineInput.c similarity index 81% rename from external/engine/input.h rename to src/engineInput.c index cf0be60..5a076ce 100644 --- a/external/engine/input.h +++ b/src/engineInput.c @@ -1,20 +1,4 @@ -#ifndef INPUT_H -#define INPUT_H - -#include - -typedef struct { - Vector2 screenPosition; - Vector2 worldPosition; - float zoomSpeed; - float minZoom; - float maxZoom; - float scaleFactor; - float wheelMove; - bool leftButton; - bool rightButton; - Texture2D cursorTexture; -} Mouse; +#include "engine.h" Mouse CreateMouse(float zoomSpeed, float minZoom, float maxZoom, Texture2D *texture){ HideCursor(); @@ -57,5 +41,3 @@ Vector2 GetDirectionVector(void){ if (Vector2Length(vector) > 0.0f) {vector = Vector2Normalize(vector); } return vector; } - -#endif //INPUT_H diff --git a/external/engine/object.h b/src/engineObject.c similarity index 93% rename from external/engine/object.h rename to src/engineObject.c index 73d5a03..3dbe7eb 100644 --- a/external/engine/object.h +++ b/src/engineObject.c @@ -1,19 +1,4 @@ -#ifndef OBJECT_H -#define OBJECT_H -#include "sprite.h" -#include "vector.h" - - -typedef struct { - Sprite sprite; - Vector2 position; -} Object; - -typedef struct { - Object *data; - const Object *prototype; - size_t count; -} ObjectArray; +#include "engine.h" ObjectArray CreateObjectArray(const Object *prototype, const size_t count) { ObjectArray objects = {0}; @@ -126,4 +111,3 @@ void RenderObjectArray(const ObjectArray *objects){ } } -#endif // OBJECT_H diff --git a/external/engine/physics.h b/src/enginePhysics.c similarity index 79% rename from external/engine/physics.h rename to src/enginePhysics.c index ff7824c..88ec39d 100644 --- a/external/engine/physics.h +++ b/src/enginePhysics.c @@ -1,15 +1,4 @@ -#ifndef PHYSICS_H -#define PHYSICS_H - -#include - -typedef struct -{ - Vector2 position; - Vector2 direction; - Vector2 velocity; - float speed; -} Physics; +#include "engine.h" void UpdatePhysicsDirection(Vector2 *direction, Vector2 vector) { @@ -38,4 +27,3 @@ void UpdatePhysics(Physics *physics, Vector2 direction) UpdatePhysicsPosition(&physics->position, &physics->velocity); } -#endif // PHYSICS_H diff --git a/external/engine/postfx.h b/src/enginePostfx.c similarity index 88% rename from external/engine/postfx.h rename to src/enginePostfx.c index 29921fb..04776aa 100644 --- a/external/engine/postfx.h +++ b/src/enginePostfx.c @@ -1,12 +1,4 @@ -#ifndef POSTFX_H -#define POSTFX_H - -typedef struct { - Shader shader; - int resolutionLoc; - int strengthLoc; - float strength; -} PostProcessing; +#include "engine.h" PostProcessing CreatePostFX(const char* shaderPath){ PostProcessing postFX = {0}; @@ -42,5 +34,3 @@ void UnloadPostFX(PostProcessing *postFX){ if (postFX->shader.id == 0) return; UnloadShader(postFX->shader); } - -#endif // POSTFX_H diff --git a/external/engine/soundtrack.h b/src/engineSoundtrack.c similarity index 81% rename from external/engine/soundtrack.h rename to src/engineSoundtrack.c index b790d18..f2f1c08 100644 --- a/external/engine/soundtrack.h +++ b/src/engineSoundtrack.c @@ -1,11 +1,4 @@ -#ifndef SOUNDTRACK_H -#define SOUNDTRACK_H - -typedef struct { - Music music; - bool playing; - bool paused; -} Soundtrack; +#include "engine.h" Soundtrack LoadSoundtrack(const char* musicPath){ Soundtrack soundtrack = { @@ -35,5 +28,3 @@ void UpdateSoundtrack(Soundtrack *soundtrack, bool playing){ } -#endif // SOUNDTRACK_H - diff --git a/external/engine/sprite.h b/src/engineSprite.c similarity index 86% rename from external/engine/sprite.h rename to src/engineSprite.c index 22f511b..eb07576 100644 --- a/external/engine/sprite.h +++ b/src/engineSprite.c @@ -1,18 +1,5 @@ -#ifndef SPRITE_H -#define SPRITE_H +#include "engine.h" -#include - -typedef struct -{ - Texture2D texture; - Rectangle sourceRec; - Rectangle destRec; - Vector2 frameSize; - Vector2 origin; - float rotation; - Color color; -} Sprite; void UpdateSpriteSourceRec(Sprite *sprite, const Vector2 *vector) { @@ -58,5 +45,3 @@ void PrintSprite(const Sprite *sprite) printf(" Sprite.rotation: %f\n", sprite->rotation); printf(" Sprite.color: r = %d, g = %d, b = %d, a = %d\n", sprite->color.r, sprite->color.g, sprite->color.b, sprite->color.a); } - -#endif // SPRITE_H diff --git a/external/engine/vector.h b/src/engineVector.c similarity index 74% rename from external/engine/vector.h rename to src/engineVector.c index dfb2056..fd67816 100644 --- a/external/engine/vector.h +++ b/src/engineVector.c @@ -1,10 +1,4 @@ -#ifndef VECTOR_H -#define VECTOR_H - -typedef struct { - Vector2 *data; - size_t count; -} Vector2Array; +#include "engine.h" bool IsVectorZero(Vector2 v) { float epsilon = 0.01f; @@ -18,4 +12,3 @@ Vector2 GetRandomVector(const Rectangle bounds) { }; } -#endif // VECTOR_H diff --git a/src/main.c b/src/main.c index 7e003ce..ee9ad5f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,4 @@ -#include -#include "app.h" +#include "appTypes.h" int main(void) {