box collision detection help needed

Started by
12 comments, last by Chad Smith 10 years, 11 months ago

Thanks for the help guys, Jdean300 has managed to solve my problem. I do understand your code now BeerNuts, and will try to rewrite it your way and see if I can get the same result as Jdean300 (which is working correctly).

Thanks again guys, you've been great help!

Mike

The method I provided handles things like a player jumping up and right, and hitting a wall, the player will stop going right, but will continue to move up, then down, like sliding against a wall.

FWIW, I've moved to using a 2d physics library to handle all my movements, collision detection, and collision responses. Personally, I use chipmunk-physics, but others use box2d, both are good, and it makes writing 2d games Sooooo much easier.

In my Signature, the link to my old blog details making a top-down 2d game using chipmunk-physics if you want to check it out.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Advertisement

Thanks BeerNuts,

I have heard of these libraries but thought it would be important to learn everthing from the bottom up (collision is the worst). I have also read that professional game studios and developers don't bother make their own code for physics etc, they just use 3rd party libraries. Do you think it's worth the time to and frustration to struggle with the collision and physics or should I not bother wasting time and just switch to the library you recommended?

Mike

o you think it's worth the time to and frustration to struggle with the collision and physics or should I not bother wasting time and just switch to the library you recommended?

Up to you really. There's much to be learned if you code the movement and collisions yourself, no doubt. But, it's almost certainly going to be very poor compared to the solutions offered by these third party libraries; they can do some really cool things. So, if you want to dive more into the game making, then use the physics library.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Thanks BeerNuts,

I have heard of these libraries but thought it would be important to learn everthing from the bottom up (collision is the worst). I have also read that professional game studios and developers don't bother make their own code for physics etc, they just use 3rd party libraries. Do you think it's worth the time to and frustration to struggle with the collision and physics or should I not bother wasting time and just switch to the library you recommended?

Mike


I'd say it fully depends on your needs.

Though what I generally say is that if you are just learning/practicing and not writing anything really that you'd release or working on a project then try learning it completely. It gives you a great idea how things are implemented internally in libraries you use.

Though if you are working on a project then try using a physics/collision library if it fits your needs. Most of the time these libraries are so much better and optimized than anything you would write, plus youd be wasting development time reinventing the well.

If you're just learning though then it's fine. It's good to know how stuff is internally represented just in case you run into issues. You have an idea what the problem may be.

This topic is closed to new replies.

Advertisement