jasonmcleod Posted June 23, 2014 Share Posted June 23, 2014 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=moonWas thrown by the angle maybe becoming an issue here: https://play.google.com/store/apps/details?id=sk.flashdev.android.moonlander&hl=enInsanely hard version of the game, but no accelerometers: http://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!Thanks! Link to comment Share on other sites More sharing options...
lukaMis Posted June 23, 2014 Share Posted June 23, 2014 This was my starting point: link: http://gamemechanicexplorer.com/#thrust-4 Link to comment Share on other sites More sharing options...
lewster32 Posted June 23, 2014 Share Posted June 23, 2014 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 More sharing options...
jasonmcleod Posted June 24, 2014 Author Share Posted June 24, 2014 Thanks for the tips guys! I really appreciate it! I'll see where I land today! (no pun intended, ok maybe a little) clark 1 Link to comment Share on other sites More sharing options...
Recommended Posts