Jump to content

Ability to fall through walls at low FPS - arcade physics


ashes999
 Share

Recommended Posts

I started using this excellent Phaser tutorial: http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game

 

I skipped to part nine. I added a method called createStar(), which I call twice when a user collects a star:

 

function collectStar (player, star) {        // Removes the star from the screen    star.kill();    createStar(Math.random() * (800 - 96))    createStar(Math.random() * (800 - 96))    //  Add and update the score    score += 10;    scoreText.text = 'Score: ' + score;}function createStar(x) {  //  Create a star inside of the 'stars' group  var star = stars.create(x + (Math.random() * 60) - 30, 0, 'star');  //  Let gravity do its thing  star.body.gravity.y = 100;  //  This just gives each star a slightly random bounce value  star.body.bounce.y = 0.4 + Math.random() * 0.2;    if (starsText !== 'undefined'&& starsText != null && stars != 'undefined' && stars != null) {    starsText.text = 'Stars: ' + stars.total;  }}

(Note: in the initial for-loop, pass in i * 70 to reproduce the original behaviour.)

 

As you can imagine, eventually, you can get to lots and lots of stars. On my Ubuntu VM, I clock in around 800 stars before the FPS drops to 30.

 

Some observations:

- The game stutters when I move into a place where I collect a ton of stars -- looks like the collision handling

- Once I reach around 10-15 FPS (first noticed at 13 FPS), I sometimes try to jump onto the bottom platform but fall through instead.

 

Is this a bug? 

 

In other frameworks, when you control the update call, you can usually call it with a small value if a large amount of time elapses, eg. if one second passed since the last call, you advance game time by calling update(100ms) ten times.  This is supposed to be the fix for high-speed (or low-FPS) physics.

 

Full PasteBin is here: http://pastebin.com/TpjQrxAQ

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...