51 lines
1.6 KiB
C
51 lines
1.6 KiB
C
#ifndef ENGINE_ARRAY_H
|
|
#define ENGINE_ARRAY_H
|
|
|
|
#include "engineSprite.h"
|
|
#include "enginePhysics.h"
|
|
#include "engineVector.h"
|
|
#include <raylib.h>
|
|
#include <stddef.h>
|
|
|
|
typedef struct {
|
|
void **elements;
|
|
unsigned int count;
|
|
unsigned int capacity;
|
|
} Array;
|
|
|
|
typedef struct {
|
|
Sprite sprite;
|
|
Vector2 position;
|
|
} Object;
|
|
|
|
typedef struct {
|
|
Object *data;
|
|
const Object *prototype;
|
|
size_t count;
|
|
} ObjectArray;
|
|
|
|
Array *CreateArray(unsigned int initCapacity);
|
|
int AddElementToArray(Array *array, void *element);
|
|
int RemoveElementFromArray(Array *array, unsigned int index);
|
|
void *GetRandomElementFromArray(Array *array);
|
|
void UpdateArray(Array *array, void (*updateFunc)(void *));
|
|
void RenderArray(Array *array, void (*renderFunc)(void *));
|
|
void FreeArray(Array **array);
|
|
|
|
ObjectArray CreateObjectArray(const Object *prototype, const size_t count);
|
|
Object *GetRandomObject(ObjectArray *objects);
|
|
void AddObjectToArray(ObjectArray *objects, const Object *prototype,
|
|
Vector2 position);
|
|
void SetPositionForObjectArray(ObjectArray *objects,
|
|
const Vector2Array *positions);
|
|
void SetRandomPositionForObjectArray(ObjectArray *objects,
|
|
const Rectangle bounds);
|
|
void SwapAndPopObjectsArrayOnRecCollision(ObjectArray *objects,
|
|
const Rectangle rec);
|
|
void SwapAndPopObjectsArrayOnPointCollision(ObjectArray *objects,
|
|
const Vector2 point);
|
|
Vector2 GetDirectionToObject(Object *object, Vector2 position);
|
|
void RenderObjectArray(const ObjectArray *objects);
|
|
|
|
#endif // ENGINE_ARRAY_H
|