collision-detection

Mass Ball-to-Ball Collision Handling (as in, lots of balls)

久未见 提交于 2019-12-01 20:30:49
Update: Found out that I was using the radius as the diameter, which was why the mtd was overcompensating. Another Update: The reason my balls are overlapping seem to be because there's only one check for every collision. After some research, some are saying that one of the ways you could prevent overlapping with objects piling up is to recursively perform the collision check. This works to an extent, and I suspect that it'd work even better if the physics were a lot more accurate. I'll update again if I find any more solutions. Also, I'm using Simucal's collision correction code. Hi,

line-rectangle collision detection

假装没事ソ 提交于 2019-12-01 20:30:46
问题 I have one line (two point (x,y) (x1,y1)) and a rectangle with focus point (rx,ry). I need help to find out collision point between line and rectangle, an example in C++ will be help. 回答1: I don't see how you can represent a rectangle with just a "focus point". You'll need either the two corner points or one corner point with a width/height/rotation set of data. However, once you have a rectangle, I would simply break it down into four lines and do the intercept checks between each of those

Javascript collision detection system don't ignore blocked collisions

回眸只為那壹抹淺笑 提交于 2019-12-01 19:59:37
I'm having issues during a minigame development using EaselJS with my collision detection system and I need someone's help. The issue occurs when the hero (a circle bitmap) collides an object and there's other object behind the first one, the hero collides with both objects, even if the second collision is blocked. Here's an image explanation: The cause of the problem is really simple, even if the problem itself isn't: This collision detection system is based on the future position of the circle (and not on its actual position), then if the next position of the circle intersect a rectangle, it

Click on given element in canvas

北城以北 提交于 2019-12-01 19:40:26
Is there any trick to determine if user clicks on given element rendered in canvas? For example I'm displaying rhombus from .png file with transparent background and i want to know if user click inside or outside that figure (like mouse-element collision). There is no concept of individual elements in a canvas - it is simply just an area that you're drawing pixels onto. SVG on the other hand is made up of elements which you can then bind events to. However there are a few approaches you can take to add click events to canvas: Position an html element that overlays the area on the canvas you

Python & Pygame: Ball collision with interior of circle

こ雲淡風輕ζ 提交于 2019-12-01 16:29:15
I'm making a game in which balls bounce around the inside of a much larger circle. The larger circle doesn't move. Here's the code that I'm currently using for these collisions: def collideCircle(circle, ball): """Check for collision between a ball and a circle""" dx = circle.x - ball.x dy = circle.y - ball.y distance = math.hypot(dx, dy) if distance >= circle.size + ball.size: # We don't need to change anything about the circle, just the ball tangent = math.atan2(dy, dx) ball.angle = 2 * tangent - ball.angle ball.speed *= elasticity + 0.251 angle = 0.5 * math.pi + tangent ball.x -= math.sin

Python & Pygame: Ball collision with interior of circle

十年热恋 提交于 2019-12-01 15:45:31
问题 I'm making a game in which balls bounce around the inside of a much larger circle. The larger circle doesn't move. Here's the code that I'm currently using for these collisions: def collideCircle(circle, ball): """Check for collision between a ball and a circle""" dx = circle.x - ball.x dy = circle.y - ball.y distance = math.hypot(dx, dy) if distance >= circle.size + ball.size: # We don't need to change anything about the circle, just the ball tangent = math.atan2(dy, dx) ball.angle = 2 *

Javascript ball collision

孤者浪人 提交于 2019-12-01 14:00:20
I am trying to create a simple javascript game with simple physics. I can determine when 2 balls are colliding but I have having problems with handling the collision. Does anyone know of any useful tutorials on this? I've been searching the internet for a couple days but can't seem to find anything. In the UK, this would be A-level maths, so not too advanced. I think the phrase you need is " elastic collision ". That page has some of the formulae you need. Physics for JavaScript Games, Animation, and Simulations with HTML5 Canvas is a Book all about modeling Physics simulations in JavaScript.

collision detection for paddle (pong/breaking block game)

浪尽此生 提交于 2019-12-01 13:51:34
I'm new to javascript, and trying to learn the collision detection for the paddle. This might be simple, but I don't know how to create collision detector of the paddle I created. How do this work and what do I have to put in order to create collision detection? (I don't need know about bricks, I just have to create simple animated/game javascript page.) Oh and do you know what kind of javascript am I using? because sometimes it is totally different coding so it's really hard to find my type of coding I can follow of.. Thankyou! var canvas = document.getElementById("myCanvas"); var ctx =

collision detection in javascript game?

和自甴很熟 提交于 2019-12-01 13:39:05
问题 My Map array ;; map[0] = [0,0,0,0,0,0] map[1] = [0,1,0,1,0,1] map[2] = [0,0,0,0,0,0] map[3] = [1,0,1,0,1,0] map[4] = [0,0,0,0,0,0] map[5] = [0,1,0,1,0,1] 1= Hurdle 0 = Nothing i've to detect collision detection b/w player and hurdles in map. player.x & player.y is the reference from left top . Each hurdle is 40px of width and length . i need a roughly concept not codes 回答1: You have to normalize player position to the collision map unit as player position is in px units and your collision map

Box2D: How to get the position of a static body?

大城市里の小女人 提交于 2019-12-01 13:38:51
I have a Box2D world with a mixture of static and dynamic bodies. On collisions, I can only get the positions of the dynamic ones. Is it possible to get the positions of static objects? N.b., this is a development of a previous question, Box2D: How to get the position of a sensor? I found a way - in the collision, the center of the AABB will give the position contact.GetFixtureA().GetAABB().GetCenter() You can get the position vector using the following code: b2Transform t = body->GetTransform(); b2Vec2 pos = b2Vec2(t.p.x,t.p.y); 来源: https://stackoverflow.com/questions/5666834/box2d-how-to-get