mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 03:39:00 +00:00
Updated CLI unit tests again.
This commit is contained in:
parent
41967b11f7
commit
a4ebde3e07
@ -53,24 +53,24 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi
|
|||||||
|
|
||||||
world.Space = space
|
world.Space = space
|
||||||
|
|
||||||
moveToCollide := false
|
moveToCollide := true
|
||||||
if moveToCollide {
|
if moveToCollide {
|
||||||
effPushback := Vec2D{X: float64(0), Y: float64(0)}
|
effPushback := Vec2D{X: float64(0), Y: float64(0)}
|
||||||
toTestPlayerCollider := playerColliders[0]
|
toTestPlayerCollider := playerColliders[0]
|
||||||
toTestPlayerCollider.X += -2.98
|
toTestPlayerCollider.X += -50.0
|
||||||
toTestPlayerCollider.Y += -50.0
|
toTestPlayerCollider.Y += -60.0
|
||||||
toTestPlayerCollider.Update()
|
toTestPlayerCollider.Update()
|
||||||
oldDx, oldDy := float64(0), float64(0)
|
oldDx, oldDy := float64(0), float64(0)
|
||||||
if collision := toTestPlayerCollider.Check(oldDx, oldDy); collision != nil {
|
if collision := toTestPlayerCollider.Check(oldDx, oldDy); collision != nil {
|
||||||
playerShape := toTestPlayerCollider.Shape.(*resolv.ConvexPolygon)
|
playerShape := toTestPlayerCollider.Shape.(*resolv.ConvexPolygon)
|
||||||
for _, obj := range collision.Objects {
|
for _, obj := range collision.Objects {
|
||||||
barrierShape := obj.Shape.(*resolv.ConvexPolygon)
|
barrierShape := obj.Shape.(*resolv.ConvexPolygon)
|
||||||
if overlapped, pushbackX, pushbackY := CalcPushbacks(oldDx, oldDy, playerShape, barrierShape); overlapped {
|
if overlapped, pushbackX, pushbackY, overlapResult := CalcPushbacks(oldDx, oldDy, playerShape, barrierShape); overlapped {
|
||||||
Logger.Info(fmt.Sprintf("Overlapped: a=%v, b=%v, pushbackX=%v, pushbackY=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape), pushbackX, pushbackY))
|
Logger.Info(fmt.Sprintf("Overlapped: a=%v, b=%v, pushbackX=%v, pushbackY=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape), pushbackX, pushbackY))
|
||||||
effPushback.X += pushbackX
|
effPushback.X += pushbackX
|
||||||
effPushback.Y += pushbackY
|
effPushback.Y += pushbackY
|
||||||
} else {
|
} else {
|
||||||
Logger.Info(fmt.Sprintf("Collider BUT not overlapped: a=%v, b=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape)))
|
Logger.Info(fmt.Sprintf("Collided BUT not overlapped: a=%v, b=%v, overlapResult=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape), overlapResult))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toTestPlayerCollider.X -= effPushback.X
|
toTestPlayerCollider.X -= effPushback.X
|
||||||
|
@ -55,7 +55,7 @@ func GenerateConvexPolygonCollider(unalignedSrc *Polygon2D, spaceOffsetX, spaceO
|
|||||||
return collider
|
return collider
|
||||||
}
|
}
|
||||||
|
|
||||||
func CalcPushbacks(oldDx, oldDy float64, playerShape, barrierShape *resolv.ConvexPolygon) (bool, float64, float64) {
|
func CalcPushbacks(oldDx, oldDy float64, playerShape, barrierShape *resolv.ConvexPolygon) (bool, float64, float64, *SatResult) {
|
||||||
origX, origY := playerShape.Position()
|
origX, origY := playerShape.Position()
|
||||||
defer func() {
|
defer func() {
|
||||||
playerShape.SetPosition(origX, origY)
|
playerShape.SetPosition(origX, origY)
|
||||||
@ -71,9 +71,9 @@ func CalcPushbacks(oldDx, oldDy float64, playerShape, barrierShape *resolv.Conve
|
|||||||
}
|
}
|
||||||
if overlapped := IsPolygonPairOverlapped(playerShape, barrierShape, overlapResult); overlapped {
|
if overlapped := IsPolygonPairOverlapped(playerShape, barrierShape, overlapResult); overlapped {
|
||||||
pushbackX, pushbackY := overlapResult.Overlap*overlapResult.OverlapX, overlapResult.Overlap*overlapResult.OverlapY
|
pushbackX, pushbackY := overlapResult.Overlap*overlapResult.OverlapX, overlapResult.Overlap*overlapResult.OverlapY
|
||||||
return true, pushbackX, pushbackY
|
return true, pushbackX, pushbackY, overlapResult
|
||||||
} else {
|
} else {
|
||||||
return false, 0, 0
|
return false, 0, 0, overlapResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup id="2" name="PlayerStartingPos">
|
<objectgroup id="2" name="PlayerStartingPos">
|
||||||
<object id="135" x="1516.33" y="2113">
|
<object id="135" x="1513.33" y="1996">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
<object id="137" x="2270" y="1640">
|
<object id="137" x="2270" y="1640">
|
||||||
|
@ -371,7 +371,7 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
|
|||||||
const tilesElListUnderTilesets = {};
|
const tilesElListUnderTilesets = {};
|
||||||
for (let tsxFilenameIdx = 0; tsxFilenameIdx < tsxFileNames.length; ++tsxFilenameIdx) {
|
for (let tsxFilenameIdx = 0; tsxFilenameIdx < tsxFileNames.length; ++tsxFilenameIdx) {
|
||||||
const tsxOrientation = tileSets[tsxFilenameIdx].orientation;
|
const tsxOrientation = tileSets[tsxFilenameIdx].orientation;
|
||||||
if (cc.TiledMap.Orientation.ORTHO == tsxOrientation) {
|
if (cc.TiledMap.Orientation.ORTHO != tsxOrientation) {
|
||||||
cc.error("Error at tileset %s: We proceed with ONLY tilesets in ORTHO orientation for all map orientations by now.", tsxFileNames[tsxFilenameIdx]);
|
cc.error("Error at tileset %s: We proceed with ONLY tilesets in ORTHO orientation for all map orientations by now.", tsxFileNames[tsxFilenameIdx]);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user