Jump to content

Removing interpolation from movement in Phaser


scanlonman
 Share

Recommended Posts

Hello everyone!

 

I'm creating a Tetris style game where I want my blocks to fall at ~16 pixels every 10 frames.

 

You can see something similar here: http://youtu.be/vBpdS5d1i1k?t=1m26s (gameplay video of Tetris)

 

I was curious how I could emulate this within Phaser.  I'm familiar with other game engines where there's a delta time variable (Cocos2D-iphone, Cocos2D-x) and the concept of removing that is completely new to me. 

 

Thank you for your time.

Link to comment
Share on other sites

I remember one of the first Tetris clones I wrote used the following technique, which I think could work nicely here too (I've modified this concept for Phaser specifically)

 

You have a hidden "collision block" that drops from the top to the bottom. You can drop this using velocity, acceleration, whatever you like. Consider it as being your "marker". Now add your actual Tetris piece to the display, make sure it's visible and under the players control so they can rotate it.

 

In your update loop monitor the y coordinate of the marker and once it hits the multiple you need (16px multiples I guess?) you drop the visible players piece down by 16px. You can do the same for the horizontal too. As long as the marker is the same overall dimension of the piece (including rotation) they should track each other quite happily.

 

You could even use the collision block for custom collision handling when it gets to the bottom, but it may be easier to write your own method for this given the unique way Tetris works.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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