collision-detection

Javascript canvas collision detection

荒凉一梦 提交于 2019-11-30 09:26:31
I'm building a game in Javascript using canvas which requires collision detection, in this case if the player sprite hits a box, the player must not be allowed through the box. I have a global array called blockList that holds all the boxes being drawn to the canvas. It looks like this: var blockList = [[50, 400, 100, 100]]; And they're being drawn to the canvas like this: c.fillRect(blockList[0][0], blockList[0][1], blockList[0][2], blockList[0][3]); I also have a player object, which has an update method and a draw method. Update sets the position of the player based on keyboard input etc,

XNA 3d physics engine [closed]

对着背影说爱祢 提交于 2019-11-30 09:11:34
I am looking for a 3D physics engine for XNA. I heard of some options, but what I need is: free for commercial purposes (preferable open-source) support for rigid body dynamics support for per-polygon collision (this is very important) managed code - has to work on XBOX360 Have you used something like this? Can you recommend something? I would look at JigLibX . It's a C# port of the JigLib engine and has support for all the things you need. It also comes with quite a lot of samples, and if you have any experience with physics engines it shouldn't be too hard to work with it. Also, you might

JavaScript Separating Axis Theorem

 ̄綄美尐妖づ 提交于 2019-11-30 07:58:47
I'm trying to wrap my head around using the Separating Axis Theorem in JavaScript to detect two squares colliding (one rotated, one not). As hard as I try, I can't figure out what this would look like in JavaScript, nor can I find any JavaScript examples. Please help, an explanation with plain numbers or JavaScript code would be most useful. Update: After researching lots of geometry and math theories I've decided to roll out a simplified SAT implementation in a GitHub repo. You can find a working copy of SAT in JavaScript here: https://github.com/ashblue/canvas-sat Transforming polygons First

Best way to detect collision between sprites?

最后都变了- 提交于 2019-11-30 07:43:53
问题 Whats the best way to detect collisions in a 2d game sprites? I am currently working in allegro and G++ 回答1: There are a plethora of ways to detect collision detection. The methods you use will be slightly altered if depending on if your using a 2d or 3d environment. Also remember when instituting a collision detection system, to take into account any physics you may want to implement in the game (needed for most descent 3d games) in order to enhance the reality of it. The short version is to

Collision detection in html5 canvas

对着背影说爱祢 提交于 2019-11-30 07:41:18
问题 I'm trying to build a game where the user should place the circle inside a vertical bar but I'm having trouble in the collision detection function. Here is my jsfiddle : http://jsfiddle.net/seekpunk/QnBhK/1/ if (collides(Bluecircle, longStand)) { Bluecircle.y = longStand.y2; Bluecircle.x = longStand.x2; } else if (collides(Bluecircle, ShortStand)) { Bluecircle.y = ShortStand.y2; Bluecircle.x = ShortStand.x2; } function collides(a, bar) { return a.x == bar.x1 && a.y == bar.y1; } 回答1: [ Edited

Circle to Circle Segment Collision

懵懂的女人 提交于 2019-11-30 07:30:58
I'm struggling to find a rock solid solution to detecting collisions between a circle and a circle segment. Imagine a Field of View cone for a game enemy, with the circles representing objects of interest. The diagram at the bottom is something I drew to try and work out some possible cases, but i'm sure there are more. I understand how to quickly exlude extreme cases, I discard any targets that don't collide with the entire circle, and any cases where the center of the main circle is within the target circle are automatically true (E in the diagram). I'm struggling to find a good way to check

3D Line Segment and Plane Intersection

跟風遠走 提交于 2019-11-30 05:52:07
I'm trying to implement a line segment and plane intersection test that will return true or false depending on whether or not it intersects the plane. It also will return the contact point on the plane where the line intersects, if the line does not intersect, the function should still return the intersection point had the line segmenent had been a ray. I used the information and code from Christer Ericson's Real-time Collision Detection but I don't think im implementing it correctly. The plane im using is derived from the normal and vertice of a triangle. Finding the location of intersection

Tile based collision in XNA

本秂侑毒 提交于 2019-11-30 05:32:23
问题 I have drawn tiles in my XNA game and loaded my character. My character, however, doesn't move- the map does, which gives it the illusion of movement. Now I am wondering how to actually test against them for collision. I mean, where does the collision code go and how do I make all tiles represent 'one big thing'? 回答1: There's a tutorial on pixel based collision detection on XNA Creator's club. You'll need to figure out what objects you want to do collision detection on. I guess you want the

Continuous collision detection between two moving tetrahedra

不打扰是莪最后的温柔 提交于 2019-11-30 04:50:43
My question is fairly simple. I have two tetrahedra, each with a current position, a linear speed in space, an angular velocity and a center of mass (center of rotation, actually). Having this data, I am trying to find a (fast) algorithm which would precisely determine (1) whether they would collide at some point in time, and if it is the case, (2) after how much time they collided and (3) the point of collision. Most people would solve this by doing triangle-triangle collision detection, but this would waste a few CPU cycles on redundant operations such as checking the same edge of one

Detect if a cube and a cone intersect each other?

时间秒杀一切 提交于 2019-11-30 04:49:24
Consider two geometrical objects in 3D: a cube aligned with the axes and defined by the position of its center and its extent (edge length) a cone not aligned with the axes and defined by the position of its vertex, the position of the center of its base, and the half-angle at the vertex Here is a small code to define these objects in C++: // Preprocessor #include <iostream> #include <cmath> #include <array> // 3D cube from the position of its center and the side extent class cube { public: cube(const std::array<double, 3>& pos, const double ext) : _position(pos), _extent(ext) {;} double