From 815aec62f8ae3a403e913559d5fe6138c8825007 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Tue, 29 Jul 2025 11:50:57 +0300 Subject: Added background entity and asset system --- include/assets.h | 6 ++++++ include/background.h | 7 +++++++ include/game.h | 20 ++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 include/assets.h create mode 100644 include/background.h (limited to 'include') diff --git a/include/assets.h b/include/assets.h new file mode 100644 index 0000000..e2d76b7 --- /dev/null +++ b/include/assets.h @@ -0,0 +1,6 @@ +#pragma once + +#include + +void LoadAssets(); +Texture2D GetTexture(const char* name); diff --git a/include/background.h b/include/background.h new file mode 100644 index 0000000..104db7c --- /dev/null +++ b/include/background.h @@ -0,0 +1,7 @@ +#pragma once + +#include "game.h" +#include "assets.h" + +void AddBackground(const char* backgroundTexture); +void UpdateBackground(Entity* background, float deltaTime); diff --git a/include/game.h b/include/game.h index 64da8e7..1039ad5 100644 --- a/include/game.h +++ b/include/game.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "constants.h" @@ -11,9 +12,15 @@ typedef enum EntityType { Player_Entity, - Wall_Entity + Wall_Entity, + Background_Entity } EntityType; +typedef enum DrawLayer { + Background_Layer = 0, + Foreground_Layer = 1 +} DrawLayer; + typedef struct Entity { int id; EntityType type; @@ -29,6 +36,11 @@ typedef struct Entity { int numHurtBoxes; Rectangle hurtBoxes[MAX_AREA_COUNT]; + //Graphics Information + Texture2D texture; + DrawLayer drawLayer; + Rectangle destRect; //Relative to the players position + #ifdef BEATEMUP_DEBUG //Debug information Color physicsColliderColor; @@ -42,6 +54,10 @@ typedef struct Game { Texture2D background; float backgroundPosition; + #ifdef BEATEMUP_DEBUG + //Debug information + bool enableDebugOverlay; + #endif } Game; void AddEntity(Entity* e); @@ -49,4 +65,4 @@ void AddWall(float xpos, float ypos, float width, float height); void InitGame(); void UpdateGame(float deltaTime); -void DrawGame(); \ No newline at end of file +void DrawGame(); -- cgit v1.2.3