prosperon/source/engine/gameobject.h

71 lines
1.8 KiB
C
Raw Normal View History

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
struct mShader;
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];
};
struct mGameObject {
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-08-26 09:19:17 -05:00
extern struct mGameObject *gameobjects;
2021-11-30 21:29:18 -06:00
struct mGameObject *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);
void setup_model_transform(struct mTransform *t, struct mShader *s, float scale);
2021-11-30 21:29:18 -06:00
void toggleprefab(struct mGameObject *go);
struct mGameObject *get_gameobject_from_id(int id);
void gameobject_save(struct mGameObject *go, FILE * file);
void gameobject_addcomponent(struct mGameObject *go, struct component *c);
void gameobject_delcomponent(struct mGameObject *go, int n);
void gameobject_loadcomponent(struct mGameObject *go, int id);
void gameobject_saveprefab(struct mGameObject *go);
void gameobject_makefromprefab(char *path);
void gameobject_syncprefabs(char *revertPath);
void gameobject_revertprefab(struct mGameObject *go);
void gameobject_init(struct mGameObject *go, FILE * fprefab);
void gameobject_update(struct mGameObject *go);
void update_gameobjects();
void gameobject_move(struct mGameObject *go, float xs, float ys);
void gameobject_rotate(struct mGameObject *go, float as);
2022-08-12 14:03:56 -05:00
void object_gui(struct mGameObject *go);
2021-11-30 21:29:18 -06:00
#endif