2021-08-28 22:48:16 +00:00
|
|
|
#include "raylib.h"
|
2021-09-12 19:23:15 +00:00
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
#include "Controls.h"
|
2021-09-05 16:30:50 +00:00
|
|
|
#include "Debug.h"
|
2021-09-18 15:22:16 +00:00
|
|
|
#include "Copying.h"
|
2021-08-28 22:48:16 +00:00
|
|
|
|
|
|
|
// Globles
|
|
|
|
|
|
|
|
// Position Varaibles
|
|
|
|
float EnemyPos_x = 482.0f, EnemyPos_y = 62.0f;
|
2021-09-05 16:30:50 +00:00
|
|
|
float TuxPos_x = 32.0f, TuxPos_y = 62.0f;
|
2021-08-28 22:48:16 +00:00
|
|
|
|
2021-11-19 22:36:33 +00:00
|
|
|
// Toggle bools
|
|
|
|
bool ShowHitbox = false;
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
// Setup Code
|
2021-10-21 12:02:11 +00:00
|
|
|
void Func_Setup()
|
2021-08-28 22:48:16 +00:00
|
|
|
{
|
|
|
|
const int screenWidth = 800;
|
|
|
|
const int screenHeight = 450;
|
|
|
|
|
|
|
|
InitWindow(screenWidth, screenHeight, "Tux Vs Windows");
|
|
|
|
|
|
|
|
SetTargetFPS(60);
|
|
|
|
}
|
|
|
|
|
|
|
|
// GameLoop Code
|
2021-10-21 12:02:11 +00:00
|
|
|
void Func_MainGameLoop()
|
2021-08-28 22:48:16 +00:00
|
|
|
{
|
|
|
|
// Load Textures
|
|
|
|
Texture2D tux = LoadTexture("assets/tux.png");
|
|
|
|
Texture2D enemy = LoadTexture("assets/enemy.png");
|
|
|
|
Texture2D arctic = LoadTexture("assets/arctic.png");
|
|
|
|
|
2021-11-18 22:44:12 +00:00
|
|
|
// 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};
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle boxCollision = { 0 };
|
|
|
|
bool collision = false;
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
// GameLoop
|
2021-11-19 22:36:33 +00:00
|
|
|
while (!WindowShouldClose()) {
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
Func_ShowPos();
|
|
|
|
Func_Controls();
|
|
|
|
|
2021-11-18 22:44:12 +00:00
|
|
|
TuxHitbox.x = TuxPos_x+50;
|
|
|
|
TuxHitbox.y = TuxPos_y+50;
|
|
|
|
EnemyHitbox.x = EnemyPos_x;
|
|
|
|
EnemyHitbox.y = EnemyPos_y;
|
|
|
|
|
|
|
|
collision = CheckCollisionRecs(EnemyHitbox, TuxHitbox);
|
|
|
|
if (collision) boxCollision = GetCollisionRec(EnemyHitbox, TuxHitbox);
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
BeginDrawing();
|
|
|
|
ClearBackground(RAYWHITE);
|
|
|
|
|
2021-09-18 15:22:16 +00:00
|
|
|
// Put the sprites and text on the screen
|
2021-08-28 22:48:16 +00:00
|
|
|
DrawTexture(arctic, 50, 0, RAYWHITE);
|
|
|
|
DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE);
|
|
|
|
DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE);
|
2021-11-18 22:44:12 +00:00
|
|
|
|
2021-11-19 22:36:33 +00:00
|
|
|
Func_CheckHitboxToggle();
|
|
|
|
|
|
|
|
if (ShowHitbox==true) {
|
2021-11-18 22:44:12 +00:00
|
|
|
DrawRectangleRec(EnemyHitbox, RED);
|
|
|
|
DrawRectangleRec(TuxHitbox, BLUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (collision) {
|
|
|
|
DrawText("FINALY BASIC AWFUL COLLISION", 50, 18, 20, BLACK);
|
|
|
|
} else {
|
|
|
|
DrawText("Tux Vs X ENGINE PROTOTYPE please read the LINCENSE", 50, 18, 20, BLACK);
|
|
|
|
}
|
|
|
|
|
2021-11-19 22:36:33 +00:00
|
|
|
DrawText("Press 'H' to toggle hitboxes", 50, 72, 20, BLACK);
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
EndDrawing();
|
2021-11-19 22:36:33 +00:00
|
|
|
}
|
2021-08-28 22:48:16 +00:00
|
|
|
// Unload Textures
|
|
|
|
UnloadTexture(tux);
|
|
|
|
UnloadTexture(enemy);
|
|
|
|
UnloadTexture(arctic);
|
|
|
|
}
|
|
|
|
|
2021-11-19 22:36:33 +00:00
|
|
|
void Func_CheckHitboxToggle()
|
|
|
|
{
|
|
|
|
if (IsKeyPressed(KEY_H)) ShowHitbox = !ShowHitbox;
|
|
|
|
}
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
Func_Setup();
|
|
|
|
Func_MainGameLoop();
|
|
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
2021-09-18 15:22:16 +00:00
|
|
|
Func_License();
|
|
|
|
|
2021-08-28 22:48:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|