159 lines
2.5 KiB
C
159 lines
2.5 KiB
C
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
|
|
|
|
#ifndef _ENTITY_H_
|
|
#define _ENTITY_H_
|
|
|
|
#include "Util.h"
|
|
#include "Draw.h"
|
|
#include "Anim.h"
|
|
|
|
#define EntityFlag_Collision 1
|
|
#define EntityFlag_Overlap 2
|
|
#define EntityFlag_Light 4
|
|
#define EntityFlag_UpdateLight 8
|
|
#define EntityFlag_UpdatedPos 16
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
// Entity //
|
|
////////////
|
|
//
|
|
typedef struct Tag_Entity {
|
|
|
|
int type;
|
|
vec2 pos;
|
|
int flags;
|
|
int zorder;
|
|
|
|
vec2 vel;
|
|
vec2 bod_offset;
|
|
float radius;
|
|
float mass;
|
|
float elast;
|
|
float fric_static;
|
|
float fric_dynamic;
|
|
|
|
AnimPlay anim;
|
|
|
|
float color[4];
|
|
float light[4];
|
|
|
|
void (*oncopy)(struct Tag_Entity *ent);
|
|
void (*ondelete)(struct Tag_Entity *ent);
|
|
void (*proc)(struct Tag_Entity *ent,int ft);
|
|
void (*postproc)(struct Tag_Entity *ent,int ft);
|
|
int (*collision)(
|
|
struct Tag_Entity *ent,
|
|
struct Tag_Entity *ent2,
|
|
float t,vec2 n);
|
|
void (*overlap)(
|
|
struct Tag_Entity *ent,
|
|
struct Tag_Entity *ent2);
|
|
|
|
int A;
|
|
struct Tag_Entity *child;
|
|
|
|
void *next;
|
|
} Entity;
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_New
|
|
//
|
|
//
|
|
Entity *Entity_New();
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Destroy
|
|
//
|
|
//
|
|
void Entity_Destroy(Entity *e);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Copy
|
|
//
|
|
//
|
|
Entity *Entity_Copy(Entity *e);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Draw
|
|
//
|
|
//
|
|
void Entity_Draw(Entity *e,int x,int y);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Process
|
|
//
|
|
//
|
|
void Entity_Process(Entity *e,int ft);
|
|
|
|
/////////////////////////////
|
|
// Entity_PostProcess
|
|
//
|
|
//
|
|
void Entity_PostProcess(Entity *e,int ft);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_CollisionResponse
|
|
//
|
|
// Normal response to a collision.
|
|
void Entity_CollisionResponse(
|
|
Entity *b1,Entity *b2,float t,vec2 n);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Collide
|
|
//
|
|
//
|
|
int Entity_Collide(Entity *b1,Entity *b2);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_Overlaps
|
|
//
|
|
//
|
|
void Entity_Overlaps(Entity *b1,Entity *b2);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_AddVelLimit
|
|
//
|
|
//
|
|
void Entity_AddVelLimit(Entity *e,vec2 vel,float limit);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_SetColor
|
|
//
|
|
//
|
|
void Entity_SetColor(Entity *e,float r,float g,float b,float a);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_AddColor
|
|
//
|
|
//
|
|
void Entity_AddColor(Entity *e,float r,float g,float b,float a);
|
|
|
|
|
|
/////////////////////////////
|
|
// Entity_AddColor
|
|
//
|
|
//
|
|
void Entity_SetLight(Entity *e,float r,float g,float b,float rad);
|
|
|
|
/////////////////////////////
|
|
// Entity_AddColor
|
|
//
|
|
//
|
|
void Entity_Iluminate(Entity *e,Entity **elist,int n);
|
|
|
|
|
|
#endif
|
|
|