Added day&night cycle. Also fixed world loading
Build / build (push) Has been cancelled

This commit is contained in:
milkwx3
2026-07-07 22:02:10 +03:00
parent 7ab2d5a083
commit 04d1969084
25 changed files with 3018 additions and 888 deletions
+11 -5
View File
@@ -11,7 +11,6 @@
#endif
#include <functional>
#include "glfw_keycodes_to_string.h"
#include "../PerlinNoise.hpp"
#include "raylib.h"
#include "raymath.h"
#include <stdint.h>
@@ -76,9 +75,9 @@
#define GAME_NAME "CubeGame"
#define GAME_VERSION_INT 0
#define DEFAULT_FONT_SIZE 16
#define TPS 30.0
#define TPS 30
#define TPS_DIV 1.0 / TPS
#define RENDER_DISTANCE 5
#define RENDER_DISTANCE 16
#define RENDER_DISTANCE_SQUARED RENDER_DISTANCE*RENDER_DISTANCE
#define MAX_HP 100
#define PATH_APPEND "resources/"
@@ -87,6 +86,8 @@
#define INVENTORY_WIDTH 8
#define INVENTORY_HEIGHT 6
#define INVENTORY_SIZE INVENTORY_WIDTH*INVENTORY_HEIGHT
#define WORLD_TIME_SECONDS (24*60)
#define WORLD_TIME_TICKS WORLD_TIME_SECONDS*TPS
enum BlockType {
B_Wood,
B_Stone,
@@ -311,7 +312,9 @@ int GetSkyLight(World&world,int x,int y,int z);
int GetRLight(World&world,int x,int y,int z);
int GetGLight(World&world,int x,int y,int z);
int GetBLight(World&world,int x,int y,int z);
Color GetSunlightColor();
Color GetLight(World&world,int x,int y,int z);
Color GetLightMesher(World&world,int x,int y,int z);
bool CanTick(int blockType);
bool GetCloud(int x,int z);
bool IsTranslucent(int blockType);
@@ -333,6 +336,7 @@ void RebuildLighting(World&world,int startX,int startZ);
#if !defined(SERVER)
ChunkRenderData GenerateCRDOpaque(Chunk&chunk,World&world);
ChunkRenderData GenerateCRDTranslucent(Chunk chunk,World&world);
ChunkRenderData GenerateCRDWater(Chunk chunk,World&world);
#endif
void SaveWorld(World&world,const char *path);
bool LoadWorld(World&world,const char *path);
@@ -444,10 +448,12 @@ const char *Pathify(const char *src);
const char *PathifyUser(const char *src);
#if !defined(SERVER)
void DrawCubeTexture(Texture2D texture,Vector3 position,float width,float height,float length,Color color,int offsetX,int offsetY,int sizeX,int sizeY);
void DrawCubeBlock(Texture2D texture,Vector3 position,float width,float height,float length,BlockDef def);
void DrawCubeBlock(Texture2D texture,Vector3 position,float width,float height,float length,BlockDef def,Color tint);
void DrawTextCodepoint3D(Font font,int codepoint,Vector3 position,float fontSize,bool backface,Color tint);
void DrawText3D(Font font,const char *text,Vector3 position,float fontSize,float fontSpacing,float lineSpacing,bool backface,Color tint);
#endif
RenderTexture2D LoadRenderTextureDepthTex(int width,int height);
void UnloadRenderTextureDepthTex(RenderTexture2D target);
inline uint8_t pack6(bool b0,bool b1,bool b2,bool b3,bool b4,bool b5){
return (uint8_t)(
((uint8_t)(b0 ? 1 : 0) << 0) |
@@ -619,7 +625,7 @@ void HotbarAddItemLots(Item *registry,int damage,int amount);
void InitHotbar();
void DrawHotbar();
InventoryItem HotbarGetSelected();
void DrawSelectedItem();
void DrawSelectedItem(Color tint);
void CloseInventory();
void UpdateHotbar();
void LocaleUpdate();