diff --git a/README.md b/README.md index 003e071..08a2b68 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,8 @@ A lot of things should be hidden to the player, the player shouldn't know everyt Each step should have if possible an array of data, that can then be sliced and dispatched to multiple thread that do the same action (ex physique that have a thread for each local coordinate or for each entity and resolve collision later or before). maybe i could also make this work for spliting for each AI it's pathfinding into 2 but maybe not usefull?? TOOL THAT FUZZY FIND CURRENT TOKEN HOVERING OR AUTOCOMPLETION TO SHOW IN HEADER OR A FILE THE ENTRY IN A SIDE WINDOW AND MAYBE DOCUMENTATION (show definition of it). + +will playing my week of terrarria, i had 2 issue, first a lot of systems are just not really enjoyable like the fishing quest, not really fun. +and the other things, playing without the wiki is impossible in master mod, and some fight and weapon just feel bad. +bad the building, exploration and visiual of the game are wonderfull. +some of the npc are useless and it's sad, and their are not really that much variety in "viable" stuff, but again i might be missing some of the stuff as i didn't read all the wiki, but a good things to do is have all classes stuff and farm and have fun, but this game is a huge time sink diff --git a/include/engine.h b/include/engine.h index e809dd4..02821c2 100644 --- a/include/engine.h +++ b/include/engine.h @@ -234,6 +234,10 @@ typedef struct { Limb limbs[10]; BodyStats body_stats; MentalStats mental_stats; + int mass; + Vector3 pos; + Vector3 velocity; + int health; } Body; typedef struct { @@ -242,6 +246,11 @@ typedef struct { ENTITY_STATE state;//can be multiple flag } Entity; +typedef struct { + Entity entity; + void (*ai)(void); +} Mob; + // Item typedef struct { @@ -302,6 +311,12 @@ typedef struct { //int mouse_pressed[2]; } Input; +typedef struct { + int state; + Player player; + Assets assets; +} Context; + # endif # ifndef ENGINE_PROTOTYPE @@ -312,7 +327,7 @@ void LoadPipeline(); void UnloadPipeline(); //UI -void UserInterface(); +void UserInterface(const Player *player); //void Menu(); # endif diff --git a/source/client.c b/source/client.c index 96963da..1233933 100644 --- a/source/client.c +++ b/source/client.c @@ -1,5 +1,147 @@ #include +#include +#include +//#define RAYGUI_IMPLEMENTATION +//#include + +Context g_ctx; +RenderCtx r_ctx; + +/* + Audio + Video + Gameplay + Control + Accessibility + Filter +*/ +void RenderOption() { + +} + +void RenderInventory() { + //DrawTextureRec(); +} + +void DebugInterface() { + DrawFPS(10, 10); +} + +void UserInterface(const Player *player) { + //player stats + //player state and aliement + //health and other metric + //DrawTextureRec(); + DrawText(player->entity.body.health, 0, 0, 16, RED); +} + +void MainMenu() { + switch (g_ctx.state) { + case(0): { + break; + } + default: + break; + } +} + +void LoadCameraMode(int mode) { + switch (mode) { + case(0): { + break; + } + default: + break; + } +} + +void LoadPipeline() { + r_ctx.width = 800; + r_ctx.height = 480; + + r_ctx.hud_on = true; + r_ctx.debug_on = true; + InitWindow(r_ctx.width, r_ctx.height, "GAME!!"); + assert(IsWindowReady()); + r_ctx.window = GetWindowHandle(); + + r_ctx.shader.deferred = LoadShader("source/shader/deferred.vs", "source/shader/deferred.fs"); + r_ctx.shader.gbuffer = LoadShader("source/shader/gbuffer.vs", "source/shader/gbuffer.fs"); + r_ctx.shader.filter = LoadShader("", "source/shader/Screen_filter.fs"); + + r_ctx.gbuffer.framebufferId = rlLoadFramebuffer(); + assert(r_ctx.gbuffer.framebufferId); + + rlEnableFramebuffer(r_ctx.gbuffer.framebufferId); + r_ctx.gbuffer.depth_tex_id = rlLoadTextureDepth(r_ctx.width, r_ctx.height, false); + // 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) + r_ctx.gbuffer.normal_tex_id = rlLoadTexture(NULL, r_ctx.width, r_ctx.height, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1); + // The color in RGB, and the specular strength in the alpha channel + r_ctx.gbuffer.albedoSpec_tex_id = rlLoadTexture(NULL, r_ctx.width, r_ctx.height, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1); + rlActiveDrawBuffers(3); + + rlFramebufferAttach(r_ctx.gbuffer.framebufferId, r_ctx.gbuffer.depth_tex_id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_TEXTURE2D, 0); + rlFramebufferAttach(r_ctx.gbuffer.framebufferId, r_ctx.gbuffer.normal_tex_id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0); + rlFramebufferAttach(r_ctx.gbuffer.framebufferId, r_ctx.gbuffer.albedoSpec_tex_id, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0); + assert(rlFramebufferComplete(r_ctx.gbuffer.framebufferId)); + + rlEnableShader(r_ctx.shader.deferred.id); + int texUnitDepth = 0; + int texUnitNormal = 1; + int texUnitAlbedoSpec = 2; + SetShaderValue(r_ctx.shader.deferred, rlGetLocationUniform(r_ctx.shader.deferred.id, "gDepth"), &texUnitDepth, RL_SHADER_UNIFORM_SAMPLER2D); + SetShaderValue(r_ctx.shader.deferred, rlGetLocationUniform(r_ctx.shader.deferred.id, "gNormal"), &texUnitNormal, RL_SHADER_UNIFORM_SAMPLER2D); + SetShaderValue(r_ctx.shader.deferred, rlGetLocationUniform(r_ctx.shader.deferred.id, "gAlbedoSpec"), &texUnitAlbedoSpec, RL_SHADER_UNIFORM_SAMPLER2D); + rlDisableShader(); + //now need to set this to things that use this Material, and add light used in the scene. + + rlEnableDepthTest(); + rlEnableBackfaceCulling(); + TraceLog(LOG_INFO, "Render Pipeline Built"); + SetTargetFPS(120);//may change +} + +void UnloadPipeline() { + rlUnloadFramebuffer(r_ctx.gbuffer.framebufferId); + rlUnloadTexture(r_ctx.gbuffer.depth_tex_id); + rlUnloadTexture(r_ctx.gbuffer.normal_tex_id); + rlUnloadTexture(r_ctx.gbuffer.albedoSpec_tex_id); + UnloadShader(r_ctx.shader.deferred); + UnloadShader(r_ctx.shader.gbuffer); + UnloadShader(r_ctx.shader.filter); + CloseWindow(); +} + +void RenderingDeferred3D() { + BeginDrawing(); + ClearBackground(BLACK); + rlEnableDepthMask(); + rlEnableFramebuffer(r_ctx.gbuffer.framebufferId); + rlEnableShader(r_ctx.shader.gbuffer.id); + BeginMode3D(r_ctx.camera3d); + //MainGeamoetry; + EndMode3D(); + 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(r_ctx.shader.filter);//may be good to have this disabled for accessibility + //DrawTextureRec(); + EndShaderMode(); + + //render ui + EndDrawing(); +} + Assets* LoadAssets() { Assets *asset = (Assets *)calloc(sizeof(Assets), 1); assert(asset); diff --git a/source/entity.c b/source/entity.c index f885864..d915de5 100644 --- a/source/entity.c +++ b/source/entity.c @@ -18,12 +18,14 @@ void EntityManager(void) { while(!close_signal) { //update all entity data //spawn newentity from queue - //cull entity + //advance timed entity tick + //despawn dead or timed entity } return; } void SpawnEntity() { + } void SpawnVisualEffect() { diff --git a/source/player.c b/source/player.c index 166e3e6..f613699 100644 --- a/source/player.c +++ b/source/player.c @@ -22,3 +22,7 @@ void PlayerInventory() { void PlayerUpdate() { } + +void PlayerStats() { + // +} diff --git a/source/render.c b/source/render.c deleted file mode 100644 index 49437b8..0000000 --- a/source/render.c +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include -#include -//#define RAYGUI_IMPLEMENTATION -//#include - -RenderCtx ctx; - -/* - Audio - Video - Gameplay - Control - Accessibility - Filter -*/ -void RenderOption() { - -} - -void RenderInventory() { - //DrawTextureRec(); -} - -void DebugInterface() { - DrawFPS(10, 10); -} - -void UserInterface() { -} - - - -void MainMenu() { - int current_state; - switch (current_state) { - case(0): { - break; - } - default: - break; - } -} - -void LoadCameraMode(int mode) { - switch (mode) { - case(0): { - break; - } - default: - break; - } -} - -void LoadPipeline() { - ctx.width = 800; - ctx.height = 480; - - ctx.hud_on = true; - ctx.debug_on = true; - InitWindow(ctx.width, ctx.height, "GAME!!"); - assert(IsWindowReady()); - ctx.window = GetWindowHandle(); - - ctx.shader.deferred = LoadShader("source/shader/deferred.vs", "source/shader/deferred.fs"); - ctx.shader.gbuffer = LoadShader("source/shader/gbuffer.vs", "source/shader/gbuffer.fs"); - ctx.shader.filter = LoadShader("", "source/shader/Screen_filter.fs"); - - ctx.gbuffer.framebufferId = rlLoadFramebuffer(); - assert(ctx.gbuffer.framebufferId); - - 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 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); - rlActiveDrawBuffers(3); - - rlFramebufferAttach(ctx.gbuffer.framebufferId, ctx.gbuffer.depth_tex_id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_TEXTURE2D, 0); - rlFramebufferAttach(ctx.gbuffer.framebufferId, ctx.gbuffer.normal_tex_id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0); - rlFramebufferAttach(ctx.gbuffer.framebufferId, ctx.gbuffer.albedoSpec_tex_id, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0); - assert(rlFramebufferComplete(ctx.gbuffer.framebufferId)); - - rlEnableShader(ctx.shader.deferred.id); - int texUnitDepth = 0; - int texUnitNormal = 1; - int texUnitAlbedoSpec = 2; - SetShaderValue(ctx.shader.deferred, rlGetLocationUniform(ctx.shader.deferred.id, "gDepth"), &texUnitDepth, RL_SHADER_UNIFORM_SAMPLER2D); - SetShaderValue(ctx.shader.deferred, rlGetLocationUniform(ctx.shader.deferred.id, "gNormal"), &texUnitNormal, RL_SHADER_UNIFORM_SAMPLER2D); - SetShaderValue(ctx.shader.deferred, rlGetLocationUniform(ctx.shader.deferred.id, "gAlbedoSpec"), &texUnitAlbedoSpec, RL_SHADER_UNIFORM_SAMPLER2D); - rlDisableShader(); - //now need to set this to things that use this Material, and add light used in the scene. - - rlEnableDepthTest(); - rlEnableBackfaceCulling(); - TraceLog(LOG_INFO, "Render Pipeline Built"); - SetTargetFPS(120);//may change -} - -void UnloadPipeline() { - rlUnloadFramebuffer(ctx.gbuffer.framebufferId); - rlUnloadTexture(ctx.gbuffer.depth_tex_id); - rlUnloadTexture(ctx.gbuffer.normal_tex_id); - rlUnloadTexture(ctx.gbuffer.albedoSpec_tex_id); - UnloadShader(ctx.shader.deferred); - UnloadShader(ctx.shader.gbuffer); - UnloadShader(ctx.shader.filter); - CloseWindow(); -} - -//arg should be a voxel asset -void VoxelRender(void) { - -} - -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); - 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(); - 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(); -}