41 lines
845 B
C
41 lines
845 B
C
#include <stdlib.h>
|
|
#include "Entity.h"
|
|
|
|
struct Entity *newEntity() {
|
|
struct Entity *entity = malloc(sizeof(struct Entity));
|
|
cleanPhys(&entity->phys);
|
|
entity->l_phys = entity->phys;
|
|
cleanVector(&entity->home_offset);
|
|
entity->home = NULL;
|
|
cleanVector(&entity->target_offset);
|
|
entity->target = NULL;
|
|
|
|
entity->speed = 2.0f;
|
|
entity->turn_rate = 0.1f;
|
|
|
|
entity->name = NULL;
|
|
entity->exp = 2;
|
|
entity->damage = 1;
|
|
entity->logic = 0;
|
|
entity->spawn_data = NULL;
|
|
|
|
entity->range = 32.0f;
|
|
|
|
entity->hp = 0;
|
|
entity->max_hp = 0;
|
|
|
|
cleanAnim(&entity->animation);
|
|
entity->move_id = -1;
|
|
entity->idle_id = -1;
|
|
entity->curr_id = -1;
|
|
entity->mode = 0;
|
|
return entity;
|
|
}
|
|
|
|
int freeEntity(struct Entity *entity) {
|
|
if (entity == NULL) return 0;
|
|
if (entity->name != NULL) free(entity->name);
|
|
//free(entity);
|
|
return 1;
|
|
}
|