Page 1 of 1

[Help]Sidescroller Engine

Posted: Tue Nov 24, 2015 4:35 pm
by zrrion
Hello. This is my first post on these forums, so I apologize if this is the wrong place for this post.

Anyway. I've taken a look at löve and it looks to be the exact thing I would want for an indie sidescroller. Problem is, I am unsure where to start. From my searching there don't appear to be any basic 2D sidescroller engines floating around for love, but rather every project has built their own.
Is this the case? If it is, where would I look to start building my own?
If it is not the case, can anyone point me towards an engine?

tl;dr could someone point me in the right direction for making a sidescroller, either to an engine, or to someething that would help with creating my own?

Re: [Help]Sidescroller Engine

Posted: Tue Nov 24, 2015 5:42 pm
by Jasoco
If you don't need slopes, you can look into kikito's Bump 3.0 (Not 2.0. Both threads are in the Demos forum. 3.0 is better.) collision detection and resolution library. It has a simple demo of a platformer. But it's very simple. If you want to actually do scrolling you should look into a camera library if you don't want to try and figure it all out yourself. I code my own from scratch but it's a lot of work. You could start simple and go the Knytt route where the level is divided into non-scrolling screens. Then you don't have to bother with camera math and can implement that into a later project once you've gotten the hang of coding.

See, one thing you need to remember when scrolling is that you have to learn how to cull stuff that isn't on screen. Like if you have a large tile map, you don't want to be looping over every single tile in the level every frame because like 80% of it is off screen and it's wasting time and slowing down. So you need to do some math and only loop over the visible tiles. That's one tip to remember.

Also, physics for a platformer are simple usually, but can still be a bit overwhelming. If you are new to programming you can start with a different kind of game like a top-down game where you don't need to really worry about whether you're jumping or standing on a platform.

Also, don't use Box2D for your 2D platformer unless you know exactly how to use Box2D to make it work like a normal platformer. It might be tempting to use it because it's there, but it also does not work like a regular platformer out of the box. It takes a lot of tweaking and work to make sure you can work the physics correctly. Just way too much work. Just look at Concerned Joe/Move or Die. Those are built in Löve with Box2D but took a lot of work to get where they are but the character physics might still feel "floaty" to someone used to other platformers.

Re: [Help]Sidescroller Engine

Posted: Tue Nov 24, 2015 9:13 pm
by adnzzzzZ
Jasoco wrote: Also, don't use Box2D for your 2D platformer unless you know exactly how to use Box2D to make it work like a normal platformer. It might be tempting to use it because it's there, but it also does not work like a regular platformer out of the box. It takes a lot of tweaking and work to make sure you can work the physics correctly. Just way too much work. Just look at Concerned Joe/Move or Die. Those are built in Löve with Box2D but took a lot of work to get where they are but the character physics might still feel "floaty" to someone used to other platformers.
All you have to do is use body:setLinearVelocity and do velocity/acceleration calculations on your side to make it not floaty. Then whenever you need the physics engine to take over (like when you want to push an object based on some force), use body:applyLinearImpulse or body:applyForce and make sure to disable your setting of body:setLinearVelocity so the body's velocity isn't overwritten while it's being pushed. This is relatively simple logic that gives you control over how movement works.

Re: [Help]Sidescroller Engine

Posted: Tue Nov 24, 2015 10:03 pm
by pgimeno
adnzzzzZ wrote:All you have to do is use body:setLinearVelocity and do velocity/acceleration calculations on your side to make it not floaty. Then whenever you need the physics engine to take over (like when you want to push an object based on some force), use body:applyLinearImpulse or body:applyForce and make sure to disable your setting of body:setLinearVelocity so the body's velocity isn't overwritten while it's being pushed. This is relatively simple logic that gives you control over how movement works.
I'm not the OP, but wanted to thank you for the advice anyway :nyu:

Re: [Help]Sidescroller Engine

Posted: Tue Nov 24, 2015 11:45 pm
by Lafolie
A physics library can be great, but when you're starting out I do believe that it's a very good idea to have a go at doing some pseudo physics yourself. Having an understanding or insight as to how things like Box2D work internally can help you solve problems when you do use them, and adds to your overall grounding. You might even pick up some habits or techniques that are useful elsewhere (this is particularly true with data structures).