Compare commits
2 Commits
3ccbbf493f
...
05cf88d986
| Author | SHA1 | Date | |
|---|---|---|---|
| 05cf88d986 | |||
| d6bec9e870 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+38
-16
@@ -218,6 +218,16 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
bool IsInPuzzle(WorldPuzzle& puz, Vec3 worldPos)
|
||||
{
|
||||
Vec3 offsetToPuzzle = worldPos - puz.WorldPosition + (Vec3{0.5f, 0.0f, 0.5f} * Puzzle::Config::CardScaleWorld);
|
||||
Vec3 scaledOffset = offsetToPuzzle / Puzzle::Config::CardScaleWorld;
|
||||
int32_t offsetX = (int32_t)bx::floor(scaledOffset.x);
|
||||
int32_t offsetY = (int32_t)bx::floor(scaledOffset.z);
|
||||
return (offsetX >= 0 && offsetX < puz.Data.WidthTiles / 2 && offsetY >= -1 &&
|
||||
offsetY < puz.Data.HeightTiles / 2);
|
||||
}
|
||||
|
||||
bool IsOnGround(Level& level, Vec3 worldPos)
|
||||
{
|
||||
for (auto& puz : level.Puzzles)
|
||||
@@ -226,7 +236,10 @@ namespace Game
|
||||
worldPos - puz.WorldPosition + (Vec3{0.5f, 0.0f, 0.5f} * Puzzle::Config::CardScaleWorld);
|
||||
Vec3 scaledOffset = offsetToPuzzle / Puzzle::Config::CardScaleWorld;
|
||||
int32_t offsetX = (int32_t)bx::floor(scaledOffset.x);
|
||||
int32_t offsetY = (int32_t)bx::floor(scaledOffset.z);
|
||||
int32_t offsetY = puz.Data.HeightTiles / 2 - (int32_t)bx::floor(scaledOffset.z) - 1;
|
||||
float fracOffsetX = scaledOffset.x - offsetX;
|
||||
float fracOffsetY = scaledOffset.z - bx::floor(scaledOffset.z);
|
||||
|
||||
if (offsetX >= 0 && offsetX < puz.Data.WidthTiles / 2 && offsetY >= 0 && offsetY < puz.Data.HeightTiles / 2)
|
||||
{
|
||||
auto& card = puz.Data.PlacedCards[offsetY * Puzzle::Config::MaxPuzzleSizeCards + offsetX];
|
||||
@@ -243,8 +256,6 @@ namespace Game
|
||||
}
|
||||
|
||||
auto& heightmap = GameRendering::Get().Models[refCard.BaseModelHandle.ModelIdx].Height;
|
||||
float fracOffsetX = scaledOffset.x - offsetX;
|
||||
float fracOffsetY = scaledOffset.z - offsetY;
|
||||
int32_t xPos = (int32_t)(fracOffsetX * heightmap.Width);
|
||||
int32_t yPos = (int32_t)(fracOffsetY * heightmap.Height);
|
||||
|
||||
@@ -255,7 +266,7 @@ namespace Game
|
||||
height = heightmap.Values[yPos * heightmap.Width + xPos];
|
||||
break;
|
||||
case 1:
|
||||
height = heightmap.Values[(heightmap.Height - xPos - 1) * heightmap.Width + yPos];
|
||||
height = heightmap.Values[xPos * heightmap.Width + (heightmap.Height - yPos - 1)];
|
||||
break;
|
||||
case 2:
|
||||
height =
|
||||
@@ -263,18 +274,18 @@ namespace Game
|
||||
.Values[(heightmap.Height - yPos - 1) * heightmap.Width + (heightmap.Width - xPos - 1)];
|
||||
break;
|
||||
default:
|
||||
height = heightmap.Values[xPos * heightmap.Width + (heightmap.Height - yPos - 1)];
|
||||
height = heightmap.Values[(heightmap.Height - xPos - 1) * heightmap.Width + yPos];
|
||||
break;
|
||||
}
|
||||
return height >= 110 && height <= 125;
|
||||
}
|
||||
if (offsetX >= 0 && offsetX < puz.Data.WidthTiles / Puzzle::Config::CardSize &&
|
||||
offsetY == puz.Data.HeightTiles / Puzzle::Config::CardSize)
|
||||
if (offsetX == 1 && offsetY == puz.Data.HeightTiles / Puzzle::Config::CardSize)
|
||||
{
|
||||
if (puz.IsSolved)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true; // TODO!
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -387,6 +398,10 @@ namespace Game
|
||||
uint16_t activeIdx = GetInstance().DebugData.SelectedDebugLevel;
|
||||
for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i)
|
||||
{
|
||||
if (IsInPuzzle(Puzzles[i], player.PlayerCamTransform.Position))
|
||||
{
|
||||
activeIdx = i;
|
||||
}
|
||||
Puzzles[i].IsActive = activeIdx == i;
|
||||
Puzzles[i].Update();
|
||||
Puzzles[i].IsSolved = solver.IsPuzzleSolved(Puzzles[i].Data);
|
||||
@@ -495,6 +510,15 @@ namespace Game
|
||||
LOG("finished setup!");
|
||||
}
|
||||
|
||||
Vec3 PuzPosToWorldPos(const PuzzleData& data, int32_t x, int32_t y)
|
||||
{
|
||||
return {
|
||||
(float)x * Puzzle::Config::CardScaleWorld,
|
||||
-5.0f,
|
||||
(float)(data.HeightTiles / 2 - y - 1) * Puzzle::Config::CardScaleWorld,
|
||||
};
|
||||
}
|
||||
|
||||
void WorldPuzzle::Update()
|
||||
{
|
||||
Level& level = GetInstance().GameLevel;
|
||||
@@ -521,17 +545,13 @@ namespace Game
|
||||
tile.EData.DotColor = visuals.TileDotColor;
|
||||
tile.EData.BaseColor = visuals.TileBaseColor;
|
||||
|
||||
Vec3 cardPos = {
|
||||
(float)card.Position.X * Puzzle::Config::CardScaleWorld,
|
||||
-5.0f,
|
||||
(float)card.Position.Y * Puzzle::Config::CardScaleWorld,
|
||||
};
|
||||
Vec3 cardPos = PuzPosToWorldPos(Data, card.Position.X, card.Position.Y);
|
||||
if (!isValid)
|
||||
{
|
||||
cardPos = {x * Puzzle::Config::CardScaleWorld, -5.0f, y * Puzzle::Config::CardScaleWorld};
|
||||
cardPos = PuzPosToWorldPos(Data, x, y);
|
||||
}
|
||||
tile.EData.Transform.Position = cardPos + WorldPosition;
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * -0.5f);
|
||||
|
||||
// Covers
|
||||
if (IsValid(staticCard.BaseModelHandle))
|
||||
@@ -576,11 +596,13 @@ namespace Game
|
||||
}
|
||||
auto& wall = level.PuzzleTiles.Get(WallHandle);
|
||||
wall.EData.Visible = true;
|
||||
wall.EData.Transform.Position = WorldPosition + Vec3{30.0f, -5.0f, 40.2f};
|
||||
wall.EData.Transform.Position =
|
||||
WorldPosition + Vec3{0.0f, 0.0f, Data.HeightTiles * 5.0f} + Vec3{30.0f, -5.0f, 0.2f};
|
||||
|
||||
auto& door = level.PuzzleTiles.Get(DoorHandle);
|
||||
door.EData.Visible = !IsSolved;
|
||||
door.EData.Transform.Position = WorldPosition + Vec3{30.0f, -5.0f, 40.2f};
|
||||
door.EData.Transform.Position =
|
||||
WorldPosition + Vec3{0.0f, 0.0f, Data.HeightTiles * 5.0f} + Vec3{30.0f, -5.0f, 0.2f};
|
||||
}
|
||||
|
||||
void Level::ReloadLevelEntities()
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Game
|
||||
|
||||
void Setup();
|
||||
void Update();
|
||||
void Reset(); // TODO!
|
||||
};
|
||||
|
||||
class Level
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "../gen/Def.h"
|
||||
#include "Gen.h"
|
||||
#include "Global.h"
|
||||
#include "Instance.h"
|
||||
#include "Log.h"
|
||||
#include "Puzzle.h"
|
||||
|
||||
|
||||
+14
-3
@@ -668,6 +668,11 @@ namespace Tools
|
||||
{
|
||||
if (ImGui::Button("Spiel Neustarten"))
|
||||
{
|
||||
player.PlayerCamTransform.Position = {0.0f, 3.0f, 0.0f};
|
||||
for (int32_t i = 0; i < BX_COUNTOF(level.Puzzles); ++i)
|
||||
{
|
||||
Puzzle::ResetPuzzle(level.Puzzles[i].Data);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Zurück zum Anfang"))
|
||||
@@ -678,16 +683,22 @@ namespace Tools
|
||||
ImGui::Text("Anleitung:");
|
||||
ImGui::Text("Bewege dich mit");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored({1.0f, 0.8f, 0.8f, 1.0f}, "W, A, S, D");
|
||||
ImGui::TextColored({1.0f, 0.6f, 0.6f, 1.0f}, "W, A, S, D");
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("und schau dich um mit der");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored({1.0f, 0.8f, 0.8f, 1.0f}, "Maus.");
|
||||
ImGui::TextColored({1.0f, 0.6f, 0.6f, 1.0f}, "Maus.");
|
||||
ImGui::Text("Drücke");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored({1.0f, 0.8f, 0.8f, 1.0f}, "Leertaste");
|
||||
ImGui::TextColored({1.0f, 0.6f, 0.6f, 1.0f}, "Leertaste");
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("um den Spielplan zu öffnen.");
|
||||
ImGui::Text("Auf dem Spielplan kannst du Karten verschieben.");
|
||||
ImGui::Text("Mit");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored({1.0f, 0.6f, 0.6f, 1.0f}, "Rechter Maustaste");
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("kannst du Karten drehen.");
|
||||
ImGui::Text("");
|
||||
auto& inflowTexture = rendering.Textures[10];
|
||||
auto& outflowTexture = rendering.Textures[9];
|
||||
|
||||
+24
-12
@@ -124,6 +124,22 @@ namespace Game
|
||||
WorldPuzzleUI::UICardScale * WorldPuzzleUI::UICardScale;
|
||||
}
|
||||
|
||||
Vec3 CardPosToUIPos(const Gen::PuzzleData& data, int32_t cardX, int32_t cardY)
|
||||
{
|
||||
return Vec3{(float)cardX, (float)(data.HeightTiles / 2 - cardY - 1), -0.3f} * WorldPuzzleUI::UICardOffset *
|
||||
WorldPuzzleUI::UICardScale -
|
||||
CalcBoardOffset(data);
|
||||
}
|
||||
|
||||
void UIPosToCardPos(const Gen::PuzzleData& data, Vec3 uiPos, int32_t& cardXOut, int32_t& cardYOut)
|
||||
{
|
||||
Vec3 boardOffset = CalcBoardOffset(data) / WorldPuzzleUI::UICardScale;
|
||||
Vec3 boardPos = GlobalToLocalPoint(StaticData.UITransform, uiPos);
|
||||
Vec3 boardTilePos = (boardPos + boardOffset) / WorldPuzzleUI::UICardOffset;
|
||||
cardXOut = (int32_t)bx::round(boardTilePos.x);
|
||||
cardYOut = data.HeightTiles / 2 - (int32_t)bx::round(boardTilePos.y) - 1;
|
||||
}
|
||||
|
||||
void WorldPuzzleUI::UpdateAvailableCards(Gen::PuzzleData& Data)
|
||||
{
|
||||
auto& level = GetInstance().GameLevel;
|
||||
@@ -169,11 +185,9 @@ namespace Game
|
||||
dragPos += StaticData.ZAxis * -0.01f;
|
||||
quad.EData.Transform.Position = dragPos;
|
||||
|
||||
Vec3 boardOffset = CalcBoardOffset(Data) / WorldPuzzleUI::UICardScale;
|
||||
Vec3 boardPos = GlobalToLocalPoint(StaticData.UITransform, quadPlaneIntersectPos);
|
||||
Vec3 boardTilePos = (boardPos + boardOffset) / UICardOffset;
|
||||
int32_t xPos = (int32_t)bx::round(boardTilePos.x);
|
||||
int32_t yPos = (int32_t)bx::round(boardTilePos.y);
|
||||
int32_t xPos;
|
||||
int32_t yPos;
|
||||
UIPosToCardPos(Data, quadPlaneIntersectPos, xPos, yPos);
|
||||
|
||||
if (!GetMouseButton(MouseButton::Left))
|
||||
{
|
||||
@@ -219,9 +233,8 @@ namespace Game
|
||||
bool isLocked = GetFlag(card.Flags, PlacedPuzzleCardFlags::Locked);
|
||||
|
||||
auto& quad = level.UIQuads.Get(UIPlacedCards[cardIdx]);
|
||||
quad.UIPos = Vec3{(float)card.Position.X, (float)card.Position.Y, -0.3f} * UICardOffset * UICardScale;
|
||||
quad.UIPos -= boardOffset;
|
||||
quad.UIRot = card.Rotation * bx::kPi * 0.5f;
|
||||
quad.UIPos = CardPosToUIPos(Data, card.Position.X, card.Position.Y);
|
||||
quad.UIRot = card.Rotation * bx::kPi * -0.5f;
|
||||
UpdateQuad(level.UIQuads, UIPlacedCards[cardIdx]);
|
||||
|
||||
quad.EData.Visible = isValid;
|
||||
@@ -253,10 +266,9 @@ namespace Game
|
||||
dragPos += StaticData.ZAxis * -0.01f;
|
||||
quad.EData.Transform.Position = dragPos;
|
||||
|
||||
Vec3 boardPos = GlobalToLocalPoint(StaticData.UITransform, quadPlaneIntersectPos);
|
||||
Vec3 boardTilePos = boardPos / UICardOffset;
|
||||
int32_t xPos = (int32_t)bx::round(boardTilePos.x);
|
||||
int32_t yPos = (int32_t)bx::round(boardTilePos.y);
|
||||
int32_t xPos;
|
||||
int32_t yPos;
|
||||
UIPosToCardPos(Data, quadPlaneIntersectPos, xPos, yPos);
|
||||
Gen::PuzPos srcCardPos = {(int8_t)DraggedCard.X, (int8_t)DraggedCard.Y};
|
||||
Gen::PlacedPuzzleCard& srcCard =
|
||||
Data.PlacedCards[srcCardPos.Y * Puzzle::Config::MaxPuzzleSizeCards + srcCardPos.X];
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,17 +1,18 @@
|
||||
// raddbg 0.9.19 project file
|
||||
|
||||
recent_file: path: "../src/game/level.cpp"
|
||||
recent_file: path: "../src/game/puzzle.cpp"
|
||||
recent_file: path: "../src/dependency/bgfx.cmake/bx/src/debug.cpp"
|
||||
recent_file: path: "../src/game/entity.h"
|
||||
recent_file: path: "../src/game/ui.cpp"
|
||||
recent_file: path: "../src/game/Log.cpp"
|
||||
recent_file: path: "../src/game/rendering/dither.cpp"
|
||||
recent_file: path: "../src/game/rendering/rendering.cpp"
|
||||
recent_file: path: "../src/game/entity.h"
|
||||
recent_file: path: "../src/game/ui.cpp"
|
||||
recent_file: path: "../src/gen/generated.cpp"
|
||||
recent_file: path: "../src/engine/main.cpp"
|
||||
recent_file: path: "../src/game/setup.cpp"
|
||||
recent_file: path: "../src/dependency/imgui/imgui_widgets.cpp"
|
||||
recent_file: path: "../src/game/tools.cpp"
|
||||
recent_file: path: "../src/dependency/bgfx.cmake/bx/src/debug.cpp"
|
||||
recent_file: path: "../src/gen/def.h"
|
||||
recent_file: path: "../src/game/global.cpp"
|
||||
target:
|
||||
|
||||
Reference in New Issue
Block a user