Skip to content

Commit 5182c03

Browse files
Bounce the ball on screen instead of Offscreen at the bottom and right (#57)
* Prevent the sprite from going off screen Its just a simple visual yet neat thing to have :3 * fix trivial pet-peeve --------- Co-authored-by: George Kurelic <[email protected]>
1 parent 55e1f88 commit 5182c03

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

demos/states/flxsubstate/source/PlayState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class PlayState extends FlxState
4646
{
4747
super.update(elapsed);
4848

49-
if (sprite.x < 0 || sprite.x > FlxG.width)
49+
if (sprite.x < 0 || sprite.x + sprite.width > FlxG.width)
5050
{
5151
sprite.velocity.x *= -1;
5252
}
53-
if (sprite.y < 0 || sprite.y > FlxG.height)
53+
if (sprite.y < 0 || sprite.y + sprite.height > FlxG.height)
5454
{
5555
sprite.velocity.y *= -1;
5656
}

0 commit comments

Comments
 (0)