mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
rename-mul
...
test-platf
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f6eafb32a0 |
@@ -1328,12 +1328,11 @@ describe('gdjs.PlatformerObjectRuntimeBehavior', function () {
|
||||
});
|
||||
|
||||
it('can fall through the jumpthru from the left side', function () {
|
||||
jumpthru.setPosition(0, -33);
|
||||
object.setPosition(0, -100);
|
||||
jumpthru.setPosition(12, -90);
|
||||
jumpthru.setCustomWidthAndHeight(60, 100);
|
||||
|
||||
// Check the jumpthru let the platformer object go through.
|
||||
// The jumpthru lets the character go through.
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
object.getBehavior('auto1').simulateRightKey();
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
@@ -1343,9 +1342,50 @@ describe('gdjs.PlatformerObjectRuntimeBehavior', function () {
|
||||
);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(true);
|
||||
}
|
||||
// Overlapping the jumpthru
|
||||
expect(object.getX()).to.above(5);
|
||||
expect(object.getY()).to.be.within(-100, -80);
|
||||
// The character is overlapping the jumpthru.
|
||||
expect(object.getX()).to.above(jumpthru.getX() - object.getWidth() + 3);
|
||||
expect(object.getY()).to.be.within(
|
||||
jumpthru.getY() - object.getHeight() + 10,
|
||||
jumpthru.getY() + jumpthru.getHeight() - 10
|
||||
);
|
||||
});
|
||||
|
||||
it('can fall through a jumpthru from the left side and land on another jumpthru', function () {
|
||||
object.setPosition(0, -100);
|
||||
jumpthru.setPosition(1, -90);
|
||||
jumpthru.setCustomWidthAndHeight(60, 20);
|
||||
|
||||
// Add another jumpthu under with a 10 pixels interleave (less than object height).
|
||||
bottomJumpthru = addJumpThroughPlatformObject(runtimeScene);
|
||||
bottomJumpthru.setPosition(1, -70);
|
||||
bottomJumpthru.setCustomWidthAndHeight(60, 20);
|
||||
|
||||
// The jumpthru lets the character go through.
|
||||
for (let i = 0; i < 7; ++i) {
|
||||
object.getBehavior('auto1').simulateRightKey();
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(true);
|
||||
expect(object.getBehavior('auto1').isFallingWithoutJumping()).to.be(
|
||||
true
|
||||
);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(true);
|
||||
}
|
||||
// The character is overlapping the jumpthru.
|
||||
expect(object.getX()).to.above(jumpthru.getX() - object.getWidth() + 3);
|
||||
expect(object.getY()).to.be.within(
|
||||
jumpthru.getY() - object.getHeight() + 1,
|
||||
jumpthru.getY() + jumpthru.getHeight() - 1
|
||||
);
|
||||
|
||||
// The character lands on the other jumpthru
|
||||
// while still overlapping the other one.
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
}
|
||||
expect(object.getBehavior('auto1').isOnFloor()).to.be(true);
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
expect(object.getY()).to.be(bottomJumpthru.getY() - object.getHeight());
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user