diff --git a/assets/blender/Channels.blend b/assets/blender/Channels.blend index 11e8950..8d86450 100644 --- a/assets/blender/Channels.blend +++ b/assets/blender/Channels.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:242cf9d56730743a30f5b077a79d23a36a9c555ba2b1d28b3aee829fdd80e26c -size 1120493 +oid sha256:1f387b0703cd22b33277eb349315ff9de5e0012603e8ecabe9aa3e70e14a0d55 +size 1148073 diff --git a/assets/textures/w corner long.png b/assets/textures/w corner long.png index 5f83df6..797497d 100644 --- a/assets/textures/w corner long.png +++ b/assets/textures/w corner long.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:474f85a0a5491292c2ee8741d287b812bd7700456f6d6810ee768b79d19b94a4 -size 89801 +oid sha256:58365045b83d8d48938829bdc23f813553af8385336e2769e8d98824a09ee077 +size 89247 diff --git a/assets/textures/w straight.png b/assets/textures/w straight.png index db102cd..34ab171 100644 --- a/assets/textures/w straight.png +++ b/assets/textures/w straight.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f78f3dba154d5696a5c7a672fc5975164dca72078f2623b3c633a7fc66a6c475 +oid sha256:a71d5d51153e0703db7e2d5baf2caa0a905c5cb4b524472c47006bf330374340 size 77219 diff --git a/assets/textures/w! corner short.png b/assets/textures/w! corner short.png index 49c953f..a4cadf2 100644 --- a/assets/textures/w! corner short.png +++ b/assets/textures/w! corner short.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41394f4058ae86303a803e3ae2a45cdf3421824fdb0d69c47bc48178ae6dfe9e -size 154930 +oid sha256:39dc7b0f3eee0566def7a711c7d535d931996477b6051c6880252ef813dfa74d +size 66522 diff --git a/assets/textures/w+ corner short.png b/assets/textures/w+ corner short.png index 9a92c51..39b19ca 100644 --- a/assets/textures/w+ corner short.png +++ b/assets/textures/w+ corner short.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8db386761b3f4feb9dbd3449e98d67683d181b61d1327477c8253ef3a0aa988a -size 167054 +oid sha256:81d8fcc985aa5f3708c7b397e29a3bdb175795244e97bf1fc354fef04c44755e +size 74715 diff --git a/src/game/Level.cpp b/src/game/Level.cpp index 44d19e2..c33e22c 100644 --- a/src/game/Level.cpp +++ b/src/game/Level.cpp @@ -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,7 +274,7 @@ 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; @@ -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)) diff --git a/src/game/Puzzle.cpp b/src/game/Puzzle.cpp index 1567340..1a852b5 100644 --- a/src/game/Puzzle.cpp +++ b/src/game/Puzzle.cpp @@ -1,7 +1,6 @@ #include "../gen/Def.h" #include "Gen.h" #include "Global.h" -#include "Instance.h" #include "Log.h" #include "Puzzle.h" diff --git a/src/game/Tools.cpp b/src/game/Tools.cpp index 39c13f2..3f6a4d5 100644 --- a/src/game/Tools.cpp +++ b/src/game/Tools.cpp @@ -678,16 +678,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]; diff --git a/src/game/UI.cpp b/src/game/UI.cpp index 7c0614a..f617b6c 100644 --- a/src/game/UI.cpp +++ b/src/game/UI.cpp @@ -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]; diff --git a/src/game/data/puzzles/0.pzl b/src/game/data/puzzles/0.pzl index 751f4f6..9470da3 100644 --- a/src/game/data/puzzles/0.pzl +++ b/src/game/data/puzzles/0.pzl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad3645b16777bfd1525939d50bb8a757670e90cdce39cfb0a84b9bf85db04dc3 +oid sha256:37da901274b47bf03ecdca43c8316de26eeb6834fabb4e74d1d4b439819de966 size 11441 diff --git a/src/game/data/puzzles/1.pzl b/src/game/data/puzzles/1.pzl index d90ee14..571f591 100644 --- a/src/game/data/puzzles/1.pzl +++ b/src/game/data/puzzles/1.pzl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ddec9e68881de0db1d50d5df52bc7353bb4e20ad07cd985e670ef3fc7d03a781 +oid sha256:ff1c4ccf050750f3fb7cc1c2a9cbaebd330d77a78d6c75de78e56060ca327f98 size 11441 diff --git a/src/game/data/puzzles/2.pzl b/src/game/data/puzzles/2.pzl index 5edae97..09329ff 100644 --- a/src/game/data/puzzles/2.pzl +++ b/src/game/data/puzzles/2.pzl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:efee4ec5ef0206326b505b472deb97c4603c80bd988e8040cc44cacfe4826dc1 +oid sha256:0cb52f7ba146dafbeb2728340aeabcd855e7c4e8c7ab8c585533cb095748b67b size 11441 diff --git a/src/game/data/static/puzzle.dat b/src/game/data/static/puzzle.dat index 41dc9e9..4ab6066 100644 Binary files a/src/game/data/static/puzzle.dat and b/src/game/data/static/puzzle.dat differ diff --git a/src/game/data/static/uiconfig.dat b/src/game/data/static/uiconfig.dat index f4bdd43..0d2f4c9 100644 Binary files a/src/game/data/static/uiconfig.dat and b/src/game/data/static/uiconfig.dat differ diff --git a/src/textures/w corner long.ktx b/src/textures/w corner long.ktx index a6a73a3..0c11762 100644 --- a/src/textures/w corner long.ktx +++ b/src/textures/w corner long.ktx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2d9cefdf5f6cbddf46b6a670c08e7a6f779a046f36f3fbdf67c19b9509a9cb4e +oid sha256:ce902c7cc4e3225bf78cc5f1149751c36b7555a05a248eb793ed9c94a8e9299f size 1048644 diff --git a/src/textures/w! corner short.ktx b/src/textures/w! corner short.ktx index 0fc4136..f52ee67 100644 --- a/src/textures/w! corner short.ktx +++ b/src/textures/w! corner short.ktx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ffc10f1db985fb69825bc27c39573a33b79647aa29459aa04adb8858c3b56a6 +oid sha256:a81f64b86c80c49ff772b81c79cd333b4e744a7bd3d868f8a52e1d76606062d6 size 1048644 diff --git a/src/textures/w+ corner short.ktx b/src/textures/w+ corner short.ktx index 578d5d0..8c56bee 100644 --- a/src/textures/w+ corner short.ktx +++ b/src/textures/w+ corner short.ktx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d774e48308b04cff8e5174ea7a84fb73f246f735572e7d2bb0ba68da3a27fa9 +oid sha256:048a7b8d6e7759bdae2c695031c78235bffeffb8efa378c6792e2e83a70bbf14 size 1048644 diff --git a/tools/radsession.rad b/tools/radsession.rad index 5575b36..2d7b990 100644 --- a/tools/radsession.rad +++ b/tools/radsession.rad @@ -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: