collision-detection

How to do pixel-perfect collision detection of a player and the walls (JavaScript Game)

为君一笑 提交于 2019-12-23 06:23:09
问题 I'm making a 2D game in JavaScript. For it, I need to be able to "perfectly" check collision between my players(the game has two players, open the picture please) and the walls! I mean, I have a function that actually works, but when I make them jump against the walls they pass through the walls and keep moving until they reach another area or even leave the canvas! Also, if they are falling down and I make them collide with a wall, they just stop there wich is also pretty bad! I really need

How do I make my hitTestObject() more precise?

随声附和 提交于 2019-12-23 05:22:26
问题 I'm doing some collision detection with a circle and a square and whenever the circle comes in contact with the square it bounces away changing its X coordinate by *-1. However, the Hit Area of the circle is a square, so even when it collides with the white area around the circle , the affect still occurs. My question is, is there a way to modify the hit area to closer resemble my circle? Thanks 回答1: Bitmap hit testing is pixel based (instead of boundary-based, like Sprite-based hit testing),

3D Line Segment and Plane Intersection - Contd

大城市里の小女人 提交于 2019-12-23 04:56:19
问题 After advice from krlzlx I have posted it as a new question. From here: 3D Line Segment and Plane Intersection I have a problem with this algorithm, I have implemented it like so: template <class T> class AnyCollision { public: std::pair<bool, T> operator()(Point3d &ray, Point3d &rayOrigin, Point3d &normal, Point3d &coord) const { // get d value float d = (normal.x * coord.x) + (normal.y * coord.y) + (normal.z * coord.z); if (((normal.x * ray.x) + (normal.y * ray.y) + (normal.z * ray.z)) == 0

Optimizing collison detection code in AS3

别等时光非礼了梦想. 提交于 2019-12-23 04:45:30
问题 I have two mc's on the stage, the first one is called missiles and the second one is called boxes. So accordingly I put boxes in the boxes mc and missiles in the missiles mc. My problem is how to detect whether any of the missiles collide with boxes and make damage to the box. I am using simple and effective algorithm which works but it is very slow when there are many missiles and boxes on stage. I am using two nested "for" cycles which is a bad practice, but I don't have other idea at the

Ball and brick collision handling

☆樱花仙子☆ 提交于 2019-12-23 04:32:02
问题 I have made the game, "Breakout". A small fun side-project. Now, I usually do not make games, so collision-handling is not something I normally think about. I have a paddle, a ball and some bricks. For now, when there is a collision (I draw rectangles around each of the objects mentioned), I simply change the Y value of the ball to -Y. This works fine, EXCEPT if the ball hits a brick from the side (either East or West). The side-effect is not pretty and ruins the gameplay. I think I can

CCRenderTexture size and position in Cocos2d-iphone

只愿长相守 提交于 2019-12-23 03:37:10
问题 I was trying to use CCRenderTexture for pixel perfect collision detection, as outlined in this forum posting: http://www.cocos2d-iphone.org/forum/topic/18522/page/2 The code "as is" works, and I have integrated it with my project But I am having trouble doing some of the other things discussed: If I create the renderTexture to be any size less than the screen size, the collision detection doesn't work properly - It seems to show collisions when the sprites are close (<15px) to each other but

CGAL Mesh(es) intersection/collision

不羁的心 提交于 2019-12-22 20:43:07
问题 I would like to have a collision detection module in my tracking pipeline, detecting when two different meshes collide/interpenetrate or if there is a self-penetration of an articulated mesh. Based on the depth of the penetration there should be a penalization that combats this phenomenon. I should get a list of the colliding faces/vertices in order to do so. After examining several options, I decided to start working with CGAL. In this link there is an interesting answer pointing to some

Collision detection between ball & bricks in brick breaker game [closed]

萝らか妹 提交于 2019-12-22 12:22:53
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . How do you detect a collision between ball & bricks in a brick breaker game? 回答1: Bounding Box Collision That should get you started, and give you some terms to search for. Essentially you treat each brick as a bounding box. Based on the ball position you should be able to

How to prevent draggable child elements from dragging over each other?

对着背影说爱祢 提交于 2019-12-22 11:21:19
问题 How to prevent draggable child elements from dragging over each other in absolute position? Something like: if( ($("#firstChild").position().left) >= ($("#secondChild").position().left) ) { $(this).draggable({ disabled: true }); } but this only disables dragabble when stop dragging, the goal is to prevent from overdragging in some way...Or with Droppable??? Any ideas for CASE 2? EDIT: Also, this is maximum for child1 towards child2 , so no overlap occurs , but child1 can push child2 on right,

Detect collision between a moving object and an immobile one

一世执手 提交于 2019-12-22 05:10:09
问题 First of all, my question isn't really specific to C# or XNA, but my code examples will use these. I am currently trying to make a Pong clone and I've run into a problem with collision-detection. Each object basicly has a specific Velocity(which is a Vector2), Position(Vector2, also) and Speed(just a float). On every Update() call of the object, the position is changed this way: Velocity.Normalize(); Position += Velocity * Speed; At first, I only checked if there currently was a collision