Block Breaker: breaking blocks & pathfinding
July 13, 2007 at 5:49 pm | In Game idea's |Breaking away blocks now actually works! I had to implement some pathfinding to pull it off: I’ve used vertices as nodes and edge lengths as path costs, to find the block with the smallest enclosing, from a given start and end vertex (the intersection points). It does the job quite nicely now:

I’ve ported this game to C++, using Haaf’s Game Engine, partly because it ran too slow in Python (after quite a bit of shooting around, of course), and partly because I needed a solid debugger for further progress. The whole project is now quite a bit past it’s prototyping stage anyway: I know what kinds of issues I need to solve, and I know how I can solve most of them:
- removing any leftover edges in the old shape - a few comparisons between the two blocks should tell which edges have become obsolete
- making some other edges border edges - again, just a few comparisons
- making sure the new block doesn’t have it’s edges inverted - in some cases, new blocks have inverted edges, and I don’t know yet how I’ll solve this
- determining when a loose path should become part of the new block - this one is more tricky, but I think comparing angles between edges should suffice
- determining the surface of the new block - tricky, I think I’m going to triangulate the shape and take the sum of the surfaces of the resulting triangles
- determining the center of the new block - again, tricky, but triangulating the shape and taking the average center should do the job
- and finally, some debugging here and here…
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.