-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Contact Bias Solver order for seams + Deprecate ex.Ph…
…ysics Static (#2926) This PR implements arcade contact solver bias, so you can choose to solve horizontal or vertical first. Or to defer to the default order by distance. Additionally this PR marks the `ex.Physics` static configuration object as deprecated and will be removed in v0.30. It still will work to configure physics behavior. Now the new way to configure physics will be where everything else is configured, the `ex.Engine({..})` constructor. ```typescript const engine = new ex.Engine({ ... physics: { solver: ex.SolverStrategy.Realistic, arcade: { contactSolveBias: ex.ContactSolveBias.VerticalFirst }, } }) ``` Without the bias `ex.Physics.arcadeContactSolveBias = ex.ContactSolveBias.None;` https://github.com/excaliburjs/Excalibur/assets/612071/0d7c1217-911d-4791-8425-b45d06f7da8e Using the bias `ex.Physics.arcadeContactSolveBias = ex.ContactSolveBias.VerticalFirst;` https://github.com/excaliburjs/Excalibur/assets/612071/8873bedf-ea07-4e85-9376-8c1f8ae56089
- Loading branch information
Showing
34 changed files
with
869 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Arcade Collision Solver - Seam</title> | ||
</head> | ||
<body> | ||
<p>Compare with physics.arcade.contactSolveBias: None & physics.arcade.contactSolveBias: VerticalFirst</p> | ||
<script src="../../lib/excalibur.js"></script> | ||
<script src="./index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/// <reference path='../../lib/excalibur.d.ts' /> | ||
|
||
var game = new ex.Engine({ | ||
width: 1000, | ||
height: 1000, | ||
fixedUpdateFps: 60, | ||
physics: { | ||
gravity: ex.vec(0, 5000), | ||
solver: ex.SolverStrategy.Arcade, | ||
arcade: { | ||
contactSolveBias: ex.ContactSolveBias.VerticalFirst | ||
} | ||
} | ||
}); | ||
|
||
game.toggleDebug(); | ||
|
||
// big tiles so distance heuristic doesn't work | ||
var lastWidth = 200; | ||
var lastPos = ex.vec(0, 0); | ||
for (let x = 0; x < 10; x++) { | ||
const width = (x % 2 === 1 ? 16 : 200); | ||
game.add( | ||
new ex.Actor({ | ||
name: 'floor-tile', | ||
x: lastPos.x, | ||
y: 300, | ||
width: width, | ||
height: x % 2 ? 16 : 900, | ||
anchor: ex.Vector.Zero, | ||
color: ex.Color.Red, | ||
collisionType: ex.CollisionType.Fixed | ||
}) | ||
); | ||
lastPos.x += width; | ||
} | ||
|
||
var player = new ex.Actor({ | ||
pos: ex.vec(100, 270), | ||
width: 16, | ||
height: 16, | ||
color: ex.Color.Blue, | ||
collisionType: ex.CollisionType.Active | ||
}); | ||
|
||
player.onPostUpdate = () => { | ||
const speed = 164; | ||
if (game.input.keyboard.isHeld(ex.Keys.Right)) { | ||
player.vel.x = speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Left)) { | ||
player.vel.x = -speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Up)) { | ||
player.vel.y = -speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Down)) { | ||
player.vel.y = speed; | ||
} | ||
} | ||
game.add(player); | ||
|
||
|
||
game.currentScene.camera.strategy.elasticToActor(player, .8, .9); | ||
game.currentScene.camera.zoom = 2; | ||
|
||
game.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.