72 lines
1.8 KiB
C
72 lines
1.8 KiB
C
// Copyright © 2017 Project Golan, all rights reserved.
|
|
#ifndef g_object_h
|
|
#define g_object_h
|
|
|
|
#include "m_types.h"
|
|
|
|
#include <Doominati.h>
|
|
#include <GDCC/HashMap.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#define G_ObjDef_setupEntity(type, th) \
|
|
do { \
|
|
(th).sprite = (type)->sprite; \
|
|
(th).health = (type)->health; \
|
|
(th).friction = (type)->friction; \
|
|
(th).mass = (type)->mass; \
|
|
(th).rsx = (type)->rsx; \
|
|
(th).rsy = (type)->rsy; \
|
|
(th).sx = (type)->sx; \
|
|
(th).sy = (type)->sy; \
|
|
(th).sz = (type)->sz; \
|
|
} while(0)
|
|
|
|
#define G_ObjDef_createTask(type, ...) \
|
|
(DGE_Task_Create(0, (type)->task, __VA_ARGS__))
|
|
|
|
#define G_ObjDef_loadFunc(fn) G_ObjDef_LoadFunc(#fn, (DGE_CallbackType)fn)
|
|
|
|
// Extern Functions ----------------------------------------------------------|
|
|
|
|
struct G_entty const *G_ObjDef_GetType(char const *name);
|
|
struct G_anima const *G_ObjDef_GetAnim(struct G_entty const *type, char const *name);
|
|
|
|
// Types ---------------------------------------------------------------------|
|
|
|
|
typedef struct G_frame // Frame
|
|
{
|
|
integ time;
|
|
M_texid sprite;
|
|
} G_frame;
|
|
|
|
typedef struct G_anima // Animation
|
|
{
|
|
G_frame *frame;
|
|
msize count;
|
|
} G_anima;
|
|
|
|
typedef struct G_entty // Entity Type
|
|
{
|
|
__prop getAnim {call: G_ObjDef_GetAnim(this)}
|
|
|
|
M_texid sprite;
|
|
integ health;
|
|
lfrac friction;
|
|
fixed mass;
|
|
fixed rsx, rsy;
|
|
fixed sx, sy, sz;
|
|
DGE_CallbackType task;
|
|
} G_entty;
|
|
|
|
// Extern Functions ----------------------------------------------------------|
|
|
|
|
void G_ObjDef_Init(void);
|
|
void G_ObjDef_Load(char const *fname);
|
|
void G_ObjDef_LoadFunc(char const *name, DGE_CallbackType fptr);
|
|
|
|
DGE_Entity G_Player_Create(fixed x, fixed y);
|
|
DGE_Callback void G_Player_Think(DGE_Entity ent);
|
|
|
|
#endif
|