working on adding a entity workflow
This commit is contained in:
0
source/game_source/CMakeLists.txt
Normal file
0
source/game_source/CMakeLists.txt
Normal file
8
source/game_source/color.h
Normal file
8
source/game_source/color.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
typedef struct {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
} color;
|
||||
#endif // !COLOR_H
|
||||
25
source/game_source/engine.c
Normal file
25
source/game_source/engine.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "engine.h"
|
||||
|
||||
int GameInit(AuthUser *auth, User *user){
|
||||
// init tart
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GameRun(User* user) {
|
||||
// game logic
|
||||
// display render
|
||||
}
|
||||
|
||||
void GameEnd() {
|
||||
// free objects
|
||||
}
|
||||
|
||||
int GetInput(char* buffer){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Render(char* outbuffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
25
source/game_source/engine.h
Normal file
25
source/game_source/engine.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef ENGIN_H
|
||||
#define ENGIN_H
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char* username;
|
||||
int userId;
|
||||
int runs;
|
||||
int hours;
|
||||
int currentServerId;
|
||||
} User;
|
||||
|
||||
typedef struct {
|
||||
char username[256];
|
||||
char password[256];
|
||||
} AuthUser;
|
||||
|
||||
int GameInit(AuthUser* auth, User* user);
|
||||
void GameRun(User* user);
|
||||
void GameEnd();
|
||||
void SetInput(char* buffer);
|
||||
int GetInput(char* buffer);
|
||||
int Render(char* outbuffer);
|
||||
|
||||
#endif // !ENGIN_H
|
||||
26
source/game_source/entities/Centery.c
Normal file
26
source/game_source/entities/Centery.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "Centery.h"
|
||||
#include "entity_utils.h"
|
||||
|
||||
int CreateCentery(int tear, int classification) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ServerUpdate(void * ent) {
|
||||
entity* e = (entity*)ent;
|
||||
centery* cen = (centery*)e->userdata;
|
||||
|
||||
if(
|
||||
|
||||
return 0;
|
||||
}
|
||||
int ClientUpdate(int action, void * centery) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Init(void * ent){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Free(void* ent) {
|
||||
return 0;
|
||||
}
|
||||
27
source/game_source/entities/Centery.h
Normal file
27
source/game_source/entities/Centery.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CENTERY_H
|
||||
#define CENTERY_H
|
||||
#include "../entity.h"
|
||||
|
||||
typedef struct {
|
||||
entity* target;
|
||||
int weapon;
|
||||
int classification;
|
||||
int tear;
|
||||
int alert;
|
||||
int mode;
|
||||
|
||||
int health;
|
||||
int ac;
|
||||
int str;
|
||||
int wis;
|
||||
int dex;
|
||||
} centery;
|
||||
|
||||
int CreateCentery(int tear, int classification);
|
||||
|
||||
int ServerUpdate(void*);
|
||||
int ClientUpdate(int, void*);
|
||||
int Init(void*);
|
||||
int Free(void*);
|
||||
|
||||
#endif // !CENTERY_H
|
||||
0
source/game_source/entities/Cypher.c
Normal file
0
source/game_source/entities/Cypher.c
Normal file
6
source/game_source/entities/Cypher.h
Normal file
6
source/game_source/entities/Cypher.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef CYPHER_H
|
||||
#define CYPHER_H
|
||||
#include "../entity.h"
|
||||
|
||||
#endif
|
||||
|
||||
0
source/game_source/entities/RAT.c
Normal file
0
source/game_source/entities/RAT.c
Normal file
0
source/game_source/entities/RAT.h
Normal file
0
source/game_source/entities/RAT.h
Normal file
0
source/game_source/entities/Rebuilder.c
Normal file
0
source/game_source/entities/Rebuilder.c
Normal file
0
source/game_source/entities/Rebuilder.h
Normal file
0
source/game_source/entities/Rebuilder.h
Normal file
0
source/game_source/entities/Reclamed.c
Normal file
0
source/game_source/entities/Reclamed.c
Normal file
0
source/game_source/entities/Reclamed.h
Normal file
0
source/game_source/entities/Reclamed.h
Normal file
0
source/game_source/entities/Reclamer.c
Normal file
0
source/game_source/entities/Reclamer.c
Normal file
0
source/game_source/entities/Reclamer.h
Normal file
0
source/game_source/entities/Reclamer.h
Normal file
0
source/game_source/entities/Servitor.c
Normal file
0
source/game_source/entities/Servitor.c
Normal file
0
source/game_source/entities/Servitor.h
Normal file
0
source/game_source/entities/Servitor.h
Normal file
0
source/game_source/entities/Walker.c
Normal file
0
source/game_source/entities/Walker.c
Normal file
0
source/game_source/entities/Walker.h
Normal file
0
source/game_source/entities/Walker.h
Normal file
0
source/game_source/entity.c
Normal file
0
source/game_source/entity.c
Normal file
52
source/game_source/entity.h
Normal file
52
source/game_source/entity.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef ENTITY_H
|
||||
#define ENTITY_H
|
||||
#include "vector.h"
|
||||
#include "tile.h"
|
||||
|
||||
typedef int(*entity_func)(void*);
|
||||
typedef int(*entity_update_func)(int, void*);
|
||||
|
||||
// Entity network transaction.
|
||||
typedef struct {
|
||||
int id;
|
||||
int action;
|
||||
int userdataSize;
|
||||
void* userdata;
|
||||
} entity_transaction;
|
||||
|
||||
// Entity Callbacks
|
||||
typedef struct {
|
||||
entity_func init;
|
||||
entity_update_func update;
|
||||
entity_func free;
|
||||
} entity_callbacks;
|
||||
|
||||
// Entity Struct
|
||||
typedef struct {
|
||||
int id;
|
||||
const char* name;
|
||||
const char* description;
|
||||
tile tile;
|
||||
vec2 position;
|
||||
void* userdata;
|
||||
entity_callbacks callback;
|
||||
entity_transaction ta;
|
||||
} entity;
|
||||
|
||||
entity* CreateEntity(const char* name, const char* description);
|
||||
int EntityAddCallbacks(entity* e, entity_callbacks cb);
|
||||
int EntitySetUserdat(entity* e, void* userdata);
|
||||
|
||||
// Gets
|
||||
const char* GetEntityDescription(entity* e);
|
||||
const char* GetEntityName(entity* e);
|
||||
|
||||
// Entity minipulation
|
||||
int EntityInit(entity* e);
|
||||
int EntityUpdate(entity* e, int action, void* userdata);
|
||||
int EntityFree(entity* e);
|
||||
|
||||
// Network
|
||||
int EntityTransaction(entity* e);
|
||||
|
||||
#endif
|
||||
0
source/game_source/entity_handler.c
Normal file
0
source/game_source/entity_handler.c
Normal file
29
source/game_source/entity_handler.h
Normal file
29
source/game_source/entity_handler.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef ENTITY_HEADER_H
|
||||
#define ENTITY_HEADER_H
|
||||
|
||||
#define ENTITY_LIST_ACTION_ADD
|
||||
#define ENTITY_LIST_ACTION_REMOVE
|
||||
#include "entity.h"
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
entity* entities[256];
|
||||
} entity_list;
|
||||
|
||||
typedef struct {
|
||||
int action;
|
||||
int sizeOfData;
|
||||
void* data;
|
||||
}entity_list_transaction;
|
||||
|
||||
void EntityListInit(entity_list* list);
|
||||
int EntityListAddEntity(entity* ent);
|
||||
int EntityListRemoveEntity(entity* ent);
|
||||
|
||||
int EntityListTransactionSet(entity_list_transaction* ta, int action, void* data);
|
||||
int EntityListTransactionSend(entity_list* list, entity_list_transaction* ta);
|
||||
|
||||
int EntityListUpdate();
|
||||
|
||||
|
||||
#endif
|
||||
0
source/game_source/entity_utils.c
Normal file
0
source/game_source/entity_utils.c
Normal file
10
source/game_source/entity_utils.h
Normal file
10
source/game_source/entity_utils.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef ENTITY_UTILS_H
|
||||
#define ENTITY_UTILS_H
|
||||
#include "entity_handler.h"
|
||||
#include "vector.h"
|
||||
|
||||
|
||||
int* GetEntitiesAroundPoint(entity_list* list, vec2 position, int radious);
|
||||
int* GetClosestEntity(entity_list* list, vec2 position);
|
||||
|
||||
#endif // !ENTITY_UTILS_H
|
||||
0
source/game_source/level.c
Normal file
0
source/game_source/level.c
Normal file
0
source/game_source/level.h
Normal file
0
source/game_source/level.h
Normal file
9
source/game_source/tile.h
Normal file
9
source/game_source/tile.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef TILE_H
|
||||
#define TILE_H
|
||||
#include "color.h"
|
||||
typedef struct {
|
||||
char simble;
|
||||
color forground;
|
||||
color background;
|
||||
} tile;
|
||||
#endif
|
||||
5
source/game_source/transaction.h
Normal file
5
source/game_source/transaction.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifndef TRANSACTION_H
|
||||
#define TRANSACTION_H
|
||||
|
||||
|
||||
#endif // !TRANSACTION_H
|
||||
12
source/game_source/vector.h
Normal file
12
source/game_source/vector.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef VECTOR_H
|
||||
#define VECTOR_H
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
} vec2;
|
||||
|
||||
vec2 vec2_add(vec2 a, vec2 b);
|
||||
vec2 vec2_sub(vec2 a, vec2 b);
|
||||
vec2 vec2_mul(vec2 a, vec2 b);
|
||||
vec2 vec2_dev(vec2 a, vec2 b);
|
||||
#endif
|
||||
Reference in New Issue
Block a user