diff --git a/Makefile b/Makefile index 87fb62f..74853d2 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ OBJS = src/Main.c src/Controls.c src/Debug.c src/Copying.c CC = cc -#gimmie dem warnings yo +#gimmie ALL dem 1999 era warnings yo -COMPILER_FLAGS = -Wall +COMPILER_FLAGS = -std=c99 -Wall #libs we linkin bro diff --git a/README.md b/README.md index 2beeef8..bc5ebde 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Tux Vs X ENGINE A remake of the first game I made. -

This time made with C and raylib.

+

This time made with C99 and raylib.

Sprites made by Jelly_poi.

Programming and design by M-C-O-B.

@@ -13,13 +13,14 @@ Make sure to read the LICENSE file * More clean code * Build Guide -* Hitboxes working in .h files * Screen Boundaries * Projectiles * Portable Binaries of the game # BRANCHES -

To see new code use

- +Use +```sh git checkout unstable +``` +to see the unstable branch diff --git a/src/Controls.c b/src/Controls.c index 32a0196..2c7b607 100644 --- a/src/Controls.c +++ b/src/Controls.c @@ -4,7 +4,7 @@ #include "Controls.h" // Controls -void Func_Controls() +void Controls() { if (IsKeyDown(KEY_LEFT)) TuxPos_x -= GetFrameTime() * 800.0f; if (IsKeyDown(KEY_RIGHT)) TuxPos_x += GetFrameTime() * 800.0f; diff --git a/src/Controls.h b/src/Controls.h index 56f7d33..5995afe 100644 --- a/src/Controls.h +++ b/src/Controls.h @@ -1,3 +1,3 @@ #pragma once -void Func_Controls(); +void Controls(); diff --git a/src/Copying.c b/src/Copying.c index cd618b6..ed6d51c 100644 --- a/src/Copying.c +++ b/src/Copying.c @@ -1,7 +1,7 @@ #include -void Func_License() +void License() { // Outputs Copying info in the command line printf diff --git a/src/Copying.h b/src/Copying.h index 633e427..8fff4f4 100644 --- a/src/Copying.h +++ b/src/Copying.h @@ -1,3 +1,3 @@ #pragma once -void Func_License(); +void License(); diff --git a/src/Debug.c b/src/Debug.c index 289f508..2d02b39 100644 --- a/src/Debug.c +++ b/src/Debug.c @@ -1,9 +1,11 @@ #include +#include +#include "raylib.h" #include "Main.h" #include "Debug.h" -void Func_ShowPos() +void ShowPos() { // Ouput Position Infomation in the command line printf @@ -12,3 +14,8 @@ void Func_ShowPos() TuxPos_x, TuxPos_y, EnemyPos_x, EnemyPos_y ); } + +void CheckHitboxToggle() +{ + if (IsKeyPressed(KEY_H)) ShowHitbox = !ShowHitbox; +} diff --git a/src/Debug.h b/src/Debug.h index 8392152..4587e1b 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -1,3 +1,4 @@ #pragma once -void Func_ShowPos(); +void ShowPos(); +void CheckHitboxToggle(); diff --git a/src/Main.c b/src/Main.c index 8c9ff1d..9fc6049 100644 --- a/src/Main.c +++ b/src/Main.c @@ -1,3 +1,4 @@ +#include #include "raylib.h" #include "Controls.h" @@ -5,7 +6,7 @@ #include "Copying.h" // Functions -void Func_CheckHitboxToggle(); + // Globles @@ -15,10 +16,10 @@ float TuxPos_x = 32.0f, TuxPos_y = 62.0f; // Toggle bools bool ShowHitbox = false; -bool ShowPos = false; +bool ToggleShowPos = false; // Setup Code -void Func_Setup() +void Setup() { const int screenWidth = 800; const int screenHeight = 450; @@ -29,7 +30,7 @@ void Func_Setup() } // GameLoop Code -void Func_MainGameLoop() +void MainGameLoop() { // Load Textures Texture2D tux = LoadTexture("assets/tux.png"); @@ -41,17 +42,16 @@ void Func_MainGameLoop() Rectangle TuxHitbox = { GetScreenWidth()/2.0f - 30, GetScreenHeight()/2.0f - 30, 90, 40}; - Rectangle boxCollision = { 0 }; bool collision = false; // GameLoop while (!WindowShouldClose()) { // Checks and calls the Pos show function - if (IsKeyPressed(KEY_P)) ShowPos = !ShowPos; - if (ShowPos==true) Func_ShowPos(); + if (IsKeyPressed(KEY_P)) ToggleShowPos = !ToggleShowPos; + if (ToggleShowPos==true) ShowPos(); - Func_Controls(); + Controls(); TuxHitbox.x = TuxPos_x+50; TuxHitbox.y = TuxPos_y+50; @@ -59,7 +59,6 @@ void Func_MainGameLoop() EnemyHitbox.y = EnemyPos_y; collision = CheckCollisionRecs(EnemyHitbox, TuxHitbox); - if (collision) boxCollision = GetCollisionRec(EnemyHitbox, TuxHitbox); BeginDrawing(); ClearBackground(RAYWHITE); @@ -69,7 +68,7 @@ void Func_MainGameLoop() DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE); DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE); - Func_CheckHitboxToggle(); + CheckHitboxToggle(); if (ShowHitbox==true) { DrawRectangleRec(EnemyHitbox, RED); @@ -93,20 +92,12 @@ void Func_MainGameLoop() UnloadTexture(arctic); } -void Func_CheckHitboxToggle() -{ - if (IsKeyPressed(KEY_H)) ShowHitbox = !ShowHitbox; -} - - int main() { - Func_Setup(); - Func_MainGameLoop(); - + Setup(); + MainGameLoop(); CloseWindow(); - - Func_License(); + License(); return 0; } diff --git a/src/Main.h b/src/Main.h index 3658820..91a6d9e 100644 --- a/src/Main.h +++ b/src/Main.h @@ -1,3 +1,4 @@ +#include #pragma once // makes the Varaibles globle across c files @@ -5,3 +6,6 @@ extern float TuxPos_x; extern float TuxPos_y; extern float EnemyPos_x; extern float EnemyPos_y; + +extern bool ShowHitbox; +extern bool ToggleShowPos;