This commit is contained in:
2025-06-08 17:22:30 +02:00
parent 64cac7578d
commit 79c8b747cd
16 changed files with 686 additions and 79 deletions

55
entity/entity.h Normal file
View File

@@ -0,0 +1,55 @@
//
// 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