Best way to detect collision between sprites?
Whats the best way to detect collisions in a 2d game sprites? I am currently working in allegro and G++ ...
Whats the best way to detect collisions in a 2d game sprites? I am currently working in allegro and G++ ...
How do I correct for floating point error in the following physical simulation: Original point (x, y, z), Desired point (x', y', z') after forces are applied. Two triangles (A, B, C) and (B, C, D), who share edge BC I am using this method for collision detection: For each Triangle If the original point is in front of the current...
Can someone explain the pros and cons of it and any math involved with it? ...
What's your best, most elegant 2D "point inside polygon" or Polygon.contains(p:Point) algorithm? Edit: There may be different answers for floats vs integers. Primary goal is speed. ...
I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data structures like R trees are used for nearest neighbor queries and Oct/Kd/BSP are used for collis...
I have two characters displayed in a game I am writing, the player and the enemy. defined as such: public void player(Graphics g) { g.drawImage(plimg, x, y, this); } public void enemy(Graphics g) { g.drawImage(enemy, 200, 200, this); } Then called with: player(g); enemy(g); I am able to move player() around with the keyboa...
With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator. You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the "floor". My next big feature I want to add in is ball to ball collision. The ball's movement is broken up into a x and y speed vector. ...
Hi, I'm having trouble computing reflection angles for a ball hitting an oblique wall. I'm using an algorithm lifted from this tutorial. It looks like this (in Actionscript 3), with p1 being the current velocity vector and p2 the normal of the wall: private function getReflect2(p1 : Point, p2 : Point) : Point { var wallvec : Point = g...
How can I tell whether a circle and a rectangle intersect in 2D Euclidean space? (i.e. classic 2D geometry) ...
Collision detection is naturally an O(n^2) problem. You have a bunch of objects and you need to check if that object is colliding with every other object. Right now that is my naive approach and while it isn't a problem for a limited number of objects I'm now approaching the point that it is a bottleneck (after profiling my code). H...
How do games with gravity handle the relationship between moving things like players, monsters, or objects and the floor? Is the player constantly "falling into" the floor and being bounced back up? Two ways to react to collisions that I have found are moving the player back to his previous location before the collision, and testing ...
There's a lot of literature on collision detection, and I've read at least a big enough portion of it to be fairly familiar with most techniques. However, there's something that has eluded me for a while, and I figured, since StackOverflow provides access to a large group of brilliant minds at once, I'd ask here first before digging arou...
I've written a simple physics modeler that allows me to bounce balls around the screen. You can click and drag to launch a ball, or you can generate balls hundreds at a time and watch them interact with eachother. [Link to larger version] It has been a fun little program to work on and I want to take it further if I can. I know they ...
With reference to this programming game I am currently building. Thanks to the answers from this post, I am now able to find the x-y coordinates of all the points of the rectangles (even when rotated), and Collision-Detection with Walls is almost working perfectly now. Now I need to implement collision detection with the bots themselve...
I would like to downsize a Texture2D object to another Texture2D object in XNA. The reason is to use the downsized object for pixel based collision detection. Can this be done? ...
Okay, I'm trying to write a program that could tell me if any points in a 30x100 rectangle rotated to 140 degrees are inside another 30x100 rectangle rotated to 200 degrees. Honestly, I don't even know where to start. I thought about re-rotating them before doing normal calculations, but than they still wouldn't match up. How can I do...
While working on a really only-for-fun project I encountered some problem. There is a 2D world populated with Round Balls, Pointy Triangles and Skinny Lines (and other wildlife too, maybe). They all are subclasses of WorldCreatures. They can move inside this world. When they meet each other, a Collision happens. The thing I'd like to d...
I'm trying to write a method that will calculate if two circles are overlapping. I've come up with the following and I'm just curious to know if there is anyway it could be optimised further. private static boolean isCollision(Point2D p1, float r1, Point2D p2, float r2) { float a,dx, dy; a = (r1+r2) * (r1+r2); dx = (float) (p1.getX()...
Hi All.... I am doing ping pong game where I have to move ball and detect collision with outside boundary and also with moving paddle. I want to implement it using vector and not by trigonometry. I am very weak in math,so kindly guide me. ...
The OBBs have a position(x,y), a velocity(x,y) and an orientation(Matrix). Given periodic updates, the OBBs must collide with each other, returning the fraction of the move that was deemed successful. I have looked at the Polygon test on the GPWiki - http://gpwiki.org/index.php/Polygon_Collision - but it does not account for moving obj...