From 7b9172c27b15aad40b88da8aa0936edcf65c9d5c Mon Sep 17 00:00:00 2001 From: genxium Date: Wed, 16 Nov 2022 21:32:25 +0800 Subject: [PATCH] Fixed backend tmx parsing for ortho map. --- collider_visualizer/worldColliderDisplay.go | 4 ++-- dnmshared/tmx_parser.go | 17 +++++++++++++++++ frontend/assets/resources/map/dungeon/map.tmx | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/collider_visualizer/worldColliderDisplay.go b/collider_visualizer/worldColliderDisplay.go index 1d7a2db..0c2b0ed 100644 --- a/collider_visualizer/worldColliderDisplay.go +++ b/collider_visualizer/worldColliderDisplay.go @@ -36,7 +36,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi virtualGridToWorldRatio := 0.1 playerDefaultSpeed := 20 minStep := (int(float64(playerDefaultSpeed)*virtualGridToWorldRatio) << 2) - playerColliderRadius := float64(24) + playerColliderRadius := float64(16) playerColliders := make([]*resolv.Object, len(playerPosList.Eles)) space := resolv.NewSpace(int(spaceW), int(spaceH), minStep, minStep) for i, playerPos := range playerPosList.Eles { @@ -56,7 +56,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi world.Space = space - moveToCollide := true + moveToCollide := false if moveToCollide { newVx, newVy := int32(-2959), int32(-2261) effPushback := Vec2D{X: float64(0), Y: float64(0)} diff --git a/dnmshared/tmx_parser.go b/dnmshared/tmx_parser.go index 0477567..99d8344 100644 --- a/dnmshared/tmx_parser.go +++ b/dnmshared/tmx_parser.go @@ -406,6 +406,12 @@ type TileRectilinearSize struct { } func (pTmxMapIns *TmxMap) continuousObjLayerVecToContinuousMapNodeVec(continuousObjLayerVec *Vec2D) Vec2D { + if "orthogonal" == pTmxMapIns.Orientation { + return Vec2D{ + X: continuousObjLayerVec.X, + Y: continuousObjLayerVec.Y, + } + } var tileRectilinearSize TileRectilinearSize tileRectilinearSize.Width = float64(pTmxMapIns.TileWidth) tileRectilinearSize.Height = float64(pTmxMapIns.TileHeight) @@ -428,6 +434,17 @@ func (pTmxMapIns *TmxMap) continuousObjLayerVecToContinuousMapNodeVec(continuous } func (pTmxMapIns *TmxMap) continuousObjLayerOffsetToContinuousMapNodePos(continuousObjLayerOffset *Vec2D) Vec2D { + if "orthogonal" == pTmxMapIns.Orientation { + layerOffset := Vec2D{ + X: float64(pTmxMapIns.Width*pTmxMapIns.TileWidth) * 0.5, + Y: float64(pTmxMapIns.Height*pTmxMapIns.TileHeight) * 0.5, + } + return Vec2D{ + X: continuousObjLayerOffset.X - layerOffset.X, + Y: continuousObjLayerOffset.Y - layerOffset.Y, + } + } + // "isometric" == pTmxMapIns.Orientation layerOffset := Vec2D{ X: 0, Y: float64(pTmxMapIns.Height*pTmxMapIns.TileHeight) * 0.5, diff --git a/frontend/assets/resources/map/dungeon/map.tmx b/frontend/assets/resources/map/dungeon/map.tmx index 3129bcb..a2856de 100644 --- a/frontend/assets/resources/map/dungeon/map.tmx +++ b/frontend/assets/resources/map/dungeon/map.tmx @@ -8,10 +8,10 @@ - + - +