Temporary default hotbar!!

This commit is contained in:
2024-12-27 15:26:53 -05:00
parent 3fb2db4fd4
commit 929231f0ff
6 changed files with 51 additions and 7 deletions

View File

@@ -60,6 +60,15 @@ namespace CaveGame::Client {
using CaveGame::Core::Entity;
class GameSession : public Scene {
public:
Core::TileID GetHotbarTile() const {
return HotbarItems[active_hotbar_slot];
}
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::ASH, Core::TileID::ICE
};
GameSession() = default;
GameSession(bool createNewWorld);
@@ -95,6 +104,12 @@ namespace CaveGame::Client {
hotbar_elements[i]->AnchorPoint({0.f, 0.8f});
}
Core::TileID active_item = HotbarItems[active_hotbar_slot];
auto* data = GetByNumeric(active_item);
item_label->SetContent(data->Name());
hotbar_elements[active_hotbar_slot]->CornerRounding(8);
hotbar_elements[active_hotbar_slot]->SetBorderWidth(1.5f);
hotbar_elements[active_hotbar_slot]->Size({58_px, 56_px});

View File

@@ -209,7 +209,8 @@ namespace CaveGame::ClientApp
Vector2 transformed = game_ctx->world->camera.ScreenToWorld(GetMouseCoordinates());
tile_draw(transformed.x, transformed.y, 2, Core::TileID::GRASS);
tile_draw(transformed.x, transformed.y, 2, game_ctx->GetHotbarTile());
/*game_ctx->world->SetTile(transformed.x, transformed.y, Core::TileID::GRASS);
game_ctx->world->SetTile(transformed.x+1, transformed.y, Core::TileID::GRASS);

View File

@@ -58,10 +58,14 @@ namespace CaveGame::Core {
virtual void PhysicsUpdate(float elapsed) {
next_position += velocity * elapsed;
float friction = 2.45f;
float friction = 3.45f;
float gravity = 9.81f;
float mass = 32.f;
velocity *= (1 - (elapsed*friction));
velocity.y += (elapsed*gravity*mass);
position = next_position;
}
@@ -91,11 +95,22 @@ namespace CaveGame::Core {
next_position += separation;
//if (normal.y != 0)
// velocity = {velocity.x, -velocity.y};
// Touched top.
if (normal.y == -1)
velocity.y = 0;
if (normal.y == 1)
velocity.y = -velocity.y;
//if (normal.x != 0)
// velocity = {-velocity.x, velocity.y};
// TODO: Refine condition for "step-up"s
if (normal.x != 0 && velocity.y == 0)
next_position.y -= 1;
next_position += separation;
return;
}
}
}

View File

@@ -133,6 +133,7 @@ namespace CaveGame::Core
Tile(TileID id, const std::string& name, const Color4& color, const std::vector<Color4>& pallet);
[[nodiscard]] TileID NumericID() const;
[[nodiscard]] std::string MnemonicID() const;
std::string Name() const { return mnemonic_id; }
virtual bool DoesRandomTicc() const { return false; }
virtual bool Solid() const { return false;}
virtual void ForcedTicc(ITileMap* world, TileState state, int x, int y) {}
@@ -147,6 +148,9 @@ namespace CaveGame::Core
class LiquidTile : public Tile
{
public:
LiquidTile();
LiquidTile(TileID id, const std::string& name, const Color4& color, const std::vector<Color4>& pallet);
LiquidTile(TileID numeric, const std::string& name, Color4 color);
bool Solid() const override { return true;}
};
@@ -352,10 +356,10 @@ namespace CaveGame::Core
static const Tile BirchPlank;
static const LiquidTile Water;
static const LiquidTile Water {ID::WATER, "Water", Colors::Blues::DodgerBlue};
static const LiquidTile Blood;
static const LiquidTile Sludge;
static const LiquidTile Lava;
static const LiquidTile Lava {ID::LAVA, "Lava", Colors::Red};
static const LiquidTile MuddyWater;
static const LiquidTile Ectoplasm;
static const LiquidTile Oil;

View File

@@ -4,7 +4,6 @@ CaveGame::Core::Entity::Entity(const Vector2 &spawnPoint) {
position = spawnPoint;
}
CaveGame::Core::Player::Player(const Vector2 &spawnPoint): Humanoid(spawnPoint) {
bounding_box = {16, 24};
}

View File

@@ -19,6 +19,16 @@ namespace CaveGame::Core
return false;
}
LiquidTile::LiquidTile(): Tile() {}
LiquidTile::LiquidTile(TileID id, const std::string &name, const Color4 &color, const std::vector<Color4> &pallet): Tile(id,name, color,pallet) {
does_random_ticc = true;
}
LiquidTile::LiquidTile(TileID numeric, const std::string &name, Color4 color): Tile(numeric, name, color) {
does_random_ticc = true;
}
SoilTile::SoilTile(): Tile() {}
SoilTile::SoilTile(TileID id, const std::string &name, const Color4 &color, const std::vector<Color4> &pallet,