From c27ada53525d2dba229f5921e6c2b336960ed1c8 Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Mon, 29 Jun 2026 18:13:31 +0200 Subject: [PATCH 01/13] feat: add Cross2D for Kreuzprodukt vector calculation --- include/engine.h | 239 +++++++++++++++++++++++---------------------- src/engineVector.c | 31 +++--- 2 files changed, 137 insertions(+), 133 deletions(-) diff --git a/include/engine.h b/include/engine.h index 6aa987d..3049ef7 100644 --- a/include/engine.h +++ b/include/engine.h @@ -1,190 +1,189 @@ #ifndef ENGINE_H #define ENGINE_H +#include +#include #include #include -#include #include -#include #include +#include #include -#include -typedef struct -{ - Texture2D texture; - Rectangle sourceRec; - Rectangle destRec; - Vector2 frameSize; - Vector2 origin; - float rotation; - Color color; +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; +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; + void **elements; + unsigned int count; + unsigned int capacity; } Array; typedef struct { - const char* path; - float frameWidth; - float frameHeight; - float rotation; + const char *path; + float frameWidth; + float frameHeight; + float rotation; } TextureAsset; typedef struct { - const char* path; + const char *path; } ShaderAsset; typedef struct { - const char* path; + const char *path; } SoundtrackAsset; typedef struct { - const char* path; + const char *path; } SoundAsset; typedef struct { - const TextureAsset *textureAssets; - const ShaderAsset *shaderAssets; - const SoundtrackAsset *soundtrackAssets; - const SoundAsset *soundAssets; + const TextureAsset *textureAssets; + const ShaderAsset *shaderAssets; + const SoundtrackAsset *soundtrackAssets; + const SoundAsset *soundAssets; } Assets; typedef struct { - char *path; - rini_config rini; + char *path; + rini_config rini; } Config; -typedef enum { - NOT_CLICKED, - HOVER, - CLICKED -} ButtonState; +typedef enum { NOT_CLICKED, HOVER, CLICKED } ButtonState; -typedef struct -{ - Sprite sprite; - Vector2 notClicked; - Vector2 hover; - Vector2 clicked; - bool isHovered; - bool isClicked; +typedef struct { + Sprite sprite; + Vector2 notClicked; + Vector2 hover; + Vector2 clicked; + bool isHovered; + bool isClicked; } ImageButton; -typedef struct -{ - Sprite sprite; +typedef struct { + Sprite sprite; } ImageElement; -typedef struct -{ - Rectangle rec; - char *text; +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; + 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; + Sprite sprite; + Vector2 position; } Object; typedef struct { - Object *data; - const Object *prototype; - size_t count; + Object *data; + const Object *prototype; + size_t count; } ObjectArray; -typedef struct -{ - Vector2 position; - Vector2 direction; - Vector2 velocity; - float speed; +typedef struct { + Vector2 position; + Vector2 direction; + Vector2 velocity; + float speed; + float weight; } Physics; typedef struct { - Shader shader; - int resolutionLoc; - int strengthLoc; - float strength; + Shader shader; + int resolutionLoc; + int strengthLoc; + float strength; } PostProcessing; typedef struct { - Music music; - bool playing; - bool paused; + Music music; + bool playing; + bool paused; } Soundtrack; typedef struct { - Vector2 *data; - size_t count; + Vector2 *data; + size_t count; } Vector2Array; typedef struct { - int width; - int height; - const char* title; + 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); +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* GetCamera(void); +Camera2D *GetCamera(void); Rectangle GetCameraRectangle(void); void CreateCamera(Vector2 playerPosition, float initZoom); void UpdateCameraTarget(Vector2 *position, const float smoothness); -void UpdateCameraZoom(const float *scaleFactor, const float *minZoom, const float *maxZoom); -void UpdateCamera2D(Vector2* position, Mouse* mouse); +void UpdateCameraZoom(const float *scaleFactor, const float *minZoom, + const float *maxZoom); +void UpdateCamera2D(Vector2 *position, Mouse *mouse); -void InitConfig(Config *config, const char* path); +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); +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 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 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); +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); @@ -193,18 +192,24 @@ 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); +Mouse CreateMouse(float zoomSpeed, float minZoom, float maxZoom, + Texture2D *texture); void UpdateMouseScreen(Mouse *mouse); void UpdateMouse(Mouse *mouse); 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); +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); Vector2 GetDirectionBetweenTwoVectors(Vector2 vec1, Vector2 vec2); @@ -215,12 +220,12 @@ void UpdatePhysicsPosition(Vector2 *position, Vector2 *velocity); void UpdatePhysicsSpeed(float *speed, float *newSpeed); void UpdatePhysics(Physics *physics, Vector2 direction); -PostProcessing CreatePostFX(const char* shaderPath); +PostProcessing CreatePostFX(const char *shaderPath); void UpdatePostFX(PostProcessing *postFX); void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target); void UnloadPostFX(PostProcessing *postFX); -Soundtrack LoadSoundtrack(const char* musicPath); +Soundtrack LoadSoundtrack(const char *musicPath); void UpdateSoundtrack(Soundtrack *soundtrack, bool playing); void UpdateSpriteSourceRec(Sprite *sprite, const Vector2 *vector); @@ -233,9 +238,9 @@ bool IsVectorZero(Vector2 v); Vector2 GetRandomVector(const Rectangle bounds); Vector2 RotationToVector2(float rotation); float Vector2ToRotation(Vector2 vec); +float Cross2D(Vector2 a, Vector2 b); Vector2 GetPositionInsideRectangle(Rectangle rec); Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max); -#endif //ENGINE_H - +#endif // ENGINE_H diff --git a/src/engineVector.c b/src/engineVector.c index 38a141f..40481ba 100644 --- a/src/engineVector.c +++ b/src/engineVector.c @@ -1,27 +1,26 @@ #include "engine.h" bool IsVectorZero(Vector2 v) { - float epsilon = 0.01f; - return (fabs(v.x) < epsilon && fabs(v.y) < epsilon); + float epsilon = 0.01f; + return (fabs(v.x) < epsilon && fabs(v.y) < epsilon); } Vector2 GetRandomVector(const Rectangle bounds) { - return (Vector2){ - bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width, - bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height - }; + return (Vector2){ + bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width, + bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height}; } -Vector2 RotationToVector2(float rotation) -{ - float rad = rotation * (PI / 180.0f); - Vector2 vec = { cosf(rad), sinf(rad) }; - return vec; +Vector2 RotationToVector2(float rotation) { + float rad = rotation * (PI / 180.0f); + Vector2 vec = {cosf(rad), sinf(rad)}; + return vec; } -float Vector2ToRotation(Vector2 vec) -{ - float rad = atan2f(vec.y, vec.x); - float deg = rad * (180.0f / PI); - return deg; +float Vector2ToRotation(Vector2 vec) { + float rad = atan2f(vec.y, vec.x); + float deg = rad * (180.0f / PI); + return deg; } + +float Cross2D(Vector2 a, Vector2 b) { return a.x * b.y - a.y * b.x; } From 199634545922c6fef5dc202ec9b0c5259ee41e21 Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Mon, 29 Jun 2026 18:15:31 +0200 Subject: [PATCH 02/13] feat: add collisionhandling --- include/app.h | 4 ++ src/appGame.c | 3 + src/appGameCollisions.c | 75 ++++++++++++++++++++++ src/appGameEnemies.c | 136 +++++++++++++++++++++------------------- src/appGamePlayer.c | 3 +- 5 files changed, 156 insertions(+), 65 deletions(-) create mode 100644 src/appGameCollisions.c diff --git a/include/app.h b/include/app.h index 06cbea5..7ece17a 100644 --- a/include/app.h +++ b/include/app.h @@ -247,6 +247,10 @@ Projectiles CreateProjectiles(void); void UpdateProjectiles(Projectiles *projectiles); void RenderProjectiles(Projectiles *projectiles); +void CheckPlayerEnemyCollisions(Player *player, Enemies *enemies); +void CheckEnemyEnemyCollisions(Enemies *enemies); +void CheckProjectileEnemyCollisions(Projectiles *projectiles, Enemies *enemies); + void InitGame(App *app); void UpdateGame(App *app); void RenderComponents(App *app); diff --git a/src/appGame.c b/src/appGame.c index 15ba635..e6f8b9e 100644 --- a/src/appGame.c +++ b/src/appGame.c @@ -69,6 +69,9 @@ void UpdateGame(App *app) { UpdateEnemies(&g->enemies); UpdateIslands(&g->islands); UpdateProjectiles(&g->projectiles); + CheckPlayerEnemyCollisions(GetPlayer(), &app->game.enemies); + CheckEnemyEnemyCollisions(&app->game.enemies); + CheckProjectileEnemyCollisions(&app->game.projectiles, &app->game.enemies); } void RenderComponents(App *app) { diff --git a/src/appGameCollisions.c b/src/appGameCollisions.c new file mode 100644 index 0000000..e109769 --- /dev/null +++ b/src/appGameCollisions.c @@ -0,0 +1,75 @@ +#include "app.h" +#include + +void CheckPlayerEnemyCollisions(Player *player, Enemies *enemies) { + for (int i = 0; i < enemies->count; i++) { + + Vector2 playerPos = player->physics.position; + Vector2 enemiesPos = enemies->physics[i].position; + + float playerRadius = 8.0f; + float enemiesRadius = 8.0f; + float minDist = playerRadius + enemiesRadius; + + if (CheckCollisionCircles(playerPos, playerRadius, enemiesPos, + enemiesRadius)) { + float dist = GetDistanceBetweenTwoVectors(playerPos, enemiesPos); + float overlap = minDist - dist; + + if (dist > 0.0f) { + Vector2 collisionVector = GetDirectionBetweenTwoVectors( + enemies->physics[i].position, player->physics.position); + player->physics.position.x += collisionVector.x * overlap; + player->physics.position.y += collisionVector.y * overlap; + Vector2 forward = RotationToVector2(player->rotation - 90.0f); + float side = Cross2D(forward, collisionVector); + player->rotation += side * 120.0f * GetFrameTime(); + } + } + } +} +void CheckEnemyEnemyCollisions(Enemies *enemies) { + for (int a = 0; a < enemies->count; a++) { + for (int b = a + 1; b < enemies->count; b++) { + + Vector2 posA = enemies->physics[a].position; + Vector2 posB = enemies->physics[b].position; + + float enemiesRadius = 8.0f; + float minDist = enemiesRadius * 2; + + if (CheckCollisionCircles(posA, enemiesRadius, posB, enemiesRadius)) { + + Vector2 collisionVectorA = GetDirectionBetweenTwoVectors(posB, posA); + Vector2 collisionVectorB = GetDirectionBetweenTwoVectors(posA, posB); + float dist = GetDistanceBetweenTwoVectors(posA, posB); + float overlap = minDist - dist; + + if (dist > 0.0f) { + enemies->physics[a].position.x += collisionVectorA.x * overlap * 0.5f; + enemies->physics[a].position.y += collisionVectorA.y * overlap * 0.5f; + + enemies->physics[b].position.x += collisionVectorB.x * overlap * 0.5f; + enemies->physics[b].position.y += collisionVectorB.y * overlap * 0.5f; + + Vector2 forwardA = + RotationToVector2(enemies->sprite[a].rotation - 90.0f); + Vector2 forwardB = + RotationToVector2(enemies->sprite[b].rotation - 90.0f); + float sideA = Cross2D(forwardA, collisionVectorA); + float sideB = Cross2D(forwardB, collisionVectorB); + enemies->sprite[a].rotation += sideA * 120.0f * GetFrameTime(); + enemies->sprite[b].rotation += sideB * 120.0f * GetFrameTime(); + } + } + } + } +} + +void CheckProjectileEnemyCollisions(Projectiles *projectiles, + Enemies *enemies) { + for (int i = 0; i < projectiles->count; i++) { + for (int j = 0; j < enemies->count; j++) { + } + } +} diff --git a/src/appGameEnemies.c b/src/appGameEnemies.c index 91c436b..9519cb0 100644 --- a/src/appGameEnemies.c +++ b/src/appGameEnemies.c @@ -1,81 +1,89 @@ #include "app.h" const TextureAsset enemiesTextureAssets[ENEMIES_TEX_COUNT] = { - {"assets/ship_start.png", 16.0f, 16.0f, 90.0f}}; + {"assets/ship_start.png", 16.0f, 16.0f, 90.0f} +}; -Enemies CreateEnemies(void) { - Enemies enemies = {.count = MAX_ENEMIES}; - TextureAsset textureAsset = enemiesTextureAssets[BOAT]; - Texture2D texture = LoadTexture(textureAsset.path); - float frameWidth = textureAsset.frameWidth; - float rotation = textureAsset.rotation; +Enemies CreateEnemies(void){ + Enemies enemies = {.count = MAX_ENEMIES}; + TextureAsset textureAsset = enemiesTextureAssets[BOAT]; + Texture2D texture = LoadTexture(textureAsset.path); + float frameWidth = textureAsset.frameWidth; + float rotation = textureAsset.rotation; - for (int i = 0; i < enemies.count; i++) { - enemies.sprite[i] = (Sprite){ - .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}; + for (int i = 0; i < enemies.count; i++) + { + enemies.sprite[i] = (Sprite){ + .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 + }; - enemies.animation[i] = (Animation){.state = 1, - .currentFrame = 0, - .maxFrame = 2, - .framesCounter = 0, - .framesSpeed = 2.0f, - .animTimer = 0.0f}; + enemies.animation[i] = (Animation){ + .state = 1, + .currentFrame = 0, + .maxFrame = 2, + .framesCounter = 0, + .framesSpeed = 2.0f, + .animTimer = 0.0f + }; - Rectangle cameraRec = GetCameraRectangle(); + Rectangle cameraRec = GetCameraRectangle(); - enemies.physics[i] = - (Physics){.position = GetPositionOutsideRectangle(cameraRec, 100, 1000), - .direction = (Vector2){0.0f, 0.0f}, - .speed = 5.0f}; + enemies.physics[i] = (Physics){ + .position = GetPositionOutsideRectangle(cameraRec, 100, 1000), + .direction = (Vector2){0.0f, 0.0f}, + .speed = 5.0f, + .weight = 5.0f + }; - enemies.arrived[i] = true; - enemies.destPos[i] = (Vector2){0.0f, 0.0f}; - } + enemies.arrived[i] = true; + enemies.destPos[i] = (Vector2){0.0f, 0.0f}; - return enemies; + } + + return enemies; } -void UpdateEnemies(Enemies *enemies) { - Camera2D *camera = GetCamera(); - Rectangle cameraRec = GetCameraRectangle(); +void UpdateEnemies(Enemies *enemies){ + Camera2D *camera = GetCamera(); + Rectangle cameraRec = GetCameraRectangle(); - for (int i = 0; i < enemies->count; i++) { - if (enemies->arrived[i]) { - enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000); - enemies->arrived[i] = false; - } - if (CheckCollisionPointCircle(enemies->physics[i].position, - enemies->destPos[i], 10.0F)) { - enemies->arrived[i] = true; - } - if (GetDistanceBetweenTwoVectors(enemies->physics[i].position, - camera->target) > 1000) { - enemies->physics[i].position = - GetPositionOutsideRectangle(cameraRec, 100, 1000); - } - Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position, - enemies->destPos[i]); - UpdatePhysics(&enemies->physics[i], dir); - UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position); - float rotation = Vector2ToRotation(dir); - UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f); - UpdateAnimation(&enemies->animation[i], GetFrameTime()); - UpdateSpriteSourceRec(&enemies->sprite[i], - &(Vector2){enemies->sprite[i].frameSize.x * - enemies->animation[i].currentFrame, - enemies->sprite[i].frameSize.y}); - } + for (int i = 0; i < enemies->count; i++) + { + if(enemies->arrived[i]) + { + enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000); + enemies->arrived[i] = false; + } + if(CheckCollisionPointCircle(enemies->physics[i].position, enemies->destPos[i], 10.0F)) + { + enemies->arrived[i] = true; + } + if(GetDistanceBetweenTwoVectors(enemies->physics[i].position, camera->target) > 1000){ + enemies->physics[i].position = GetPositionOutsideRectangle(cameraRec, 100, 1000); + } + Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position, enemies->destPos[i]); + UpdatePhysics(&enemies->physics[i], dir); + UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position); + float rotation = Vector2ToRotation(dir); + UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f); + UpdateAnimation(&enemies->animation[i], GetFrameTime()); + UpdateSpriteSourceRec(&enemies->sprite[i], &(Vector2){enemies->sprite[i].frameSize.x * enemies->animation[i].currentFrame, enemies->sprite[i].frameSize.y}); + } } -void RenderEnemies(Enemies *enemies) { +void RenderEnemies(Enemies *enemies){ + + for (int i = 0; i < enemies->count; i++) + { + RenderSprite(&enemies->sprite[i]); + } - for (int i = 0; i < enemies->count; i++) { - RenderSprite(&enemies->sprite[i]); - } } + + diff --git a/src/appGamePlayer.c b/src/appGamePlayer.c index 93608cb..cadccf5 100644 --- a/src/appGamePlayer.c +++ b/src/appGamePlayer.c @@ -57,7 +57,8 @@ void CreatePlayer(void) Physics playerPhysics = { .position = (Vector2){0.0f,0.0f}, .direction = (Vector2){0.0f, 0.0f}, - .speed = playerSpeeds[ANCHOR] + .speed = playerSpeeds[ANCHOR], + .weight = 10.0f }; Player* player = GetPlayer(); From d4754f6f78b56a5e94ff91a6ff08ebd26eaf6f11 Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Mon, 29 Jun 2026 18:15:44 +0200 Subject: [PATCH 03/13] feat: add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ From c9fa6e6e839474c7cc38a3dbd588562d507a246e Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Sat, 4 Jul 2026 23:47:42 +0200 Subject: [PATCH 04/13] feat: add projectile collision --- include/app.h | 6 +++--- src/appGame.c | 6 +++--- src/appGameCollisions.c | 47 ++++++++++++++++++++++++++--------------- src/appGameShip.c | 7 ------ 4 files changed, 36 insertions(+), 30 deletions(-) delete mode 100644 src/appGameShip.c diff --git a/include/app.h b/include/app.h index 7ece17a..160240e 100644 --- a/include/app.h +++ b/include/app.h @@ -247,9 +247,9 @@ Projectiles CreateProjectiles(void); void UpdateProjectiles(Projectiles *projectiles); void RenderProjectiles(Projectiles *projectiles); -void CheckPlayerEnemyCollisions(Player *player, Enemies *enemies); -void CheckEnemyEnemyCollisions(Enemies *enemies); -void CheckProjectileEnemyCollisions(Projectiles *projectiles, Enemies *enemies); +void CheckPlayerCollisions(Player *player, Enemies *enemies); +void CheckEnemyCollisions(Enemies *enemies); +void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, Player *player); void InitGame(App *app); void UpdateGame(App *app); diff --git a/src/appGame.c b/src/appGame.c index e6f8b9e..ec1d939 100644 --- a/src/appGame.c +++ b/src/appGame.c @@ -69,9 +69,9 @@ void UpdateGame(App *app) { UpdateEnemies(&g->enemies); UpdateIslands(&g->islands); UpdateProjectiles(&g->projectiles); - CheckPlayerEnemyCollisions(GetPlayer(), &app->game.enemies); - CheckEnemyEnemyCollisions(&app->game.enemies); - CheckProjectileEnemyCollisions(&app->game.projectiles, &app->game.enemies); + CheckPlayerCollisions(GetPlayer(), &app->game.enemies); + CheckEnemyCollisions(&app->game.enemies); + CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies, GetPlayer()); } void RenderComponents(App *app) { diff --git a/src/appGameCollisions.c b/src/appGameCollisions.c index e109769..259873a 100644 --- a/src/appGameCollisions.c +++ b/src/appGameCollisions.c @@ -1,24 +1,25 @@ #include "app.h" #include -void CheckPlayerEnemyCollisions(Player *player, Enemies *enemies) { +float playerCollisionRadius = 8.0f; +float enemiesCollisionRadius = 8.0f; +float projectilesCollisionRadius = 2.0f; + +void CheckPlayerCollisions(Player *player, Enemies *enemies) { for (int i = 0; i < enemies->count; i++) { Vector2 playerPos = player->physics.position; Vector2 enemiesPos = enemies->physics[i].position; - float playerRadius = 8.0f; - float enemiesRadius = 8.0f; - float minDist = playerRadius + enemiesRadius; + float minDist = playerCollisionRadius + enemiesCollisionRadius; - if (CheckCollisionCircles(playerPos, playerRadius, enemiesPos, - enemiesRadius)) { + if (CheckCollisionCircles(playerPos, playerCollisionRadius, enemiesPos, + enemiesCollisionRadius)) { float dist = GetDistanceBetweenTwoVectors(playerPos, enemiesPos); float overlap = minDist - dist; if (dist > 0.0f) { - Vector2 collisionVector = GetDirectionBetweenTwoVectors( - enemies->physics[i].position, player->physics.position); + Vector2 collisionVector = GetDirectionBetweenTwoVectors(enemies->physics[i].position, player->physics.position); player->physics.position.x += collisionVector.x * overlap; player->physics.position.y += collisionVector.y * overlap; Vector2 forward = RotationToVector2(player->rotation - 90.0f); @@ -28,17 +29,17 @@ void CheckPlayerEnemyCollisions(Player *player, Enemies *enemies) { } } } -void CheckEnemyEnemyCollisions(Enemies *enemies) { + +void CheckEnemyCollisions(Enemies *enemies) { for (int a = 0; a < enemies->count; a++) { for (int b = a + 1; b < enemies->count; b++) { Vector2 posA = enemies->physics[a].position; Vector2 posB = enemies->physics[b].position; - float enemiesRadius = 8.0f; - float minDist = enemiesRadius * 2; + float minDist = enemiesCollisionRadius * 2; - if (CheckCollisionCircles(posA, enemiesRadius, posB, enemiesRadius)) { + if (CheckCollisionCircles(posA, enemiesCollisionRadius, posB, enemiesCollisionRadius)) { Vector2 collisionVectorA = GetDirectionBetweenTwoVectors(posB, posA); Vector2 collisionVectorB = GetDirectionBetweenTwoVectors(posA, posB); @@ -66,10 +67,22 @@ void CheckEnemyEnemyCollisions(Enemies *enemies) { } } -void CheckProjectileEnemyCollisions(Projectiles *projectiles, - Enemies *enemies) { - for (int i = 0; i < projectiles->count; i++) { - for (int j = 0; j < enemies->count; j++) { +void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, Player *player) { + for (int i = 0; i < projectiles->count; i++) { + for (int j = 0; j < enemies->count; j++) { + Vector2 projectilePos = projectiles->physics[i].position; + Vector2 enemyPos = enemies->physics[j].position; + Vector2 playerPos = player->physics.position; + + if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, enemyPos, enemiesCollisionRadius)) { + Rectangle cameraRec = GetCameraRectangle(); + enemies->physics[j].position = GetPositionOutsideRectangle(cameraRec, 100, 1000); + } + + if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, playerPos, playerCollisionRadius)){ + // End screen or player health reduction here + } + + } } - } } diff --git a/src/appGameShip.c b/src/appGameShip.c deleted file mode 100644 index 0487067..0000000 --- a/src/appGameShip.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "app.h" - -Ship InitShip(int shipID) { - Config config; - InitConfig(&config, "config/ships.ini"); - Ship ship; -} From a4289a21aa6848b84cfdfdc791d3c88355e03c5c Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Sat, 4 Jul 2026 23:52:53 +0200 Subject: [PATCH 05/13] docs: add todays notes --- notes.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 notes.md diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..1ab61e2 --- /dev/null +++ b/notes.md @@ -0,0 +1,10 @@ +# 04.07.26 + +What i can do next: + +- Player health bar +- Enemy shooting +- Enemy Projectile -> player collisions effect +- Player Projectile -> Enemy collision effect +- End screen or something + From cc42a45f685454251ecc67a16ada3aa2801d164b Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:17:06 +0200 Subject: [PATCH 06/13] feat/refactor: player health and overlay display --- src/appGame.c | 8 ++------ src/appGameCollisions.c | 1 - src/appGameOverlay.c | 17 +++++++++++++++++ src/appGamePlayer.c | 10 ++++++++-- src/appGameProjectiles.c | 1 - 5 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/appGameOverlay.c diff --git a/src/appGame.c b/src/appGame.c index ec1d939..8ee8508 100644 --- a/src/appGame.c +++ b/src/appGame.c @@ -93,13 +93,9 @@ void RenderGame(App *app) { 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); + RenderOverlay(&g->mouse); EndTextureMode(); - + BeginDrawing(); ClearBackground(BLACK); for (int i = 0; i < SHADER_COUNT; i++) { diff --git a/src/appGameCollisions.c b/src/appGameCollisions.c index 259873a..ecc65af 100644 --- a/src/appGameCollisions.c +++ b/src/appGameCollisions.c @@ -1,5 +1,4 @@ #include "app.h" -#include float playerCollisionRadius = 8.0f; float enemiesCollisionRadius = 8.0f; diff --git a/src/appGameOverlay.c b/src/appGameOverlay.c new file mode 100644 index 0000000..bfd2843 --- /dev/null +++ b/src/appGameOverlay.c @@ -0,0 +1,17 @@ +#include "app.h" +#include "raylib.h" +#include + +void RenderOverlay(Mouse *mouse) { + + // Health + Player *player = GetPlayer(); + const char *healthText = TextFormat("%d", player->health); + DrawText(healthText, 0, 0, 25, WHITE); + + // Mouse + Rectangle mouseRectangle = (Rectangle){0, 0, mouse->cursorTexture.width, + mouse->cursorTexture.height}; + DrawTextureRec(mouse->cursorTexture, mouseRectangle, mouse->screenPosition, + WHITE); +} diff --git a/src/appGamePlayer.c b/src/appGamePlayer.c index cadccf5..a3d07ed 100644 --- a/src/appGamePlayer.c +++ b/src/appGamePlayer.c @@ -10,6 +10,8 @@ float playerSpeeds[SPEED_COUNT] = { 10.0f }; +Config config; + playerSpeedID GetPlayerSpeedID(float speed) { for (int i = 0; i < SPEED_COUNT; i++) { if (playerSpeeds[i] == speed) { @@ -27,12 +29,15 @@ Player* GetPlayer(void) void CreatePlayer(void) { + + InitConfig(&config, "config/player.ini"); + int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX"); + TextureAsset startShipAsset = playerTextureAssets[START_SHIP]; Texture2D texture = LoadTexture(startShipAsset.path); float frameWidth = startShipAsset.frameWidth; float rotation = startShipAsset.rotation; - Sprite playerSprite = { .texture = texture, @@ -66,7 +71,8 @@ void CreatePlayer(void) .sprite = playerSprite, .animation = playerAnimation, .physics = playerPhysics, - .rotation = rotation + .rotation = rotation, + .health = PLAYER_HEALTH_MAX }; } diff --git a/src/appGameProjectiles.c b/src/appGameProjectiles.c index c71b472..9ceeabe 100644 --- a/src/appGameProjectiles.c +++ b/src/appGameProjectiles.c @@ -61,7 +61,6 @@ void UpdateProjectiles(Projectiles *projectiles) { void RenderProjectiles(Projectiles *projectiles) { for (int i = 0; i < projectiles->count; i++) { - printf("Projectile Active: %d", projectiles->active[i]); if (projectiles->active[i] == true) { DrawCircle(projectiles->physics[i].position.x, projectiles->physics[i].position.y, projectiles->radius[i], From 3995dce1ef2d885ba7b044b9aeb7e11143445ef6 Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:17:26 +0200 Subject: [PATCH 07/13] feat/refactor: player health and overlay display --- include/app.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/app.h b/include/app.h index 160240e..e413cea 100644 --- a/include/app.h +++ b/include/app.h @@ -100,6 +100,7 @@ typedef struct { Animation animation; Physics physics; float rotation; + int health; } Player; typedef enum { BOAT, ENEMIES_TEX_COUNT } enemiesTextureID; @@ -254,6 +255,7 @@ void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, Playe void InitGame(App *app); void UpdateGame(App *app); void RenderComponents(App *app); +void RenderOverlay(Mouse *mouse); void RenderGame(App *app); void CleanupGame(App *app); From a9702a92b759126c48254c015d6a58d69691e85f Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:19:29 +0200 Subject: [PATCH 08/13] fix: compile commands are ignored and makefile seperates cflags and libs --- .gitignore | 1 + Makefile | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e660fd9..9301a2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bin/ +compile_commands.json diff --git a/Makefile b/Makefile index 9491e23..cb7822b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,10 @@ C_FLAGS = \ $(C_FLAG_NO_UNKNOWN_PRAGMAS) # INCLUDE FLGAS -INCLUDE_FLAGS = -Iinclude +INCLUDE_FLAGS = \ + -Iinclude \ + $(EXTERNAL_FLAGS) \ + $(RAYLIB_CFLAGS) # EXTERNAL FLAGS EXTERNAL_RAYGUI = -Iexternal/raygui @@ -34,11 +37,13 @@ EXTERNAL_FLAGS = \ ifeq ($(OS), Windows_NT) SRC = $(wildcard src\*.c) TARGET = bin\win\game.exe - RAYLIB_FLAGS = -I%RAYLIB% -L%RAYLIB% -lraylib -lopengl32 -lgdi32 -lwinmm + RAYLIB_CFLAGS = -I%RAYLIB% + RAYLIB_LIBS = -L%RAYLIB% -lraylib -lopengl32 -lgdi32 -lwinmm else SRC = $(wildcard src/*.c) TARGET = bin/unix/game - RAYLIB_FLAGS = $(shell pkg-config --libs --cflags raylib) -lm + RAYLIB_CFLAGS = $(shell pkg-config --cflags raylib) + RAYLIB_LIBS = $(shell pkg-config --libs raylib) -lm endif # CREATE BIN DIR @@ -46,7 +51,10 @@ $(shell mkdir -p bin/unix bin/win) # COMMANDS build: $(SRC) - $(COMPILER) $(SRC) -o $(TARGET) $(C_FLAGS) $(INCLUDE_FLAGS) $(EXTERNAL_FLAGS) $(RAYLIB_FLAGS) + $(COMPILER) $(SRC) -o $(TARGET) \ + $(C_FLAGS) \ + $(INCLUDE_FLAGS) \ + $(RAYLIB_LIBS) clean: rm -f $(TARGET) From 502e3698248b79091d2383ea7247b30bb3bb8b66 Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:20:51 +0200 Subject: [PATCH 09/13] Stop tracking compile_commands.json --- compile_commands.json | 684 ------------------------------------------ config/player.ini | 1 + 2 files changed, 1 insertion(+), 684 deletions(-) delete mode 100644 compile_commands.json create mode 100644 config/player.ini diff --git a/compile_commands.json b/compile_commands.json deleted file mode 100644 index 7c4ab3f..0000000 --- a/compile_commands.json +++ /dev/null @@ -1,684 +0,0 @@ -[ - { - "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/player.ini b/config/player.ini new file mode 100644 index 0000000..6b06718 --- /dev/null +++ b/config/player.ini @@ -0,0 +1 @@ +HEALTH_MAX = 100 From 5cae2e79d5e05cd4354d48f7b2eab47ba8e5864e Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:21:17 +0200 Subject: [PATCH 10/13] feat: add data files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9301a2c..f37a446 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/ compile_commands.json +*.data From ede02b98ebd9298405648b0337ae05513f02fd39 Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:36:17 +0200 Subject: [PATCH 11/13] feat: add player health reduction on collision --- src/appGameCollisions.c | 52 ++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/appGameCollisions.c b/src/appGameCollisions.c index ecc65af..dde1db2 100644 --- a/src/appGameCollisions.c +++ b/src/appGameCollisions.c @@ -2,7 +2,7 @@ float playerCollisionRadius = 8.0f; float enemiesCollisionRadius = 8.0f; -float projectilesCollisionRadius = 2.0f; +float projectilesCollisionRadius = 1.0f; void CheckPlayerCollisions(Player *player, Enemies *enemies) { for (int i = 0; i < enemies->count; i++) { @@ -14,11 +14,15 @@ void CheckPlayerCollisions(Player *player, Enemies *enemies) { if (CheckCollisionCircles(playerPos, playerCollisionRadius, enemiesPos, enemiesCollisionRadius)) { + + player->health -= 1; + float dist = GetDistanceBetweenTwoVectors(playerPos, enemiesPos); float overlap = minDist - dist; if (dist > 0.0f) { - Vector2 collisionVector = GetDirectionBetweenTwoVectors(enemies->physics[i].position, player->physics.position); + Vector2 collisionVector = GetDirectionBetweenTwoVectors( + enemies->physics[i].position, player->physics.position); player->physics.position.x += collisionVector.x * overlap; player->physics.position.y += collisionVector.y * overlap; Vector2 forward = RotationToVector2(player->rotation - 90.0f); @@ -38,7 +42,8 @@ void CheckEnemyCollisions(Enemies *enemies) { float minDist = enemiesCollisionRadius * 2; - if (CheckCollisionCircles(posA, enemiesCollisionRadius, posB, enemiesCollisionRadius)) { + if (CheckCollisionCircles(posA, enemiesCollisionRadius, posB, + enemiesCollisionRadius)) { Vector2 collisionVectorA = GetDirectionBetweenTwoVectors(posB, posA); Vector2 collisionVectorB = GetDirectionBetweenTwoVectors(posA, posB); @@ -66,22 +71,31 @@ void CheckEnemyCollisions(Enemies *enemies) { } } -void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, Player *player) { - for (int i = 0; i < projectiles->count; i++) { - for (int j = 0; j < enemies->count; j++) { - Vector2 projectilePos = projectiles->physics[i].position; - Vector2 enemyPos = enemies->physics[j].position; - Vector2 playerPos = player->physics.position; +void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, + Player *player) { + for (int i = 0; i < projectiles->count; i++) { + if (!projectiles->active[i]) + continue; + Vector2 projectilePos = projectiles->physics[i].position; + for (int j = 0; j < enemies->count; j++) { + Vector2 enemyPos = enemies->physics[j].position; - if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, enemyPos, enemiesCollisionRadius)) { - Rectangle cameraRec = GetCameraRectangle(); - enemies->physics[j].position = GetPositionOutsideRectangle(cameraRec, 100, 1000); - } - - if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, playerPos, playerCollisionRadius)){ - // End screen or player health reduction here - } - - } + if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, + enemyPos, enemiesCollisionRadius)) { + Rectangle cameraRec = GetCameraRectangle(); + enemies->physics[j].position = + GetPositionOutsideRectangle(cameraRec, 100, 1000); + } } + + if (!projectiles->active[i]) + continue; + + Vector2 playerPos = player->physics.position; + if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, + playerPos, playerCollisionRadius)) { + + player->health -= 20; + } + } } From 354c8b8a5da994067d50db7ee2a76202dae36846 Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:36:48 +0200 Subject: [PATCH 12/13] notes --- notes.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notes.md b/notes.md index 1ab61e2..a32ee96 100644 --- a/notes.md +++ b/notes.md @@ -3,8 +3,9 @@ What i can do next: - Player health bar +- Enemy health - Enemy shooting - Enemy Projectile -> player collisions effect -- Player Projectile -> Enemy collision effect +- Player Projectile -> Enemy collision effect - End screen or something - +- Shader for foam when driving From a167e38d3c829f2d8c52ef97fea4b67d561fa119 Mon Sep 17 00:00:00 2001 From: huaqo Date: Sun, 5 Jul 2026 20:57:17 +0200 Subject: [PATCH 13/13] feat: add player gold --- config/player.ini | 1 + include/app.h | 4 +- src/appGameCollisions.c | 1 + src/appGameOverlay.c | 6 +- src/appGamePlayer.c | 177 ++++++++++++++++++---------------------- 5 files changed, 87 insertions(+), 102 deletions(-) diff --git a/config/player.ini b/config/player.ini index 6b06718..9ad7fc6 100644 --- a/config/player.ini +++ b/config/player.ini @@ -1 +1,2 @@ HEALTH_MAX = 100 +START_GOLD = 0 diff --git a/include/app.h b/include/app.h index e413cea..1065b2e 100644 --- a/include/app.h +++ b/include/app.h @@ -101,6 +101,7 @@ typedef struct { Physics physics; float rotation; int health; + int gold; } Player; typedef enum { BOAT, ENEMIES_TEX_COUNT } enemiesTextureID; @@ -250,7 +251,8 @@ void RenderProjectiles(Projectiles *projectiles); void CheckPlayerCollisions(Player *player, Enemies *enemies); void CheckEnemyCollisions(Enemies *enemies); -void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, Player *player); +void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, + Player *player); void InitGame(App *app); void UpdateGame(App *app); diff --git a/src/appGameCollisions.c b/src/appGameCollisions.c index dde1db2..d42b723 100644 --- a/src/appGameCollisions.c +++ b/src/appGameCollisions.c @@ -82,6 +82,7 @@ void CheckProjectileCollisions(Projectiles *projectiles, Enemies *enemies, if (CheckCollisionCircles(projectilePos, projectilesCollisionRadius, enemyPos, enemiesCollisionRadius)) { + player->gold += 20; Rectangle cameraRec = GetCameraRectangle(); enemies->physics[j].position = GetPositionOutsideRectangle(cameraRec, 100, 1000); diff --git a/src/appGameOverlay.c b/src/appGameOverlay.c index bfd2843..b5b87f1 100644 --- a/src/appGameOverlay.c +++ b/src/appGameOverlay.c @@ -6,8 +6,10 @@ void RenderOverlay(Mouse *mouse) { // Health Player *player = GetPlayer(); - const char *healthText = TextFormat("%d", player->health); - DrawText(healthText, 0, 0, 25, WHITE); + const char *text = TextFormat("Health: %i\n" + "Gold: %i\n", + player->health, player->gold); + DrawText(text, 0, 0, 25, WHITE); // Mouse Rectangle mouseRectangle = (Rectangle){0, 0, mouse->cursorTexture.width, diff --git a/src/appGamePlayer.c b/src/appGamePlayer.c index a3d07ed..de376c5 100644 --- a/src/appGamePlayer.c +++ b/src/appGamePlayer.c @@ -1,135 +1,114 @@ #include "app.h" +#include "engine.h" const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = { - {"assets/ship_start.png", 16.0f, 16.0f, 0.0f} -}; + {"assets/ship_start.png", 16.0f, 16.0f, 0.0f}}; -float playerSpeeds[SPEED_COUNT] = { - 0.0f, - 5.0f, - 10.0f -}; +float playerSpeeds[SPEED_COUNT] = {0.0f, 5.0f, 10.0f}; Config config; playerSpeedID GetPlayerSpeedID(float speed) { - for (int i = 0; i < SPEED_COUNT; i++) { - if (playerSpeeds[i] == speed) { - return (playerSpeedID)i; - } + for (int i = 0; i < SPEED_COUNT; i++) { + if (playerSpeeds[i] == speed) { + return (playerSpeedID)i; } - return ANCHOR; + } + return ANCHOR; } -Player* GetPlayer(void) -{ - static Player player; - return &player; +Player *GetPlayer(void) { + static Player player; + return &player; } -void CreatePlayer(void) -{ +void CreatePlayer(void) { InitConfig(&config, "config/player.ini"); int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX"); + int START_GOLD = GetConfigInt(&config, "START_GOLD"); - TextureAsset startShipAsset = playerTextureAssets[START_SHIP]; - - Texture2D texture = LoadTexture(startShipAsset.path); - float frameWidth = startShipAsset.frameWidth; - float rotation = startShipAsset.rotation; + TextureAsset startShipAsset = playerTextureAssets[START_SHIP]; - Sprite playerSprite = { - .texture = texture, - .frameSize = {frameWidth, frameWidth}, - .sourceRec = {0.0f, 0.0f, frameWidth, frameWidth}, - .destRec = {0.0f, 0.0f, frameWidth, frameWidth}, - .origin = {frameWidth / 2, frameWidth / 2}, - .rotation = rotation, - .color = WHITE - }; + Texture2D texture = LoadTexture(startShipAsset.path); + float frameWidth = startShipAsset.frameWidth; + float rotation = startShipAsset.rotation; - Animation playerAnimation = { - .state = 1, - .currentFrame = 0, - .maxFrame = 3, - .framesCounter = 0, - .framesSpeed = 0.0f, - .animTimer = 0.0f - }; + Sprite playerSprite = {.texture = texture, + .frameSize = {frameWidth, frameWidth}, + .sourceRec = {0.0f, 0.0f, frameWidth, frameWidth}, + .destRec = {0.0f, 0.0f, frameWidth, frameWidth}, + .origin = {frameWidth / 2, frameWidth / 2}, + .rotation = rotation, + .color = WHITE}; + Animation playerAnimation = {.state = 1, + .currentFrame = 0, + .maxFrame = 3, + .framesCounter = 0, + .framesSpeed = 0.0f, + .animTimer = 0.0f}; - Physics playerPhysics = { - .position = (Vector2){0.0f,0.0f}, - .direction = (Vector2){0.0f, 0.0f}, - .speed = playerSpeeds[ANCHOR], - .weight = 10.0f - }; - - Player* player = GetPlayer(); - *player = (Player){ - .sprite = playerSprite, - .animation = playerAnimation, - .physics = playerPhysics, - .rotation = rotation, - .health = PLAYER_HEALTH_MAX - }; + Physics playerPhysics = {.position = (Vector2){0.0f, 0.0f}, + .direction = (Vector2){0.0f, 0.0f}, + .speed = playerSpeeds[ANCHOR], + .weight = 10.0f}; + Player *player = GetPlayer(); + *player = (Player){.sprite = playerSprite, + .animation = playerAnimation, + .physics = playerPhysics, + .rotation = rotation, + .health = PLAYER_HEALTH_MAX, + .gold = START_GOLD}; } -void UpdatePlayer(void) -{ - Player* player = GetPlayer(); - if(IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)){ - if(player->physics.speed < playerSpeeds[FAST_AHEAD]){ - if(player->physics.speed < playerSpeeds[SLOW_AHEAD]){ - player->physics.speed = playerSpeeds[SLOW_AHEAD]; - } - else { - player->physics.speed = playerSpeeds[FAST_AHEAD]; - } - } - } +void UpdatePlayer(void) { + Player *player = GetPlayer(); + if (IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)) { + if (player->physics.speed < playerSpeeds[FAST_AHEAD]) { + if (player->physics.speed < playerSpeeds[SLOW_AHEAD]) { + player->physics.speed = playerSpeeds[SLOW_AHEAD]; + } else { + player->physics.speed = playerSpeeds[FAST_AHEAD]; + } + } + } - if(IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)){ - if(player->physics.speed > playerSpeeds[ANCHOR]){ - if(player->physics.speed > playerSpeeds[SLOW_AHEAD]){ - player->physics.speed = playerSpeeds[SLOW_AHEAD]; - } - else { - player->physics.speed = playerSpeeds[ANCHOR]; + if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) { + if (player->physics.speed > playerSpeeds[ANCHOR]) { + if (player->physics.speed > playerSpeeds[SLOW_AHEAD]) { + player->physics.speed = playerSpeeds[SLOW_AHEAD]; + } else { + player->physics.speed = playerSpeeds[ANCHOR]; + } + } + } - } - } - } + player->sprite.sourceRec.x = 16.0f * GetPlayerSpeedID(player->physics.speed); - player->sprite.sourceRec.x = 16.0f * GetPlayerSpeedID(player->physics.speed); + float rotationSpeed = 50.0f; + if (player->physics.speed > playerSpeeds[ANCHOR]) { - float rotationSpeed = 50.0f; + if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) { + player->rotation -= rotationSpeed * GetFrameTime(); + } - if (player->physics.speed > playerSpeeds[ANCHOR]){ + if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) { + player->rotation += rotationSpeed * GetFrameTime(); + } + } - if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) { - player->rotation -= rotationSpeed * GetFrameTime(); - } + player->sprite.rotation = player->rotation; - if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) { - player->rotation += rotationSpeed * GetFrameTime(); - } - } + Vector2 dir = RotationToVector2(player->rotation - 90.0f); - player->sprite.rotation = player->rotation; - - Vector2 dir = RotationToVector2(player->rotation - 90.0f); - - - UpdatePhysics(&player->physics, dir); - UpdateSpriteDestRec(&player->sprite, &player->physics.position); + UpdatePhysics(&player->physics, dir); + UpdateSpriteDestRec(&player->sprite, &player->physics.position); } -void RenderPlayer(void){ - Player* player = GetPlayer(); - RenderSprite(&player->sprite); +void RenderPlayer(void) { + Player *player = GetPlayer(); + RenderSprite(&player->sprite); } -