Colored block lighting

This commit is contained in:
milkwx3
2026-06-24 20:25:11 +03:00
parent d02d751275
commit 85ddc90883
6 changed files with 217 additions and 25 deletions
+8 -5
View File
@@ -78,7 +78,7 @@
#define DEFAULT_FONT_SIZE 16
#define TPS 30.0
#define TPS_DIV 1.0 / TPS
#define RENDER_DISTANCE 2
#define RENDER_DISTANCE 5
#define RENDER_DISTANCE_SQUARED RENDER_DISTANCE*RENDER_DISTANCE
#define MAX_HP 100
#define PATH_APPEND "resources/"
@@ -307,6 +307,9 @@ extern const BlockDef BLOCKS[];
int GetBlock(World&world,int x,int y,int z);
int GetHighestBlock(World&world,int x,int z);
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 GetLight(World&world,int x,int y,int z);
bool CanTick(int blockType);
bool GetCloud(int x,int z);
@@ -463,10 +466,10 @@ inline void unpack6(uint8_t v,bool *b0,bool *b1,bool *b2,bool *b3,bool *b4,bool
*b5 = (v >> 5) & 1;
};
inline void GetXYZFromIndex(int index,int *x,int *y,int *z){
*x = index & 15;
int tmp = index << 4;
*z = tmp & 15;
*y = tmp << 4;
*y = index / (CHUNK_SIZE * CHUNK_SIZE);
int rem = index % (CHUNK_SIZE * CHUNK_SIZE);
*z = rem / CHUNK_SIZE;
*x = rem % CHUNK_SIZE;
};
inline int GetIndexChunk(int x,int y,int z){
if(x < 0 || y < 0 || z < 0 || x >= CHUNK_SIZE || y >= WORLD_HEIGHT || z >= CHUNK_SIZE) return 0;