From 83d93f7803f23cd89bbea0962d77072100c9281d Mon Sep 17 00:00:00 2001 From: "Emilia(SleepeeSoftware)" Date: Mon, 9 Feb 2026 15:41:12 +0100 Subject: [PATCH] i am so tired --- README.md | 4 +- {source => games}/gamemode.c | 7 +- include/core.h | 4 +- include/engine.h | 125 +++++++++++++--------- source/client.c | 71 ++++++++++++ source/core_data.c | 21 ---- source/core_sorting.c | 5 - source/entity.c | 5 +- source/event.c | 22 ++-- source/item.c | 11 ++ source/main.c | 48 --------- source/{core_memory.c => not_used/core.c} | 20 +++- source/{ => not_used}/sandbox.c | 0 source/player.c | 16 +++ source/quest.c | 9 ++ source/render.c | 66 +++++++++--- source/serialization.c | 2 - source/world.c | 14 +++ 18 files changed, 288 insertions(+), 162 deletions(-) rename {source => games}/gamemode.c (82%) create mode 100644 source/client.c delete mode 100644 source/core_data.c delete mode 100644 source/core_sorting.c delete mode 100644 source/main.c rename source/{core_memory.c => not_used/core.c} (79%) rename source/{ => not_used}/sandbox.c (100%) create mode 100644 source/quest.c create mode 100644 source/world.c diff --git a/README.md b/README.md index 31302a6..003e071 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,9 @@ A lot of things should be hidden to the player, the player shouldn't know everyt # Good Idea and ressources: - [RPG Myths by Timothy Cain](https://www.youtube.com/watch?v=x-438XTmFBE) - [paper by Eric Chan Mit](https://people.csail.mit.edu/ericchan/papers/) + - [Motivational Talk About Art and IA](https://www.youtube.com/watch?v=mb3uK-_QkOo) - -# Quote i like: +# Quote i like or find fun: ``` “The most amazing achievement of the computer software industry is its continuing cancellation of the steady and staggering gains made by the computer hardware industry.” diff --git a/source/gamemode.c b/games/gamemode.c similarity index 82% rename from source/gamemode.c rename to games/gamemode.c index c7699d3..4b29b36 100644 --- a/source/gamemode.c +++ b/games/gamemode.c @@ -20,9 +20,11 @@ void BaseDefense() { } void BaseAssault() { + } void Diplomacy() { + } void Dungeon() { @@ -52,6 +54,9 @@ void Harvesting() { void Gathering() { } -void World_Exploration() { +void World_Exploration() { } +void SlimeDungeonAdventure() { + +} diff --git a/include/core.h b/include/core.h index 00cbfbc..6f8de4c 100644 --- a/include/core.h +++ b/include/core.h @@ -9,11 +9,9 @@ #include //#include #include - +#include #include #include -#include - #include #include diff --git a/include/engine.h b/include/engine.h index bd1ad69..e809dd4 100644 --- a/include/engine.h +++ b/include/engine.h @@ -107,11 +107,40 @@ typedef enum { QUEST_COMPLETE, } QUEST_STATE; +typedef enum { + ACTION_FORWARD, + ACTION_BACKWARD, + ACTION_LEFT, + ACTION_RIGHT, + ACTION_PRIMARY, + ACTION_SECONDARY, + ACTION_USE, + ACTION_GRAB, + ACTION_JUMP, + ACTION_DASH, + ACTION_SKILL1, + ACTION_TOOLBAR1, +} PLAYER_ACTION; + +typedef enum { + DENDRITIC_VOLTAGE, + LAZENBYCOMP_LIQUID, + LAZENBYCOMP_SMOOTH, + POTRA, +} FONTS_ENUM; + # endif #ifndef ENGINE_STRUCT # define ENGINE_STRUCT +typedef struct { + Font fonts[4];// + Texture textures;// + Model models;// + Sound sound; +} Assets; + // Render typedef struct { @@ -134,50 +163,48 @@ typedef struct { void* window; //RenderTexture rendtex; GBuffer gbuffer; - Camera3D camera; + Camera3D camera3d; + Camera2D camera2d; ShaderRD shader; bool hud_on, debug_on; } RenderCtx; // Event - typedef struct { EVENT_TYPE type; int value; + double time; + char* info; + int initiator; + int actors; + int actions; } Event; +//cities +//hideout +//tiles +//level +//npc +//clan +//army +//team + typedef struct { } Damage; -// Storage - typedef struct { - -} Inventory; - -// Entity - -typedef struct { - int id; -} virtualEntity; - -typedef struct { - int id; -} physicalEntity; - -typedef struct { - EVENT_TYPE trigger; + EVENT_TYPE trigger; ACTIVITY_STATE required_state; - bool (*condition)(virtualEntity e, Event ev); - void *(*effect)(virtualEntity e, Event ev); + bool (*condition)(int e, Event ev); + void *(*effect)(int e, Event ev); } virtualRule; typedef struct { - EVENT_TYPE trigger; + EVENT_TYPE trigger; ACTIVITY_STATE required_state; - bool (*condition)(physicalEntity e, Event ev); - void *(*effect)(physicalEntity e, Event ev); + bool (*condition)(int e, Event ev); + void *(*effect)(int e, Event ev); } physicalRule; typedef struct { @@ -204,13 +231,14 @@ typedef struct { } Limb; typedef struct { - Limb limbs[10]; + Limb limbs[10]; + BodyStats body_stats; + MentalStats mental_stats; } Body; typedef struct { Body body; - BodyStats body_stats; - MentalStats mental_stats; + int faction; ENTITY_STATE state;//can be multiple flag } Entity; @@ -218,17 +246,17 @@ typedef struct { typedef struct { int number; - int description;//ref to item description table - int name;//ref to item name table - int rarity; - int flags; + int description;//ref to item description table + int name;//ref to item name table + int rarity; + int flags; int stack; } Item; typedef struct { - int size; - int capacity; - Item *storage; + int size; + int capacity; + Item storage[100]; } Inventory; // Player @@ -236,7 +264,7 @@ typedef struct { typedef struct { char *name; char *gender; - char *nickname;//can be changed, what npc refers to, also npc do not know you until you interact with them + char *nickname;//can be changed, what npc refers to when talking to you, also npc do not know you until you interact with them } Identity; typedef struct { @@ -246,13 +274,13 @@ typedef struct { Entity entity; Identity identity; Skill skills[10]; + Inventory inventory; } Player; //give more enphasis on the character than the item used (~60% ,~30%) // Quest & Task - typedef struct { - int id; + int id; int prerequisite; int objectiv; int status;//unknow, known, accepted, achieved, completed, unavailable @@ -262,25 +290,18 @@ typedef struct { // Other Struct -typedef enum { - ACTION_FORWARD, - ACTION_BACKWARD, - ACTION_LEFT, - ACTION_RIGHT, -} PLAYER_ACTION; - typedef struct { int key[4];//should be the number of action in PLAYER_ACTION - int button; - int mbutton; + union { + int key; + int pad; + int mouse; + } press; Vector2 mouse_pos; Vector2 mouse_delta; //int mouse_pressed[2]; } Input; - - - # endif # ifndef ENGINE_PROTOTYPE @@ -289,12 +310,10 @@ typedef struct { //Render void LoadPipeline(); void UnloadPipeline(); -void Rendering(); -void LoadAssets(); -void UnloadAssets(); + //UI void UserInterface(); -void Menu(); +//void Menu(); # endif diff --git a/source/client.c b/source/client.c new file mode 100644 index 0000000..96963da --- /dev/null +++ b/source/client.c @@ -0,0 +1,71 @@ +#include + +Assets* LoadAssets() { + Assets *asset = (Assets *)calloc(sizeof(Assets), 1); + assert(asset); + //Font + asset->fonts[DENDRITIC_VOLTAGE] = LoadFont("assets/font/Dendritic_Voltage.ttf"); + asset->fonts[LAZENBYCOMP_LIQUID] = LoadFont("assets/font/LazenbyCompLiquid.ttf"); + asset->fonts[LAZENBYCOMP_SMOOTH] = LoadFont("assets/font/LazenbyCompSmooth.ttf"); + asset->fonts[POTRA] = LoadFont("assets/font/Potra.ttf"); + //Textures + //Models + //Sound + //Data + TraceLog(LOG_INFO, "Assets Loaded"); + return (asset); +} + +void UnloadAssets(Assets *asset) { + UnloadFont(asset->fonts[DENDRITIC_VOLTAGE]); + UnloadFont(asset->fonts[LAZENBYCOMP_LIQUID]); + UnloadFont(asset->fonts[LAZENBYCOMP_SMOOTH]); + UnloadFont(asset->fonts[POTRA]); + free(asset); +} + +void UpdateInput() { + const Input input; + int key = GetKeyPressed(); + Vector2 mouse_pos = GetMousePosition(); + Vector2 mouse_delta = GetMouseDelta(); + while (key) { + for (PLAYER_ACTION action = 0; action < 4; action++) { + if (input.key[action] == key) { + //emit("player_intent", action); + break; + } + } + key = GetKeyPressed(); + } +} + +//may be able to dispatch it +void GameLoop(const double tick_time) { + __thread static double time = 0; + + time += GetFrameTime(); + if (time >= tick_time) { + // interaction + // simulation + time = 0; + } +} + +int main(void) { + double tick_time = 0.4; + SetTraceLogLevel(LOG_ALL); + LoadPipeline(); + Assets *assets = LoadAssets(); + SetExitKey(KEY_NULL); + while (!WindowShouldClose()) { + UpdateInput(); + ComputeIntent(); + GameLoop(tick_time); + Rendering(); + } + UnloadAssets(assets); + assets = NULL;//to remember to not use it after + UnloadPipeline(); + return (0); +} diff --git a/source/core_data.c b/source/core_data.c deleted file mode 100644 index 2baea65..0000000 --- a/source/core_data.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include -#include -#include - - -//List - -//DAG - -//BinaryTree - -//QuadTree - -//OcTree - -//K-Tree - -//HashMap - diff --git a/source/core_sorting.c b/source/core_sorting.c deleted file mode 100644 index dafa061..0000000 --- a/source/core_sorting.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -//QuickSort -//RadixSort -//DepthSort used for transparancy in the scene diff --git a/source/entity.c b/source/entity.c index 701b067..f885864 100644 --- a/source/entity.c +++ b/source/entity.c @@ -10,7 +10,7 @@ int spawn_queue = 0; //lock queue when used int EntityUpdate(void) { - + } void EntityManager(void) { @@ -23,6 +23,9 @@ void EntityManager(void) { return; } +void SpawnEntity() { +} + void SpawnVisualEffect() { //spawn a timed entity used for a visuel effect } diff --git a/source/event.c b/source/event.c index 176ddae..249501d 100644 --- a/source/event.c +++ b/source/event.c @@ -1,17 +1,21 @@ #include +//should have a event structure, and a system can subscribe to an event, then whenever the event is triggered by a system, subscriber system should receive a signal. -void create(void) { +static Event *queue; + +void EventCreate(void) { + queue = calloc(100, sizeof(Event)); } -void subscribe(void) { +void EventSubscribe(int event_type, void (*callback)(int)) { //this should return an handle that allow to poll event that happen last frame + } -void emit(void) { - double currentTime = GetTime(); - int event_type = 0; - char* Information = "tmp"; - int initiator = 0; - int actors = 0; - int action = 0; +void EventEmit(Event event) { + printf("Event Emited"); +} + +void ConsoleUpdate() { + __thread static char *buffer[1024]; } diff --git a/source/item.c b/source/item.c index c17f13c..a56348c 100644 --- a/source/item.c +++ b/source/item.c @@ -1,3 +1,14 @@ #include +void ItemUsePrimary() { + +} + +void ItemUseSecondary() { + +} + +void ItemEquipe() { + +} diff --git a/source/main.c b/source/main.c deleted file mode 100644 index 40c79d8..0000000 --- a/source/main.c +++ /dev/null @@ -1,48 +0,0 @@ -#include - -void UpdateInput() { - const Input input; - int key = GetKeyPressed(); - Vector2 mouse_pos = GetMousePosition(); - Vector2 mouse_delta = GetMouseDelta(); - while (key) { - for (PLAYER_ACTION action = 0; action < 4; action++) { - if (input.key[action] == key) { - //emit("player_intent", action)l - break; - } - } - key = GetKeyPressed(); - } -} - -//may be able to dispatch it -void GameLoop(const double tick_time) { - __thread static double time = 0; - - time += GetFrameTime(); - if (time >= tick_time) { - // interaction - // simulation - time = 0; - } -} - -int main(void) { - double tick_time = 0.4; - SetTraceLogLevel(LOG_ALL); - LoadPipeline(); - LoadAssets(); - SetExitKey(KEY_NULL); - while (!WindowShouldClose()) { - UpdateInput(); - ComputeIntent(); - //DispatchWorker - GameLoop(tick_time); - //joinWorker - Rendering(); - } - UnloadAssets(); - UnloadPipeline(); - return (0); -} diff --git a/source/core_memory.c b/source/not_used/core.c similarity index 79% rename from source/core_memory.c rename to source/not_used/core.c index 7fdb8e9..d04076e 100644 --- a/source/core_memory.c +++ b/source/not_used/core.c @@ -1,4 +1,4 @@ -#include +#include // Frame Allocator @@ -41,3 +41,21 @@ void DeleteFrameAllocator() { // Ressource Allocator (PreComputed); // Fast Allocator; when the fram allocator is too short lived + +//QuickSort +//RadixSort +//DepthSort used for transparancy in the scene + +//List + +//DAG + +//BinaryTree + +//QuadTree + +//OcTree + +//K-Tree + +//HashMap diff --git a/source/sandbox.c b/source/not_used/sandbox.c similarity index 100% rename from source/sandbox.c rename to source/not_used/sandbox.c diff --git a/source/player.c b/source/player.c index 7fad085..166e3e6 100644 --- a/source/player.c +++ b/source/player.c @@ -6,3 +6,19 @@ the item focused have a description and stats windows on the left, the focused item is either the one under the mouse or can be choosen using arrow keys (easier controller support) */ + +void PlayerController2D() { + +} + +void PlayerController3D() { + +} + +void PlayerInventory() { + +} + +void PlayerUpdate() { + +} diff --git a/source/quest.c b/source/quest.c new file mode 100644 index 0000000..df6cc3c --- /dev/null +++ b/source/quest.c @@ -0,0 +1,9 @@ +#include + +void QuestFinish() { + +} + +void QuestSuccess() { + +} diff --git a/source/render.c b/source/render.c index 4d31cad..49437b8 100644 --- a/source/render.c +++ b/source/render.c @@ -71,7 +71,7 @@ void LoadPipeline() { rlEnableFramebuffer(ctx.gbuffer.framebufferId); ctx.gbuffer.depth_tex_id = rlLoadTextureDepth(ctx.width, ctx.height, false); - // If Artefact appear on Normal, may need to change to RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32 + // If Artefact appear on Normal, may need to change to RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32 and also need to be used in case of anti aliasing (MLAA or SMAA if needed) ctx.gbuffer.normal_tex_id = rlLoadTexture(NULL, ctx.width, ctx.height, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1); // The color in RGB, and the specular strength in the alpha channel ctx.gbuffer.albedoSpec_tex_id = rlLoadTexture(NULL, ctx.width, ctx.height, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1); @@ -109,14 +109,61 @@ void UnloadPipeline() { CloseWindow(); } +//arg should be a voxel asset +void VoxelRender(void) { -void Rendering() { +} + +void RenderingForward2D() { + BeginDrawing(); + BeginMode2D(ctx.camera2d); + EndMode2D(); + EndDrawing(); +} + +void RenderingForward3D() { + BeginDrawing(); + BeginMode3D(ctx.camera3d); + EndMode3D(); + EndDrawing(); +} + +void RenderingDeferred2D() { BeginDrawing(); ClearBackground(BLACK); rlEnableDepthMask(); rlEnableFramebuffer(ctx.gbuffer.framebufferId); rlEnableShader(ctx.shader.gbuffer.id); - BeginMode3D(ctx.camera); + BeginMode2D(ctx.camera2d); + //MainGeamoetry; + EndMode2D(); + rlDisableShader(); + rlDisableFramebuffer(); + rlDisableDepthMask();//may not be usefull + //rlDisableDepthTest(); + + //Light Pass and forward pass; + //I should build a shader that take every light in the scene and make a 3D heightmap of lighting then compute it once for all static light allowing to cheat computing everylight + //light is computed into a scalar field + + //Light Pass + + //Screen Filter Pass + BeginShaderMode(ctx.shader.filter);//may be good to have this disabled for accessibility + //DrawTextureRec(); + EndShaderMode(); + + //render ui + EndDrawing(); +} + +void RenderingDeferred3D() { + BeginDrawing(); + ClearBackground(BLACK); + rlEnableDepthMask(); + rlEnableFramebuffer(ctx.gbuffer.framebufferId); + rlEnableShader(ctx.shader.gbuffer.id); + BeginMode3D(ctx.camera3d); //MainGeamoetry; EndMode3D(); rlDisableShader(); @@ -138,16 +185,3 @@ void Rendering() { //render ui EndDrawing(); } - -void LoadAssets() { - //Font - //Textures - //Models - //Sound - //Data - TraceLog(LOG_INFO, "Assets Loaded"); -} - -void UnloadAssets() { - -} diff --git a/source/serialization.c b/source/serialization.c index 0635dcb..8c39a48 100644 --- a/source/serialization.c +++ b/source/serialization.c @@ -1,7 +1,6 @@ #include #include - //load setting.toml to memory void SettingLoad(const char *name) { FILE *file; @@ -21,7 +20,6 @@ void SettingUpdate() { SettingSave("setting.toml"); } - void CharacterLoad(const char *name) { FILE *file; file = fopen(name, "wb"); diff --git a/source/world.c b/source/world.c new file mode 100644 index 0000000..96f3b8d --- /dev/null +++ b/source/world.c @@ -0,0 +1,14 @@ +#include + +//map are layered 2D layer ? or 3D ? maybe simple 3D tiles +uint32_t VoxelPacked() { + return (0); +} + +void VoxelUnpack() { + +} + +void Tile() { + +}