2021-11-30 21:29:18 -06:00
|
|
|
#ifndef GAMEOBJECT_H
|
|
|
|
#define GAMEOBJECT_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "mathc.h"
|
|
|
|
#include "transform.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdbool.h>
|
2022-01-21 11:26:22 -06:00
|
|
|
#include <chipmunk/chipmunk.h>
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
struct shader;
|
2022-11-17 16:48:20 -06:00
|
|
|
struct sprite;
|
2021-11-30 21:29:18 -06:00
|
|
|
struct component;
|
|
|
|
|
|
|
|
struct editor {
|
|
|
|
mfloat_t color[3];
|
|
|
|
int id;
|
|
|
|
bool active;
|
|
|
|
bool prefabSync;
|
|
|
|
char mname[MAXNAME];
|
|
|
|
char *curPrefabPath;
|
|
|
|
char prefabName[MAXNAME];
|
|
|
|
char rootPrefabName[MAXNAME];
|
|
|
|
};
|
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
struct gameobject {
|
2021-11-30 21:29:18 -06:00
|
|
|
struct mTransform transform;
|
|
|
|
struct editor editor;
|
|
|
|
cpBodyType bodytype;
|
|
|
|
float scale;
|
|
|
|
float mass;
|
|
|
|
cpBody *body;
|
|
|
|
float f; /* friction */
|
|
|
|
float e; /* elasticity */
|
2022-08-26 09:19:17 -05:00
|
|
|
struct component *components;
|
2022-08-12 14:03:56 -05:00
|
|
|
char *script;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
extern struct gameobject *gameobjects;
|
2022-08-26 09:19:17 -05:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
struct gameobject *MakeGameobject();
|
2022-01-19 16:43:21 -06:00
|
|
|
void init_gameobjects();
|
2021-11-30 21:29:18 -06:00
|
|
|
void gameobject_delete(int id);
|
|
|
|
void clear_gameobjects();
|
|
|
|
int number_of_gameobjects();
|
|
|
|
void set_n_gameobjects(int n);
|
2022-11-19 17:13:57 -06:00
|
|
|
void setup_model_transform(struct mTransform *t, struct shader *s, float scale);
|
|
|
|
void toggleprefab(struct gameobject *go);
|
2022-12-19 18:15:38 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
struct gameobject *get_gameobject_from_id(int id);
|
2022-12-19 18:15:38 -06:00
|
|
|
int id_from_gameobject(struct gameobject *go);
|
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_save(struct gameobject *go, FILE * file);
|
|
|
|
void gameobject_addcomponent(struct gameobject *go, struct component *c);
|
|
|
|
void gameobject_delcomponent(struct gameobject *go, int n);
|
|
|
|
void gameobject_loadcomponent(struct gameobject *go, int id);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_saveprefab(struct gameobject *go);
|
2022-12-19 18:15:38 -06:00
|
|
|
int gameobject_makefromprefab(char *path);
|
2021-11-30 21:29:18 -06:00
|
|
|
void gameobject_syncprefabs(char *revertPath);
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_revertprefab(struct gameobject *go);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_init(struct gameobject *go, FILE * fprefab);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_update(struct gameobject *go);
|
2021-11-30 21:29:18 -06:00
|
|
|
void update_gameobjects();
|
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void gameobject_move(struct gameobject *go, float xs, float ys);
|
|
|
|
void gameobject_rotate(struct gameobject *go, float as);
|
2022-12-19 18:15:38 -06:00
|
|
|
void gameobject_setangle(struct gameobject *go, float angle);
|
|
|
|
void gameobject_setpos(struct gameobject *go, float x, float y);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void object_gui(struct gameobject *go);
|
2022-08-12 14:03:56 -05:00
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#endif
|