Shitty Wood

This commit is contained in:
2025-01-30 01:56:36 -05:00
parent a2ec22aab7
commit 915371004d
5 changed files with 81 additions and 16 deletions

View File

@@ -79,7 +79,7 @@ namespace CaveGame::Client {
Core::TileID HotbarItems[10] = {
Core::TileID::GRASS, Core::TileID::STONE, Core::TileID::WATER, Core::TileID::LAVA, Core::TileID::GREEN_MOSS, Core::TileID::SAND,
Core::TileID::CLAY, Core::TileID::CLOUD, Core::TileID::COBBLESTONE, Core::TileID::ICE
Core::TileID::CLAY, Core::TileID::OAK_PLANK, Core::TileID::COBBLESTONE, Core::TileID::ICE
};
GameSession() = default;
GameSession(bool createNewWorld);

View File

@@ -138,5 +138,7 @@ namespace CaveGame::Client
static Color4 GetSkyColorBaseForTimeOfDay(float time);
void DrawSky();
void RenderTile(const Core::TileID &tid, int wx, int wy, int tx, int ty);
};
}

View File

@@ -8,6 +8,8 @@
#include "JUI/Widgets/TextRect.hpp"
#include "JUI/UDim.hpp"
#include <JUI/Widgets/ImageRect.hpp>
#include <JUI/Widgets/Image.hpp>
void CaveGame::Client::GameSession::Unload() {
Scene::Unload();
@@ -146,6 +148,9 @@ void CaveGame::Client::GameSession::ConstructHUD() {
cell->PaddingRight(5_px);
cell->BGColor(item->base_color);
// Add tile-sample rendertarget as item icon.
auto* img = new JUI::Image();
auto* amount_label = new JUI::TextRect(cell);
amount_label->BGColor({0,0,0,0});
amount_label->AnchorPoint({1,1});

View File

@@ -7,6 +7,7 @@
#include <JUI/Widgets/Scene.hpp>
namespace CaveGame::Client {
using namespace CaveGame::Core;
LocalWorld::LocalWorld(const std::string& world_name, int seed, bool overwrite)
: World(world_name, seed, overwrite) {
@@ -180,8 +181,8 @@ namespace CaveGame::Client {
// Debug Grid
if (chunk_debug.IsEnabled())
{
chunk_debug.DrawStats(chunk, 0.99f / camera.Zoom());
chunk_debug.DrawCellCoords(chunk_pos, 0.99f / camera.Zoom());
//chunk_debug.DrawStats(chunk, 0.99f / camera.Zoom());
//chunk_debug.DrawCellCoords(chunk_pos, 0.99f / camera.Zoom());
}
}
@@ -226,6 +227,63 @@ namespace CaveGame::Client {
RNG rng;
void LocalWorld::RenderTile(const TileID& t_id, int wx, int wy, int tx, int ty)
{
if (t_id == TileID::AIR || t_id == TileID::VOID) // Air
return;
Color4 t_color;
Core::Tile* t_data = Core::GetByNumeric(t_id);
if (t_id == TileID::COBBLESTONE) {
float val = generator.Perlin(wx, wy, 12, 12, 12, 2);
if (val > 0.60f || val < -0.60f)
t_color = Core::Tiles::Cobblestone.color_pallet[1];
else if (val > 0.40f || val < -0.40f)
t_color = Core::Tiles::Cobblestone.color_pallet[0];
else if (val > 0.2f || val < -0.2f)
t_color = Core::Tiles::Cobblestone.color_pallet[2];
else
t_color = Core::Tiles::Cobblestone.color_pallet[3];
//Core::Tiles::Cobblestone.color_pallet
} else if (t_id == TileID::OAK_PLANK) {
float x_remainder = Math::Mod(wx, 4);
float y_remainder = Math::Mod(wy, 9);
//int row_offset = wy
int plank_row_idx = ((int)Math::Floor(wy/5)) % 5;
int plank_length_modulus = 0;
if (plank_row_idx == 0) plank_length_modulus = -7;
if (plank_row_idx == 1) plank_length_modulus = 3;
if (plank_row_idx == 2) plank_length_modulus = 9;
if (plank_row_idx == 3) plank_length_modulus = 0;
if (plank_row_idx == 4) plank_length_modulus = 13;
// Looks good for brick.
//if (wy % 5 == 0 || ((Math::RoundInt(wy/5)*5)+wx) % 9 == 0) { //&& (y_remainder == 0)) {
if (wy % 5 == 0 || (wx+plank_length_modulus) % 19 == 0) { //&& (y_remainder == 0)) {
t_color = Colors::Browns::Brown;
} else {
t_color = Colors::Browns::BurlyWood;
}
} else if (t_data->has_color_pallet) {
uint rand = generator.ColorMap(t_data->color_pallet.size(), wx, wy);
t_color = t_data->color_pallet[rand];
} else {
t_color = t_data->base_color;
}
JGL::J2D::DrawPoint(t_color, tx, ty);
}
void LocalWorld::RenderChunkTexture(const Vector2i &coords, JGL::RenderTarget* destination, Core::Chunk* chunk)
{
@@ -238,12 +296,6 @@ namespace CaveGame::Client {
Core::Tile* t_data;
Color4 t_color;
//std::vector<Vector2> stone_coords;
//std::vector<Vector2> dirt_coords;
//std::vector<Vector2> grass_coords;
//std::vector<Vector2> clay_coords;
//std::vector<Vector2> mud_coords;
JGL::J2D::Begin(destination, true);
for (int x = 0; x < Core::Chunk::ChunkSize; x++)
{
@@ -253,8 +305,8 @@ namespace CaveGame::Client {
Vector2 relative_tile_coords = Vector2(x, y);
const Vector2& tile_coords = relative_tile_coords;
int wx = (x*Core::Chunk::ChunkSize) + x;
int wy = (y*Core::Chunk::ChunkSize) + y;
int wx = (coords.x*Core::Chunk::ChunkSize) + x;
int wy = (coords.y*Core::Chunk::ChunkSize) + y;
#ifdef DEBUG_TILE_UPDATES
@@ -265,14 +317,13 @@ namespace CaveGame::Client {
JGL::J2D::DrawPoint(Color4(255, 0, 0, 128), tile_coords);
#endif
if (t_id == TileID::AIR || t_id == TileID::VOID) // Air
continue;
RenderTile(t_id, wx, wy, x, y);
t_data = Core::GetByNumeric(t_id);
/*t_data = Core::GetByNumeric(t_id);
if (t_id == TileID::COBBLESTONE) {
float val = generator.Perlin(wx, wy, 12, 12, 12, 2);
@@ -286,6 +337,13 @@ namespace CaveGame::Client {
else
t_color = Core::Tiles::Cobblestone.color_pallet[3];
//Core::Tiles::Cobblestone.color_pallet
} else if (t_id == TileID::OAK_PLANK) {
if (Math::Mod(y, 3) == 0 || Math::Mod(x, 9) == 0) {
t_color = Colors::Browns::Brown;
} else
t_color = Colors::Browns::BurlyWood;
} else if (t_data->has_color_pallet) {
uint rand = generator.ColorMap(t_data->color_pallet.size(), x, y);
t_color = t_data->color_pallet[rand];
@@ -293,7 +351,7 @@ namespace CaveGame::Client {
t_color = t_data->base_color;
}
JGL::J2D::DrawPoint(t_color, tile_coords);
JGL::J2D::DrawPoint(t_color, tile_coords);*/
}
}

View File

@@ -607,7 +607,7 @@ namespace CaveGame::Core {
static const SaplingTile OakSapling;
static const Tile OakLog {ID::OAK_LOG, "Oak Log", Colors::Browns::BurlyWood};
static const Tile OakPlank;
static const Tile OakPlank {ID::OAK_PLANK, "Oak Plank", Colors::Browns::BurlyWood};
static const Tile OakPlatform;
static const Tile OakLeaf;