Jump to content

is a Lunar Lander type game (with rotation) possible with Phasers physics engine?


Recommended Posts

Hey guys,

I apologize for my first post being a cry for help.. but I'm in a bit of a time crunch..


I'm hoping to throw together a Lunar Lander type game but use accelerometer for the controls.

After some searching and reading I'm worried that the physics system wont be able to achieve what I'm after ( I can't math anything together :| )


This will be my first Phaser project, but I've done a little with Box2d and Pixi so I think I understand how to tie bodies together and all that fun stuff..

Basically I want to attach the "rocket engine" to a rocket, but have them both rotate based on the accelerometer's input. If your ship’s nose is tilted to the right, the boost would be applied below you and a little to the left.. depending on the overall angle of the ship.


I started with this fella's code: http://www.html5gamedevs.com/topic/2904-feedback-for-my-first-lines-of-code-moon-lander-game/?hl=moon

Was thrown by the angle maybe becoming an issue herehttps://play.google.com/store/apps/details?id=sk.flashdev.android.moonlander&hl=en

Insanely hard version of the game, but no accelerometershttp://moonlander.seb.ly/

And this guy beat me to the punch entirely: https://play.google.com/store/apps/details?id=sk.flashdev.android.moonlander&hl=en


I’m hoping their is something I’m missing with the setup of bodies, or perhaps some fancy math that can be applied to both velocity x and velocity y that correlates to the sprite angle.

Bonus points for being able to have this ship bounce off another players ship (while respecting the shape of the ship in its current rotation)


Any help or direction is awesome!


Link to comment
Share on other sites

LukaMis's link covers most of what you want to do, the clincher being how you tie it into the accelerometer.


Assuming the aim of the game is to land the ship gently and reasonably upright, the fact that Arcade physics is AABB (so the rectangular bodies do not rotate) shouldn't be an issue in this case; as the angle shouldn't be integral to the collision detection required for this kind of game. Your landing success will likely be based on the velocity being below a certain threshold when it touches the ground/landing pad, and the angle of the ship also being within a certain threshold - Phaser's angles are zeroed facing to the right, so the angle you're after is -90 degrees, plus or minus some margin of error. You probably want to normalise this to make it a little bit easier to calculate.


I don't see there being any stumbling blocks here, but should you need a more advanced physics system, Phaser also comes with P2 bundled, which is closer to Box2D in its simulation characteristics.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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