Remote Edits
This commit is contained in:
@@ -9,6 +9,8 @@ void CaveGame::Core::Player::Draw() {
|
||||
auto myAsset = Client::AssetService::Get()->player_sprite;
|
||||
JGL::J2D::DrawPartialSprite(myAsset, position, {0,0}, {16, 24});
|
||||
JGL::J2D::OutlineRect(Colors::Red, position, bounding_box);
|
||||
J2D::DrawString(Colors::White, std::format("vel: {},{}", Math::Round(velocity.x, 2), Math::Round(velocity.y, 2)), position.x, position.y-8, 0.5f, 8);
|
||||
J2D::DrawString(Colors::White, std::format("ct: {} cd: {}", coll_tests, coll_hits), position.x, position.y-16, 0.5f, 8);
|
||||
}
|
||||
|
||||
void CaveGame::Core::Player::Update(float elapsed) {
|
||||
|
@@ -84,6 +84,7 @@ void CaveGame::Client::MainMenu::BuildWidgets() {
|
||||
//title->Center();
|
||||
title->BGColor({0,0,0,0});
|
||||
title->SetBorderStyling(Colors::Cyans::Cyan, 1);
|
||||
title->BorderWidth(0);
|
||||
|
||||
auto* content = new JUI::Image(title);
|
||||
content->Content(Client::AssetService::Get()->title_img);
|
||||
@@ -95,6 +96,7 @@ void CaveGame::Client::MainMenu::BuildWidgets() {
|
||||
button_group->AnchorPoint({0.5f, 0.f});
|
||||
button_group->BGColor({0,0,0,0});
|
||||
button_group->SetBorderStyling(Colors::Cyans::Cyan, 1);
|
||||
button_group->BorderWidth(0);
|
||||
|
||||
auto *button_list = new JUI::VerticalListLayout(button_group);
|
||||
button_list->PaddingBottom(5_px);
|
||||
|
@@ -1,5 +1,18 @@
|
||||
/// CaveGame - A procedural 2D platformer sandbox.
|
||||
/// Created by Josh O'Leary @ Redacted Software, 2020-2025
|
||||
/// Contact: josh@redacted.cc
|
||||
/// Contributors: william@redacted.cc maxi@redacted.cc
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file PhysicsEntity.hpp
|
||||
/// @desc Abstract class of a physically-simulated game object.
|
||||
/// @edit 1/28/2025
|
||||
/// @auth Josh O'Leary
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "Entity.hpp"
|
||||
|
||||
#include <Core/Entity.hpp>
|
||||
|
||||
|
||||
namespace CaveGame::Core
|
||||
@@ -16,8 +29,16 @@ namespace CaveGame::Core
|
||||
|
||||
virtual void PhysicsUpdate(float elapsed);
|
||||
|
||||
void CollisionTest(ITileMap* map, float elapsed) override
|
||||
{
|
||||
void CollisionTest(ITileMap* map, float elapsed) override {
|
||||
|
||||
// The current "collision system" is unstable,
|
||||
|
||||
// One problem in particular is sometimes the entity gets teleported too far out, in a nonsensical way.
|
||||
|
||||
// The AABB separation may not be ideal, given how small the tile colliders are.
|
||||
|
||||
coll_tests = 0;
|
||||
coll_hits = 0;
|
||||
|
||||
for (int x = -1; x <= bounding_box.x; x++) {
|
||||
for (int y = -1; y <= bounding_box.y; y++) {
|
||||
@@ -28,6 +49,8 @@ namespace CaveGame::Core
|
||||
if (id == TileID::VOID || id == TileID::AIR)
|
||||
continue;
|
||||
|
||||
coll_tests++;
|
||||
|
||||
Vector2 entity_centroid = position + (bounding_box / 2.f);
|
||||
Vector2 entity_halfbox = bounding_box / 2.f;
|
||||
|
||||
@@ -36,6 +59,7 @@ namespace CaveGame::Core
|
||||
|
||||
|
||||
if (Solver::AABB2Dvs(entity_centroid, entity_halfbox, tile_centroid, tile_halfbox)) {
|
||||
coll_hits++;
|
||||
Vector2 separation = Solver::SolveAABB(entity_centroid, entity_halfbox, tile_centroid, tile_halfbox);
|
||||
|
||||
Vector2 normal = Solver::GetNormalForAABB(separation, velocity);
|
||||
@@ -49,8 +73,6 @@ namespace CaveGame::Core
|
||||
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)
|
||||
@@ -74,6 +96,8 @@ namespace CaveGame::Core
|
||||
Vector2 velocity;
|
||||
Vector2 next_position;
|
||||
float mass;
|
||||
int coll_tests;
|
||||
int coll_hits;
|
||||
private:
|
||||
};
|
||||
|
||||
|
@@ -14,7 +14,7 @@ namespace CaveGame::Core
|
||||
void Update(float elapsed) override;
|
||||
void PhysicsUpdate(float elapsed) override;
|
||||
void Jump() {
|
||||
Accelerate({0, 1});
|
||||
Accelerate({0, -2});
|
||||
}
|
||||
void Climb();
|
||||
void Descend();
|
||||
|
6
Server/include/Server/ServerGameWorld.hpp
Normal file
6
Server/include/Server/ServerGameWorld.hpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace CaveGame::Server {
|
||||
|
||||
};
|
Reference in New Issue
Block a user