Compare commits
4 commits
528aa248f3
...
d766ed5fce
Author | SHA1 | Date | |
---|---|---|---|
d766ed5fce | |||
d748b0479f | |||
6749eeb679 | |||
53130a6d19 |
5 changed files with 85 additions and 28 deletions
5
Makefile
5
Makefile
|
@ -6,8 +6,11 @@ OBJS = src/Main.c src/Controls.c src/Debug.c src/Copying.c
|
||||||
|
|
||||||
#compiler to use
|
#compiler to use
|
||||||
|
|
||||||
CC = gcc
|
CC = cc
|
||||||
|
|
||||||
|
#gimmie dem warnings yo
|
||||||
|
|
||||||
|
COMPILER_FLAGS = -Wall
|
||||||
|
|
||||||
#libs we linkin bro
|
#libs we linkin bro
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,13 @@ Make sure to read the LICENSE file
|
||||||
|
|
||||||
* More clean code
|
* More clean code
|
||||||
* Build Guide
|
* Build Guide
|
||||||
* Hitboxes
|
* Hitboxes working in .h files
|
||||||
|
* Screen Boundaries
|
||||||
* Projectiles
|
* Projectiles
|
||||||
* Portable Binaries of the game
|
* Portable Binaries of the game
|
||||||
|
|
||||||
|
# BRANCHES
|
||||||
|
|
||||||
|
<p>To see new code use</p>
|
||||||
|
|
||||||
|
git checkout unstable
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
// Controls
|
// Controls
|
||||||
void Func_Controls()
|
void Func_Controls()
|
||||||
{
|
{
|
||||||
if (IsKeyDown(KEY_LEFT)) {TuxPos_x -= GetFrameTime() * 800.0f;}
|
if (IsKeyDown(KEY_LEFT)) TuxPos_x -= GetFrameTime() * 800.0f;
|
||||||
if (IsKeyDown(KEY_RIGHT)) {TuxPos_x += GetFrameTime() * 800.0f;}
|
if (IsKeyDown(KEY_RIGHT)) TuxPos_x += GetFrameTime() * 800.0f;
|
||||||
if (IsKeyDown(KEY_UP)) {TuxPos_y -= GetFrameTime() * 800.0f;}
|
if (IsKeyDown(KEY_UP)) TuxPos_y -= GetFrameTime() * 800.0f;
|
||||||
if (IsKeyDown(KEY_DOWN)) {TuxPos_y += GetFrameTime() * 800.0f;}
|
if (IsKeyDown(KEY_DOWN)) TuxPos_y += GetFrameTime() * 800.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,6 @@ void Func_License()
|
||||||
"This program comes with ABSOLUTELY NO WARRANTY; \n"
|
"This program comes with ABSOLUTELY NO WARRANTY; \n"
|
||||||
"This is free software, and you are welcome to redistribute it\n"
|
"This is free software, and you are welcome to redistribute it\n"
|
||||||
"under certain conditions; for details read the LICENSE.\n"
|
"under certain conditions; for details read the LICENSE.\n"
|
||||||
|
"For the source code go to https://gitdab.com/Canneddonuts/Tux_Vs_X_ENGINE.git\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
50
src/Main.c
50
src/Main.c
|
@ -1,16 +1,22 @@
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Controls.h"
|
#include "Controls.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include "Copying.h"
|
#include "Copying.h"
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
void Func_CheckHitboxToggle();
|
||||||
|
|
||||||
// Globles
|
// Globles
|
||||||
|
|
||||||
// Position Varaibles
|
// Position Varaibles
|
||||||
float EnemyPos_x = 482.0f, EnemyPos_y = 62.0f;
|
float EnemyPos_x = 482.0f, EnemyPos_y = 62.0f;
|
||||||
float TuxPos_x = 32.0f, TuxPos_y = 62.0f;
|
float TuxPos_x = 32.0f, TuxPos_y = 62.0f;
|
||||||
|
|
||||||
|
// Toggle bools
|
||||||
|
bool ShowHitbox = false;
|
||||||
|
bool ShowPos = false;
|
||||||
|
|
||||||
// Setup Code
|
// Setup Code
|
||||||
void Func_Setup()
|
void Func_Setup()
|
||||||
{
|
{
|
||||||
|
@ -30,11 +36,31 @@ void Func_MainGameLoop()
|
||||||
Texture2D enemy = LoadTexture("assets/enemy.png");
|
Texture2D enemy = LoadTexture("assets/enemy.png");
|
||||||
Texture2D arctic = LoadTexture("assets/arctic.png");
|
Texture2D arctic = LoadTexture("assets/arctic.png");
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
// GameLoop
|
// GameLoop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
Func_ShowPos();
|
|
||||||
|
// Checks and calls the Pos show function
|
||||||
|
if (IsKeyPressed(KEY_P)) ShowPos = !ShowPos;
|
||||||
|
if (ShowPos==true) Func_ShowPos();
|
||||||
|
|
||||||
Func_Controls();
|
Func_Controls();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
@ -42,7 +68,22 @@ void Func_MainGameLoop()
|
||||||
DrawTexture(arctic, 50, 0, RAYWHITE);
|
DrawTexture(arctic, 50, 0, RAYWHITE);
|
||||||
DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE);
|
DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE);
|
||||||
DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE);
|
DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE);
|
||||||
|
|
||||||
|
Func_CheckHitboxToggle();
|
||||||
|
|
||||||
|
if (ShowHitbox==true) {
|
||||||
|
DrawRectangleRec(EnemyHitbox, RED);
|
||||||
|
DrawRectangleRec(TuxHitbox, BLUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collision) {
|
||||||
|
DrawText("FINALY BASIC AWFUL COLLISION", 50, 18, 20, MAROON);
|
||||||
|
} else {
|
||||||
DrawText("Tux Vs X ENGINE PROTOTYPE please read the LINCENSE", 50, 18, 20, BLACK);
|
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();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +93,11 @@ void Func_MainGameLoop()
|
||||||
UnloadTexture(arctic);
|
UnloadTexture(arctic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Func_CheckHitboxToggle()
|
||||||
|
{
|
||||||
|
if (IsKeyPressed(KEY_H)) ShowHitbox = !ShowHitbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue