#include #include "raylib.h" #include "Controls.h" #include "Debug.h" #include "Copying.h" /* Functions */ /* Globles */ // Position Varaibles float EnemyPos_x = 482.0f, EnemyPos_y = 62.0f; float TuxPos_x = 32.0f, TuxPos_y = 62.0f; // Toggle bools bool ShowHitbox = false; bool ToggleShowPos = false; // Setup Code void Setup() { const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "Tux Vs Windows"); InitAudioDevice(); SetTargetFPS(60); } // GameLoop Code void MainGameLoop() { // Load Assets Texture2D tux = LoadTexture("assets/gfx/tux.png"); Texture2D enemy = LoadTexture("assets/gfx/enemy.png"); Texture2D arctic = LoadTexture("assets/gfx/arctic.png"); Sound sfxHit = LoadSound("assets/sfx/hit.wav"); // Hitboxes Rectangle EnemyHitbox = { GetScreenWidth()/2.0f - 30, GetScreenHeight()/2.0f - 30, 290, 300}; Rectangle TuxHitbox = { GetScreenWidth()/2.0f - 30, GetScreenHeight()/2.0f - 30, 90, 40}; bool collision = false; // GameLoop while (!WindowShouldClose()) { // Checks and calls the Pos show function if (IsKeyPressed(KEY_P)) ToggleShowPos = !ToggleShowPos; if (ToggleShowPos==true) ShowPos(); Controls(); TuxHitbox.x = TuxPos_x+50; TuxHitbox.y = TuxPos_y+50; EnemyHitbox.x = EnemyPos_x; EnemyHitbox.y = EnemyPos_y; collision = CheckCollisionRecs(EnemyHitbox, TuxHitbox); BeginDrawing(); ClearBackground(RAYWHITE); // Put the sprites and text on the screen DrawTexture(arctic, 50, 0, RAYWHITE); DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE); DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE); CheckHitboxToggle(); if (ShowHitbox==true) { DrawRectangleRec(EnemyHitbox, RED); DrawRectangleRec(TuxHitbox, BLUE); } if (collision) { DrawText("FINALY BASIC AWFUL COLLISION", 50, 18, 20, MAROON); PlaySound(sfxHit); } else { DrawText("Tux Vs X ENGINE PROTOTYPE please read the LINCENSE", 50, 18, 20, BLACK); } DrawText("Press 'H' to toggle hitboxes", 50, 72, 20, DARKGREEN); DrawText("Press 'P' to toggle printing of the positions", 50, 95, 20, DARKGREEN); EndDrawing(); } // Unload Assets UnloadTexture(tux); UnloadTexture(enemy); UnloadTexture(arctic); UnloadSound(sfxHit); } int main() { Setup(); MainGameLoop(); CloseAudioDevice(); CloseWindow(); License(); return 0; }