#pragma once #include #include #include #include "constants.h" #define ENTITY_ALLOCATED 1 #define ENTITY_VISIBLE (1 << 1) #define ENTITY_PHYSICS_ACTIVE (1 << 2) typedef enum EntityType { Player_Entity, Wall_Entity, Background_Entity } EntityType; typedef enum DrawLayer { Background_Layer = 0, Foreground_Layer = 1 } DrawLayer; typedef struct Animation { int numFrames; bool isLooping; bool isComplete; Rectangle srcRects[MAX_FRAMES]; float frameTimes[MAX_FRAMES]; int currentFrame; float currentFrameTimer; } Animation; typedef struct Sprite { Texture2D texture; DrawLayer layer; Rectangle destRect; //Destination rectangle relative to player position int numAnimations; //Zero for static spritesx Animation animations[MAX_ANIMATIONS]; int currentAnimation; } Sprite; typedef struct Entity { int id; EntityType type; uint16_t flags; Vector2 position; Vector2 velocity; //Physics information Rectangle physicsCollider; int numHitBoxes; Rectangle hitBoxes[MAX_AREA_COUNT]; int numHurtBoxes; Rectangle hurtBoxes[MAX_AREA_COUNT]; Sprite sprites[MAX_SPRITE_COUNT]; int numSprites; #ifdef BEATEMUP_DEBUG //Debug information Color physicsColliderColor; #endif } Entity; typedef struct Game { bool paused; Entity entities[MAX_ENTITY_COUNT]; Camera2D camera; #ifdef BEATEMUP_DEBUG //Debug information bool enableDebugOverlay; #endif } Game; void AddEntity(Entity* e); void AddWall(float xpos, float ypos, float width, float height); void InitGame(); void UpdateGame(float deltaTime); void DrawGame(); void UpdateCurrentSpriteAnimation(Sprite* sprite, float dt); void DrawEntitySprite(const Sprite* sprite, int spriteIndex); #ifdef BEATEMUP_DEBUG void DebugHighlights(const Entity* e); #endif