lance icon indicating copy to clipboard operation
lance copied to clipboard

Platformers - gravity. Request to integrate P2 in Lance.

Open sugarmaster opened this issue 7 years ago • 11 comments

Hi i'm kind of new to the web engine scene altough i'm a programmer and already experimented with phaser and others.

I would like to know if there is any way to create 2D platformer games with the engine: basic gravity, stand on a platform, jumping, etc...

I have looked at the DynamicObject and SimplePhysicsEngine classes and I see nothing related.

I want to create a 4 player 2D arena platformer and this engine has everything needed for it but this.

sugarmaster avatar Apr 29 '17 14:04 sugarmaster

Hi

A game that you describe would require integration between P2 physics engine and Lance, Lance doesn't have this right now but it's actually a good feature request. I will try to turn this issue into a feature request. If you are interested in taking on this project yourself, that would be a great pull request contribution.

If you have further questions along this line, you may prefer asking on the lance-gg slack channel. You can auto-join that team through this link

namel avatar Apr 30 '17 07:04 namel

Actually, a 2D platformer doesn't even need a physics engine. You can do away with simulating the "physical" behaviours that you need (running, jumping, walls, platforms). We did something similar in our Spaaace example

OpherV avatar Apr 30 '17 08:04 OpherV

Thank you, namel. I think it would be great to have 2D physics in Lancer. It was kinda strange to me to find out there are 3D physics with cannon js but not a fully integrated 2D engine.

As for simulating the physics OpherV I was thinking just the same if there was no plan to include 2D physics on the roadmap: just including basic gravity with acceleration and position parameters and the platform logic just checking collisions.

I found your engine because I had the idea of making a realtime js game for a long time in my mind but couldnt find any engine with the network logic already embeded into the engine so I just dropped interest.

I will look into this matter and see what is easier for me: simulating physics or implementing a physics engine. If it's the second i will contribute it to the engine.

I will join the slack channel to ask for help and stuff. Thanks.

sugarmaster avatar Apr 30 '17 12:04 sugarmaster

@sugarmaster I made great progress with this, hope to have something usable soon :)

platformer2

OpherV avatar May 22 '17 08:05 OpherV

Hi @OpherV, I'm curious as to the progress of your efforts. Is p2 available in Lance now?

dtognazzini avatar Aug 26 '17 02:08 dtognazzini

@dtognazzini the upcoming Lance V2.0 includes many new features to enable these types of games. No P2 integration yet, as I'm focusing efforts on other areas - but many enhancements to the SimplePhysics module

OpherV avatar Aug 30 '17 19:08 OpherV

I also want P2 integration, so I plan on doing a PR for this in the coming week or so (I'll be making my first attempt tomorrow, but it may take time to get ready for a PR). I'm not particularly interested in SimplePhysics, but I'm wondering if any of the enhancements or changes impact P2 integration?

For example, I haven't yet looked at the develop branch yet, but it seems to me that some of the logic in DynamicObject (the bending code) could be factored out so that it can be reused in other GameObject-derived classes. Any tips or ideas on this before I start experimenting with it myself?

danielytics avatar Sep 22 '17 14:09 danielytics

+1 on the P2 integration. I suspect it's the single most critical feature missing in Lance.

I agree with your intuition, that the bending code should be factored out of DynamicObject. Basically there should be bending code for any object types that live in 2D space, and separate bending code for any object types that live in 3D space.

Since we don't yet havean entity-component-system or mixin design in place, the bending code could simply be a separate service, which implements 2D bending and 3D bending. That way DynamicObject and your PhysicalObject2D would both use the Bending.2D service, while PhysicalObject3D would use a Bending.3D physics.

namel avatar Sep 23 '17 06:09 namel

Really excited to see a 2D physics integration on top of all the great work already in lance! I think it would be very useful for a lot of developers.

I have not studied the lance source code yet, but would love to take a look at or help test your PRs attempting this integration @danielytics @namel . Thanks!

alexfreska avatar Oct 10 '17 18:10 alexfreska

Would be very interesting the integration with Phaser Framework

jdnichollsc avatar Oct 23 '17 05:10 jdnichollsc

Hi all, i begin a Lance game to implement the p2 physics . I based the P2PhysicEngine on CannonPhysicsEngine , just to wrap the p2 world . Is not working properly at the moment , but the intention is to finish making the game work to understand whats happening and later abstract the posible classes for Lance. If some one can help or want to check it you are welcome https://github.com/Unsigno/platforms-test . ( I just moved a p2 example to a Lance project to do it online multiplayer, i will update the readme to clarify all, but you can ask me there or on lance slack )

Unsigno avatar Dec 11 '17 22:12 Unsigno