56 lines
1.1 KiB
C
56 lines
1.1 KiB
C
//
|
|
// Created by bruno on 7.6.2025.
|
|
//
|
|
|
|
#ifndef FACTORYGAME_ENTITY_H
|
|
#define FACTORYGAME_ENTITY_H
|
|
|
|
#include "../tiles/tile.h"
|
|
#include "../util/pathfinding.h"
|
|
|
|
#define ENTITY_MAX_COUNT 1024
|
|
|
|
typedef enum EntityType {
|
|
GHOST,
|
|
} EntityType;
|
|
|
|
typedef struct EntityTypeReg {
|
|
EntityType type;
|
|
Animation animation;
|
|
char name[20];
|
|
int speed;
|
|
int entityTickRate;
|
|
} EntityTypeReg;
|
|
|
|
typedef struct Entity {
|
|
MiniRect tileRect;
|
|
SDL_Rect renderRect;
|
|
EntityType type;
|
|
uint16_t health;
|
|
MiniRect target;
|
|
Path path;
|
|
int entityNextTick;
|
|
unsigned char interpolateTick;
|
|
MiniRect fromTile;
|
|
MiniRect toTile;
|
|
MiniRect targetSnapshot;
|
|
} Entity;
|
|
|
|
typedef struct EntityArray {
|
|
Entity entities[ENTITY_MAX_COUNT];
|
|
int activeCount;
|
|
} EntityArray;
|
|
|
|
extern EntityArray entities;
|
|
|
|
void remove_entity(EntityArray *arr, int index);
|
|
|
|
int add_entity(EntityArray *arr, Entity t);
|
|
|
|
void renderEntities(SDL_Renderer *renderer, SDL_Rect playerRect);
|
|
void updateEntities();
|
|
void registerEntity(char fname[20], SDL_Renderer *renderer);
|
|
void loadEntities(SDL_Renderer *renderer);
|
|
|
|
#endif //FACTORYGAME_ENTITY_H
|