I have no idea what this error means.

This commit is contained in:
2024-12-25 16:51:22 -05:00
parent 8e8ad07d59
commit 32d27767c3
17 changed files with 211 additions and 59 deletions

View File

@@ -26,9 +26,14 @@ CPMAddPackage(
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-5.zip
)
CPMAddPackage(
NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip
)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/3.4.3.zip
URL https://git.redacted.cc/josh/j3ml/archive/3.4.4.zip
)
CPMAddPackage(

View File

@@ -83,6 +83,8 @@ namespace CaveGame::Client {
void UnloadHUD();
Core::TileID GetTileUnderMouse();
void HUDTick()
{
for (int i = 0; i < 10; i++)

View File

@@ -4,6 +4,8 @@
#include <JUI/Widgets/ListLayout.hpp>
#include <JUI/UDim.hpp>
#include <JUI/UDim2.hpp>
#include <rewindow/inputservice.hpp>
#include "JUI/Widgets/TextRect.hpp"
#include "JUI/UDim.hpp"
@@ -160,3 +162,8 @@ void CaveGame::Client::GameSession::UnloadHUD() {
Logs::Info("Unloading player HUD.");
delete hud;
}
CaveGame::Core::TileID CaveGame::Client::GameSession::GetTileUnderMouse() {
Vector2 coords = world->camera.ScreenToWorld(InputService::GetMousePosition());
return world->GetTile(coords.x, coords.y);
}

View File

@@ -140,7 +140,7 @@ namespace CaveGame::Client {
glClearColor(base_bg_color.RN(), base_bg_color.GN(), base_bg_color.BN(),1.f);
if ()
//if ()
}
@@ -189,6 +189,13 @@ namespace CaveGame::Client {
// Banana for scale.
JGL::J2D::FillRect(Colors::Yellow, {0,0}, {32, 48});
for (auto* entity : entities) {
entity->Draw();
}
JGL::J2D::End();

View File

@@ -27,6 +27,8 @@ target_include_directories(CaveClientApp PUBLIC "include")
target_link_libraries(CaveClientApp PUBLIC CaveClient ReWindowLibrary J3ML JGL )
target_compile_definitions(CaveClientApp PUBLIC CAVE_CLIENT true)
if (CLIENT_BUILD_WITH_STEAM)
target_compile_definitions(CaveClientApp PUBLIC STEAM_BUILD)

View File

@@ -1,5 +1,7 @@
#pragma once
#include <Core/AssetService.hpp>
#include "J3ML/Geometry.hpp"
#include "Client/Splash.hpp"
#include "Client/MainMenu.hpp"
@@ -27,6 +29,7 @@ namespace CaveGame::ClientApp
[[nodiscard]] bool InGameSession() const;
[[nodiscard]] bool InMainMenu() const;
Core::AssetService assets;
CaveGame::Client::Splash* splash_ctx;
CaveGame::Client::MainMenu* menu_ctx;
CaveGame::Client::GameSession* game_ctx;

View File

@@ -1,6 +1,7 @@
#include <Client/CreditsWindow.hpp>
#include "ClientApp/CaveGameWindow.hpp"
#include <Core/Loggers.hpp>
#include <rewindow/inputservice.hpp>
namespace CaveGame::ClientApp
{
@@ -75,6 +76,7 @@ namespace CaveGame::ClientApp
// TODO: Implement Resource/Asset manager rather than passing asset references around like this.
this->menu_ctx->BuildWidgets();
this->assets.EnqueueDefaultAssetsFolder();
this->ChangeScene(this->splash_ctx);
Gameloop();
@@ -259,16 +261,27 @@ namespace CaveGame::ClientApp
// Draw floating windows.
wm->Draw();
draw_debug_info({
"Re-CaveGame - Redacted Software",
std::format("frame: {}", refresh_count),
std::format("delta: {}ms", J3ML::Math::Round(delta_time*1000)),
std::format("fps: {}", J3ML::Math::Round(refresh_rate)),
std::format("avg: {}", J3ML::Math::Round(avg_refresh_rate))
});
std::vector<std::string> debug_lines =
{
"Re-CaveGame - Redacted Software",
std::format("frame: {}", refresh_count),
std::format("delta: {}ms", J3ML::Math::Round(delta_time*1000)),
std::format("fps: {}", J3ML::Math::Round(refresh_rate)),
std::format("avg: {}", J3ML::Math::Round(avg_refresh_rate))
};
if (current_scene == game_ctx) {
Core::TileID id = game_ctx->GetTileUnderMouse();
Core::Tile* data = Core::GetByNumeric(id);
//debug_lines.push_back(std::format("tile: {} id: {}", data->MnemonicID(), (uint)data->NumericID()));
//debug_lines.push_back(std::format("entities: {}", game_ctx->world->GetCurrentEntityCount()));
}
draw_debug_info(debug_lines);
}
@@ -310,6 +323,15 @@ namespace CaveGame::ClientApp
//Die();
if (ev.key == Keys::P) {
if (current_scene == game_ctx) {
auto* plr = new Core::Player(InputService::GetMousePosition());
game_ctx->world->AddEntity(plr);
}
}
if (current_scene != nullptr)
current_scene->PassKeyInput(ev.key, true);

View File

@@ -0,0 +1,62 @@
/// The AssetService is a class / static library that manages on-file game assets.
/// This class service provides asynchronous loading of game content, with introspection for hooking to a loading menu.
#pragma once
#include <string>
#include <unordered_map>
#include <filesystem>
#include <iostream>
namespace JGL {
class Texture;
class Font;
}
namespace CaveGame::Core
{
struct Asset {
std::string name;
std::string metadata;
std::string type;
};
class AssetService {
public:
AssetService() {}
~AssetService() {}
/// Performs one "Load Cycle" on the current thread. This means we will attempt to load a number of queued items until we've spent at least maxTTL seconds.
void LoadCycle(float maxTTL = 1e-3f);
unsigned int TotalAssetsQueued() const;
unsigned int TotalAssetsLoaded() const;
unsigned int AssetsToBeLoaded() const;
JGL::Texture* GetTexture(const std::string& textureName) {
return textures[textureName];
}
JGL::Font* GetFont(const std::string& fontName) {
return fonts[fontName];
}
void EnqueueTexture(const std::string& texName);
void EnqueueFont(const std::string& fontName);
void EnqueueDefaultAssetsFolder();
void EnqueueContents(const std::filesystem::path& folder) {
for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) {
if (entry.is_regular_file()) {
std::cout << entry << std::endl;
}
}
}
protected:
std::unordered_map<std::string, JGL::Font*> fonts;
std::unordered_map<std::string, JGL::Texture*> textures;
};
}

View File

@@ -43,7 +43,7 @@ namespace CaveGame::Core
GREEN_MOSS, RED_MOSS, BROWN_MOSS, LAVA_MOSS,
SNOW, PACKED_SNOW,
ICE, PACKED_ICE, ICE_BRICK, THIN_ICE,
SLUSH,
SAND, WET_SAND,
SANDSTONE, SAND_BRICK,
RED_SAND, RED_SANDSTONE, RED_SAND_BRICK,
@@ -118,6 +118,10 @@ namespace CaveGame::Core
COPPER_ORE,
IRON_ORE,
COAL_ORE,
LEAD_ORE,
SILVER_ORE,
GOLD_ORE,
TUNGSTEN_ORE,
NICKEL_ORE,
CHROMIUM_ORE,
TITANIUM_ORE,
@@ -126,6 +130,9 @@ namespace CaveGame::Core
URANIUM_ORE,
MAGNETITE_ORE,
METEORITE_ORE,
PLATINUM_ORE,
COBALT_ORE,
SOVITE, PYRITE, CINNABAR,

View File

@@ -10,6 +10,9 @@ namespace CaveGame::Core {
class Entity {
public:
explicit Entity(const Vector2& spawnPoint);
int Health() const { return health; }
int MaxHealth() const { return max_health; }
@@ -33,6 +36,9 @@ namespace CaveGame::Core {
class PhysicsEntity : public Entity {
public:
explicit PhysicsEntity(const Vector2& spawnPoint) : Entity(spawnPoint) {}
[[nodiscard]] Vector2 Velocity() const { return velocity; }
[[nodiscard]] Vector2 EstimatedNextPosition() const { return next_position; }
@@ -49,15 +55,18 @@ namespace CaveGame::Core {
class Humanoid : public PhysicsEntity {
public:
virtual int BaseDefense() const;
explicit Humanoid(const Vector2& spawnPoint) : PhysicsEntity(spawnPoint) { }
virtual int BaseDefense() const { return 0; }
virtual int ArmorDefense() const
{
return 0;
}
virtual int DefenseModifier() const;
virtual int DefenseModifier() const { return 0;}
int Defense() const
{
return 0;
}
protected:
};
@@ -73,6 +82,11 @@ namespace CaveGame::Core {
class Player : public Humanoid {
public:
explicit Player(const Vector2& spawnPoint) : Humanoid(spawnPoint) { }
void Draw() override;
void Update(float elapsed) override;
void Jump();
void Climb();
void Descend();

View File

@@ -42,88 +42,88 @@ namespace CaveGame::Core
#pragma endregion
#pragma region Ore Vein Parameters
static constexpr Vector2 ClayVeinHiPassScale = {200.f, 205.f};
const Vector2 ClayVeinHiPassScale = {200.f, 205.f};
static constexpr float ClayVeinHiPassOffset = 0.f;
static constexpr float ClayVeinHiPassOutputScale = 2.2f;
static constexpr Vector2 ClayVeinLoPassScale = {17.f, 15.f};
const Vector2 ClayVeinLoPassScale = {17.f, 15.f};
static constexpr float ClayVeinLoPassOffset = 420.f;
static constexpr float ClayVeinLoPassOutputScale = 1.2f;
static constexpr float ClayVeinNoise = 0.175f;
static constexpr float ClayVeinRampFactor = 2.f;
static constexpr Vector2 SiltVeinHiPassScale = {220.f, 205.f};
const Vector2 SiltVeinHiPassScale = {220.f, 205.f};
static constexpr float SiltVeinHiPassOffset = 5.f;
static constexpr float SiltVeinHiPassOutputScale = 2.2f;
static constexpr Vector2 SiltVeinLoPassScale = {27.f, 25.f};
const Vector2 SiltVeinLoPassScale = {27.f, 25.f};
static constexpr float SiltVeinLoPassOffset = 422.f;
static constexpr float SiltVeinLoPassOutputScale = 1.25f;
static constexpr float SiltVeinNoise = 0.175f;
static constexpr float SiltVeinRampFactor = 2.f;
static constexpr Vector2 StoneVeinHiPassScale = {30.f, 30.f};
const Vector2 StoneVeinHiPassScale = {30.f, 30.f};
static constexpr float StoneVeinHiPassOffset = 666.f;
static constexpr float StoneVeinHiPassOutputScale = 2.4f;
static constexpr Vector2 StoneVeinLoPassScale = {220.f, 220.f};
const Vector2 StoneVeinLoPassScale = {220.f, 220.f};
static constexpr float StoneVeinLoPassOffset = 0.5f;
static constexpr float StoneVeinLoPassOutputScale = 1.75f;
static constexpr float StoneVeinNoise = 0.25f;
static constexpr float StoneVeinRampFactor = 1.75f;
static constexpr Vector2 DirtVeinHiPassScale = {30.f, 30.f};
const Vector2 DirtVeinHiPassScale = {30.f, 30.f};
static constexpr float DirtVeinHiPassOffset = 12.f;
static constexpr float DirtVeinHiPassOutputScale = 1.35f;
static constexpr Vector2 DirtVeinLoPassScale = {90.f, 90.f};
const Vector2 DirtVeinLoPassScale = {90.f, 90.f};
static constexpr float DirtVeinLoPassOffset = 0.5f;
static constexpr float DirtVeinLoPassOutputScale = 0.75f;
static constexpr float DirtVeinNoise = 0.05f;
const float DirtVeinNoise = 0.05f;
static constexpr float DirtVeinRampFactor = 0.5f;
static constexpr Vector2 CoalVeinHiPassScale = {30.f, 30.f};
const Vector2 CoalVeinHiPassScale = {20.f, 20.f};
static constexpr float CoalVeinHiPassOffset = 12.f;
static constexpr float CoalVeinHiPassOutputScale = 1.35f;
static constexpr float CoalVeinHiPassOutputScale = 1.05f;
static constexpr Vector2 CoalVeinLoPassScale = {90.f, 90.f};
const Vector2 CoalVeinLoPassScale = {120.f, 120.f};
static constexpr float CoalVeinLoPassOffset = 0.5f;
static constexpr float CoalVeinLoPassOutputScale = 0.75f;
static constexpr float CoalVeinLoPassOutputScale = 0.83f;
static constexpr float CoalVeinNoise = 0.05f;
static constexpr float CoalVeinRampFactor = 0.5f;
static constexpr float CoalVeinNoise = 0.45f;
static constexpr float CoalVeinRampFactor = 0.75f;
static constexpr Vector2 CopperVeinHiPassScale = {30.f, 30.f};
const Vector2 CopperVeinHiPassScale = {30.f, 30.f};
static constexpr float CopperVeinHiPassOffset = 12.f;
static constexpr float CopperVeinHiPassOutputScale = 1.35f;
static constexpr Vector2 CopperVeinLoPassScale = {90.f, 90.f};
const Vector2 CopperVeinLoPassScale = {90.f, 90.f};
static constexpr float CopperVeinLoPassOffset = 0.5f;
static constexpr float CopperVeinLoPassOutputScale = 0.75f;
static constexpr float CopperVeinNoise = 0.05f;
static constexpr float CopperVeinRampFactor = 0.5f;
static constexpr Vector2 TinVeinHiPassScale = {30.f, 30.f};
const Vector2 TinVeinHiPassScale = {30.f, 30.f};
static constexpr float TinVeinHiPassOffset = 12.f;
static constexpr float TinVeinHiPassOutputScale = 1.35f;
static constexpr Vector2 TinVeinLoPassScale = {90.f, 90.f};
const Vector2 TinVeinLoPassScale = {90.f, 90.f};
static constexpr float TinVeinLoPassOffset = 0.5f;
static constexpr float TinVeinLoPassOutputScale = 0.75f;
static constexpr float TinVeinNoise = 0.05f;
static constexpr float TinVeinRampFactor = 0.5f;
static constexpr Vector2 IronVeinHiPassScale = {30.f, 30.f};
const Vector2 IronVeinHiPassScale = {30.f, 30.f};
static constexpr float IronVeinHiPassOffset = 12.f;
static constexpr float IronVeinHiPassOutputScale = 1.35f;
static constexpr Vector2 IronVeinLoPassScale = {90.f, 90.f};
const Vector2 IronVeinLoPassScale = {90.f, 90.f};
static constexpr float IronVeinLoPassOffset = 0.5f;
static constexpr float IronVeinLoPassOutputScale = 0.75f;

View File

@@ -9,8 +9,6 @@
#include <Core/Interfaces.hpp>
#include <J3ML/LinearAlgebra/Vector2i.hpp>
#include "Tile.hpp"
namespace CaveGame::Core
{
using J3ML::LinearAlgebra::Vector2i;
@@ -290,19 +288,19 @@ namespace CaveGame::Core
static const Tile RainCloud;
static const Tile Cobweb;
static const Tile Coal;
static const Tile Coal {ID::COAL_ORE, "Coal Ore", Colors::Black};
static const Tile CopperOre {ID::COPPER_ORE, "Copper Ore", Colors::Oranges::DarkOrange};
static const Tile CopperOre {ID::COPPER_ORE, "Copper Ore", Colors::Oranges::DarkOrange, {{255, 140, 0}, {234, 150, 3}, {241, 138, 5}}};
static const Tile TinOre {ID::TIN_ORE, "Tin Ore", Colors::Grays::Gainsboro};
static const Tile IronOre {ID::IRON_ORE, "Iron Ore", Colors::Pinks::LightPink};
static const Tile LeadOre;
static const Tile SilverOre;
static const Tile TungstenOre;
static const Tile GoldOre;
static const Tile PlatinumOre;
static const Tile CobaltOre;
static const Tile TitaniumOre;
static const Tile UraniumOre;
static const Tile LeadOre {ID::LEAD_ORE, "Lead Ore", Colors::Grays::DarkSlateGray};
static const Tile SilverOre {ID::SILVER_ORE, "Silver Ore", Colors::Grays::Silver};
static const Tile TungstenOre {ID::TUNGSTEN_ORE, "Tungsten Ore", Colors::Grays::DimGray};
static const Tile GoldOre {ID::GOLD_ORE, "Gold Ore", Colors::Oranges::Gold};
static const Tile PlatinumOre {ID::PLATINUM_ORE, "Platinum Ore", Colors::Grays::Silver};
static const Tile CobaltOre {ID::COBALT_ORE, "Cobalt Ore", Colors::Blues::MediumSlateBlue};
static const Tile TitaniumOre {ID::TITANIUM_ORE, "Titanium Ore", Colors::Grays::DimGray};
static const Tile UraniumOre {ID::URANIUM_ORE, "Uranium Ore", Colors::Greens::GreenYellow};
static const Tile Diamond;
static const Tile Emerald;

View File

@@ -97,6 +97,10 @@ namespace CaveGame::Core
entities.push_back(std::move(&e));
}
unsigned int GetCurrentEntityCount() const {
return entities.size();
}
protected:
void SaveChunkToFile(const Vector2 &cell, const Chunk &chunk);
std::future<bool> SaveChunkToFileAsync(const Vector2& cell, const Chunk& chunk);

View File

@@ -0,0 +1,12 @@
#include <Core/AssetService.hpp>
#ifdef CAVE_CLIENT
#include <JGL/Texture.hpp>
#endif CAVE_CLIENT
void CaveGame::Core::AssetService::EnqueueDefaultAssetsFolder() {
//EnqueueContents("assets");
#ifdef CAVE_CLIENT
textures.emplace("player", new JGL::Texture("assets/textures/player.png"));
#endif
}

View File

@@ -1 +1,16 @@
#include <Core/Entity.hpp>
#include <Core/Entity.hpp>
CaveGame::Core::Entity::Entity(const Vector2 &spawnPoint) {
position = spawnPoint;
}
void CaveGame::Core::Player::Draw() {
#ifdef CAVE_CLIENT
JGL::J2D::DrawPartialSprite();
#endif
}
void CaveGame::Core::Player::Update(float elapsed) {
}

View File

@@ -144,10 +144,6 @@ namespace CaveGame::Core
if (silt_pass > 0.85f) { return TileID::SILT; }
if (silt_pass < -0.75f) { return TileID::DIRT; }
//float stone_pass_1 = perlin.Noise(wx / 30.f, wy / 30.f, 666.f) * 2.4f;
//float stone_pass_2 = perlin.Noise(wx / 220.f, wy / 220.f, 0.5f) * 1.75f;
//float stone_pass = stone_pass_1 + stone_pass_2 + (stone_pass_1 * stone_pass_2 / 1.75f) + (rng*1.5f);
// Chunks of stone.
float stone_pass = ComputeOre(wx, wy, StoneVeinHiPassScale, StoneVeinLoPassScale, StoneVeinHiPassOffset, StoneVeinLoPassOffset,
StoneVeinHiPassOutputScale, StoneVeinLoPassOutputScale, StoneVeinNoise, StoneVeinRampFactor);
@@ -156,10 +152,6 @@ namespace CaveGame::Core
if (stone_pass > 0.7f) { return TileID::STONE; }
if (stone_pass < -0.7f) { return TileID::STONE; }
//float dirt_pass_1 = perlin.Noise(wx / 30.f, wy / 30.f, 12.f) * 1.35f;
//float dirt_pass_2 = perlin.Noise(wx / 90.f, wy / 90.f, 0.5f) * 0.75f;
//float dirt_pass = dirt_pass_1 + dirt_pass_2;
// Chunks of dirt
float dirt_pass = ComputeOre(wx, wy, DirtVeinHiPassScale, DirtVeinLoPassScale, DirtVeinHiPassOffset, DirtVeinLoPassOffset,
DirtVeinHiPassOutputScale, DirtVeinLoPassOutputScale, DirtVeinNoise, DirtVeinRampFactor);
@@ -171,6 +163,7 @@ namespace CaveGame::Core
CoalVeinHiPassOutputScale, CoalVeinLoPassOutputScale, CoalVeinNoise, CoalVeinRampFactor);
if (coal_pass > 0.75f) { return TileID::COAL_ORE; }
if (coal_pass < -0.75f) { return TileID::COAL_ORE;}
// Copper ore veins
float copper_pass = ComputeOre(wx, wy, CopperVeinHiPassScale, CopperVeinLoPassScale, CopperVeinHiPassOffset, CopperVeinLoPassOffset,
@@ -182,12 +175,13 @@ namespace CaveGame::Core
float tin_pass = ComputeOre(wx, wy, TinVeinHiPassScale, TinVeinLoPassScale, TinVeinHiPassOffset, TinVeinLoPassOffset,
TinVeinHiPassOutputScale, TinVeinLoPassOutputScale, TinVeinNoise, TinVeinRampFactor);
if (tin_pass > 0.85) { return TileID::TIN_ORE; }
if (tin_pass > 0.85f) { return TileID::TIN_ORE; }
// Iron ore veins
float iron_pass = ComputeOre(wx, wy, IronVeinHiPassScale, IronVeinLoPassScale, IronVeinHiPassOffset, IronVeinLoPassOffset,
IronVeinHiPassOutputScale, IronVeinLoPassOutputScale, IronVeinNoise, IronVeinRampFactor);
if (iron_pass > 0.90f) { return TileID::IRON_ORE;}
if (depth > 1000) {
// Lead ore veins

View File

@@ -172,8 +172,6 @@ namespace CaveGame::Core
{
auto[val, errcode] = json::parse(read_text_file(metadata_path));
}
}
bool World::HasChunkOnFile(const Vector2 &cell) const {