Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

New Codea Tutorial - Collision Detection

edited July 2013 in Examples Posts: 563

There is a new tutorial on collision detection for Codea at: http://codeatuts.blogspot.com.au/2013/07/tutorial-31-codea-collision-detection.html

It shows a number of simple approaches and culminates in building a simple Asteroids app to demonstrate the built in collision detection functionality provided by Box2D.

This is meant to be an introductory tute so I haven't gone down to pixel perfect collision techniques.

As usual comments, improvements and alternate approaches are welcomed. How do you do collision detection in Codea?

Comments

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Reefwing - when I explored the physics engine, I found the entire Debugdraw code to be totally unnecessary, unless you are doing very advanced stuff. I certainly wrote collision code without any of it, and I think Debugdraw is a real red herring because people think it is necessary for them to write physics code.

  • Posts: 563

    @Ignatz - you need something to draw the physics bodies each frame. I agree you don't need to use PhysicsDebugDraw for this but when I started writing my own I ended up reproducing something similar so in the end decided just to simplify the existing class.

    There is still unnecessary code in my simplified version, so you may be correct in that I have ended up with something which isn't totally generalised or bespoke. What do others think?

  • IgnatzIgnatz Mod
    edited July 2013 Posts: 5,396

    @Reefwing - I just loop through the sprites attached to the physics bodies, position them, and draw them. There's no need for any of the tables and fancy stuff in debugdraw.

    If you're trying to make the tutorial as simple as possible, I suggest clearing out unnecessary code. I speak from personal experience, because spent hours trying to decipher debugdraw before realising I didn't need it at all. IMHO, the physics demo would be much better without it, because it makes physics look way more difficult than it is.

    Here is my tutorial on collision detection

    http://coolcodea.wordpress.com/2013/03/21/6-more-physics/

  • Posts: 563

    Nice tute @Ignatz - and you are correct it is simpler to draw a sprite than reconstruct graphic primitives.

Sign In or Register to comment.