Port of Hardon Collider
Monkey Archive Forums/Monkey Projects/Port of Hardon Collider| 
 | ||
| In order to learn Monkey-X more 'in-depth' I ported the LÖVE collision library Hardon Collider. The library is on git: https://github.com/ratkingsminion/hc-monkey/ It supports points, circles, and convex and concave polygons. Rectangles are just convex polys. It only checks if there is collision between the objects and doesn't separate them. Here's an example: https://dl.dropboxusercontent.com/u/10650964/_stuff/hc-monkey/hc-monkey-example.html   | 
| 
 | ||
| Nice! Reminds me of this this I posted a while back: http://www.monkey-x.com/Community/posts.php?topic=2571 same principle. | 
| 
 | ||
| That's great, thanks! I'd love to see an example that includes collision reaction. Is there a way to get a normal out of a collision? | 
| 
 | ||
| The mtv_x and mtv_y values you get from OnCollision() (in the ICollisionResponse interface) are the delta position the shape is shoved back, so to speak. As soon as I have time I'll try to make a small example. | 
| 
 | ||
| Gotta say, unless you've made a typo that is the funniest library name I've ever seen lol! | 
| 
 | ||
| It's neither a typo, nor is it by me. :-P It's just a straight port of an already existing collision library from the LÖVE community. As far as I know they often use such Freudian names for their libraries, like HUMP or Lovetoys or Quickie... | 
| 
 | ||
| Hi, I've been playing around with this a little and so far so good. There does seem to be a problem with using 'Point' shapes. I will have a little demo video in my thread showing this collision library in action. I see potential. :) Edit:  I'd love to see an example that includes collision reaction. Is there a way to get a normal out of a collision?  I am looking into this as well. I'll need a normal for the reaction part of the collision. | 
| 
 | ||
| Looking forward to separation code / normal generating / handling. | 
| 
 | ||
| Thanks for this, if there's one thing I suck at, it's collision code, this will come in very useful | 
| 
 | ||
| This is probably a really daft question. But lets say I want to extend the Shape Class as Tile. How do I go about creating an instance of Tile that uses the HC.Rectangle(x,y,width,height) function? Class Tile Extends Shape Const WIDTH:Float = 16 Const HEIGHT:Float = 16 Field x:Float Field y:Float Function Create:Tile(tX:Float, tY:Float, tW:Float, tH:Float) Local tT:Tile = NApp.hc.Rectangle(tX, tY, tW, tH) tT.x = tX tT.y = tY Return tT End Method Render:Void(canvas:Canvas) canvas.DrawRect(x, y, WIDTH, HEIGHT) End Method End I thought about casting the returned Shape, but I get a null... Local tT:Tile = NApp.hc.Rectangle(tX, tY, tW, tH) to Local tT:Tile = Tile(NApp.hc.Rectangle(tX, tY, tW, tH)) Any clues? | 
| 
 | ||
| I haven't used HC, but I'd say you're probably making a bit of an error by trying to extending anything in that way. I'd imagine you'll be much better off defining your Tile class as having a collision shape member. I'd only look at extending Shape if I were really creating a new collision shape (like a CircleSectorShape or something). | 
| 
 | ||
| I did wonder that as well, in fact that's exactly where I went initially, but assumed (wrongly it seems!) that it might be more efficient to extend. | 
| 
 | ||
| muddy_shoes is right, you would use a Shape as a member variable. Your code bit is a bit strange anyway, I wonder why you do Extend Shape if you don't actually implement the methods of Shape... :) |