Path following

This commit is contained in:
2023-11-14 12:01:28 +01:00
parent ab817ee03d
commit 8825b9e01f
14 changed files with 213 additions and 102 deletions

View File

@@ -2,28 +2,40 @@
#define PIXELDEFENSE_COMPONENTS_H
#include <breeze.h>
#include <flecs.h>
#include "utils/building_types.h"
#define ecs_set_p(world, e, T, ...) ecs_set_id(world, e, ecs_id(T), sizeof(T), (T*)__VA_ARGS__)
typedef struct TilePosition {
BzTile x;
BzTile y;
} TilePosition;
extern ECS_COMPONENT_DECLARE(TilePosition);
typedef struct TileSize {
BzTile sizeX;
BzTile sizeY;
} TileSize;
extern ECS_COMPONENT_DECLARE(TileSize);
typedef struct Owner {
BuildingType playerID;
} Owner;
extern ECS_COMPONENT_DECLARE(Owner);
typedef Vector2 Position, Size;
typedef Vector2 Position, Size, TargetPosition;
extern ECS_COMPONENT_DECLARE(Position);
extern ECS_COMPONENT_DECLARE(Size);
extern ECS_COMPONENT_DECLARE(TargetPosition);
typedef f32 Rotation;
extern ECS_COMPONENT_DECLARE(Rotation);
typedef f32 Health;
extern ECS_COMPONENT_DECLARE(Health);
typedef struct TextureRegion {
Texture2D texture;
@@ -31,11 +43,13 @@ typedef struct TextureRegion {
bool flipX;
bool flipY;
} TextureRegion;
extern ECS_COMPONENT_DECLARE(TextureRegion);
typedef enum AnimationType {
ANIMATION_IDLE,
ANIMATION_WALK,
} AnimationType;
extern ECS_COMPONENT_DECLARE(AnimationType);
typedef struct Animation {
TextureRegion firstFrame;
@@ -45,7 +59,18 @@ typedef struct Animation {
f32 frameDuration;
f32 elapsed;
} Animation;
extern ECS_COMPONENT_DECLARE(Animation);
typedef struct Path {
Position *waypoints;
i32 maxWaypoints;
i32 numWaypoints;
i32 curWaypoint;
} Path;
extern ECS_COMPONENT_DECLARE(Path);
void initComponentIDs(ecs_world_t *ecs);
#endif //PIXELDEFENSE_COMPONENTS_H