Page 1 of 1

Should I use or not use Love Physics

Posted: Sat Jan 26, 2013 12:49 am
by n1ghtk1n9
I don't think the title is grammatically correct, but that doesn't matter

I've been thinking for quite a while now, and I've researched here and there and have seen many different opinions.
Some people say to not use the Love physics, but some people say to use it.
I'm kind of leaning on not using, since I feel like it's difficult to make new entities, without actually doing it manually
When I say manually, I mean like instead of having to do, ent1.body = love.physics.newBody(variables),
Not doing it manually would be like: newEntity(entX, entY, image, ...) and so on.

Thanks!

P.S. Sorry for the noob question, I've only used Love for a few weeks.

Re: Should I use or not use Love Physics

Posted: Sat Jan 26, 2013 3:55 am
by scutheotaku
Well, I think it mainly depends on what you want. In my experience (however limited that may be), love.physics is really good but can be way overkill (or just plain wrong) for a lot of situations.

For example...

Are you making an overhead or isometric game where you just need basic collisions (e.g. a maze game, a roguelike, an RPG, a Legend of Zelda-style game, a top down shooter, etc...)? If so, the physics system is probably overkill.

Are you making a shmup or something like that? Unless it has some really different game mechanics, the physics system is probably way overkill.

Are you making a platformer? If you want to make an "old school" platformer (e.g. like Super Mario Bros, Megaman, Contra, Commander Keen, Sonic, etc...), then the physics system will almost definitely get in your way and make it harder to give your game a good feel. If you want to make a "more realistic" or "physics based" platformer (e.g. Little Big Planet, N, etc...), then love.physics might be perfect.

To summarize: if you will only be using love.physics for basic collision (e.g. is the player running into a wall, did that bullet hit the enemy), then it is probably way overkill. If you are using love.physics because you want "realistic" gravity, friction, mass, etc..., then it should work fine for that (not saying it's flawless, but it seems to work well enough). Furthermore, if you are trying to mimic a more "old school" style (e.g. Super Mario Bros), then love.physics is probably wrong for your project as the gameplay of those older games relied on pretty unrealistic physics.

If you find that love.physics is overkill or us not right for whatever you're trying to make, you may want to look into some of the collision libraries for LOVE like bump (my personal favorite, though not the most feature rich) and HardOn (more features, and probably more popular too):
https://www.love2d.org/wiki/bump.lua
https://www.love2d.org/wiki/HardonCollider

Alternatively, you could just handle collisions in your own way (e.g. https://www.love2d.org/wiki/BoundingBox.lua ). Though it should be noted that libraries like bump and HardonCollider use a spatial hash, which makes it so that far fewer checks need to be done each frame (kikito explains this perfectly here: viewtopic.php?f=5&t=9489&start=20#p58941 ). This may not be a big deal for a game where not many things are being checked for collisions, but it can make a huge difference in a larger game.

All that being said, it is worth learning love.physics. After all, you'll probably want to use it at some point, even if you don't need it now.

EDIT:
If you want to do collisions "your own way," like I mentioned before (and this is perfectly acceptable by the way. While bump and HardonCollider's collision libraries are well optimzied, this optimization may not be necessary for "less busy game" and may not be worth the higher complexity for your project. And, of course, there's nothing stopping you from using the same methods they used to optimize their collision system for your collision system), then this video may give you a good start: [EDIT: see "EDIT AGAIN" below"] http://www.youtube.com/watch?v=vZMyHwcvoAE

If you're not sure what's going on in that video, then you may want to start from the beginning of the series (it's a pretty good series for learning LOVE):
http://sockmunkee.com/videos/

EDIT AGAIN:
Sorry! The video I linked to in "EDIT" doesn't actually have real collision...
So, for collision backs, instead of that check out these tutorials:
http://www.headchant.com/2010/11/26/lov ... llo-world/ <<<this is a nice introduction to LOVE that takes you through creating a basic Space Invaders style game. Features simple collision in part 2 of the tutorial.
http://www.youtube.com/watch?v=POVQBI9i ... 1&index=10 <<<a good tutorial that talks about hitboxes/collision. To understand it, you may want to go through the whole tutorial series (a good series for getting started): http://www.youtube.com/playlist?list=PL924F20B05A624D91
http://www.explodingrabbit.com/forum/en ... al-01.669/ <<<a LOVE platformer tutorial that includes tile-based collision and regular bounding box collision
http://www.headchant.com/2012/01/06/tut ... ve-part-1/ <<<another platformer tutorial that includes collision, though this one uses HardonCollider for collision (so it will be a good example for how to use that library for a platformer).

Sorry for the overall sloppiness of this post! Hopefully it was somewhat helpful :/