collision-detection

What's a good, simple, 2D rectangles-only collision detection algorithm?

允我心安 提交于 2019-12-21 03:34:25
问题 I'm designing a collision detection game tutorial for young adults, so I want this to be as simple as possible to make it easier to explain. The requirements are very simple. The world is 2D and contains only rectangles (of arbitrary sizes). BSP and even quadtrees seems like it would be overkill (again, the emphasis is on simplicity) but I would like something more efficient than brute forcing through all n(n-1)/2 possible collisions. 2D, rectangles only, and simple. Can anyone point to an

Problem with collision detection of a fast moving ball with a racket controlled by mouse

别来无恙 提交于 2019-12-20 14:41:45
问题 In unity, i have a racket which is supposed to hit a ball, and the racket is controlled directly by the mouse, i.e the bat is being moved by the mouse using mouse axes and the using transform.translate() function to move the racket. I expected that Unity3d's physics will not properly translate the racket's movement directly by mouse and impact the ball accordingly, and i would have to write something custom, and it turned out to be true. But the ball's collision is not being detected properly

Collision Detection in Flash Functionalities? (hitTestObject)

拜拜、爱过 提交于 2019-12-20 07:04:49
问题 Hello, so I've been recently using hitTestObject to detect collisions in an android app I'm making. After testing for a bit, I realized that the game was detecting "fake" collisions. What I mean by this is that it was detecting a collisions not when the pixels of an object(s) are touching, but (after doing a bit of research) I found out that the boxes of the objects where colliding. So I had the game stop with a collision, and this is how it looks like: I tried outlining the two object's

Prevent collision or intersection of canvas objects

我是研究僧i 提交于 2019-12-20 06:26:38
问题 I'm drawing n rectangles on a canvas. The rectangles are draggable and scalable. I want to prevent them from overlapping or intersecting. The best case is, if they just snap to each other. I figured out to check the intersection. In my example I set the opacity of touching objects to 0.1. Coincidentally in my attempt to solve this problem, my objects cant be released when they touch another object. See http://jsfiddle.net/gcollect/jZw7P/ It's because of line 91, where the alert is not

Collision not working on iphone just ipad Xcode 6.1.1

試著忘記壹切 提交于 2019-12-20 05:53:27
问题 i need help finding out why my collision code is not working. this is the code when game has started. icon1.center = CGPointMake(60, -5000); icon1.hidden = NO; int randomizeicons = rand() % 4; switch (randomizeicons) { case 0: icon1.image = [UIImage imageNamed:@"BerryBlueberryIphone.png"]; break; case 1: icon1.image = [UIImage imageNamed:@"BerryRasberryIphone.png"]; break; case 2: icon1.image = [UIImage imageNamed:@"BerryCherryIphone.png"]; break; case 3: icon1.image = [UIImage imageNamed:@

ArrayList only detects collision of last added object

浪子不回头ぞ 提交于 2019-12-20 05:16:20
问题 I've run into a problem when detecting collision between the player and many of the same objects(in this case wall tiles). The problem is that my program only detects the collision when I'm in contact with the last added wall tile. This is written in java... I am using rectangles(their intersects method) to detect collision. Code samples: Update tiles: for (int i = 0; i < wallTileArr.size(); i++) { wallTile = wallTileArr.get(i); wallTile.update(p); if(wallTile.getBounds().intersects(Screen

Oval collision detection not working properly

。_饼干妹妹 提交于 2019-12-20 05:00:13
问题 So I'm trying to implement a test where a oval can connect with a circle, but it's not working. edist = (float) Math.sqrt( Math.pow((px + ((pwidth/2) )) - (bx + (bsize/2)), 2 ) + Math.pow(-((py + ((pwidth/2)) ) - (bx + (bsize/2))), 2 ) ); and here is the full code (requires Slick2D): import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.Color; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick

How to detect collision between objects in Pygame?

故事扮演 提交于 2019-12-20 04:15:21
问题 I'm making a sidescrolling game in Pygame, and if the fox sprite collides with the tree, it is supposed to print "COLLIDE". But it doesn't work. How can I fix this to detect collision between the fox and the tree? Here's the code: if foxsprite1 > xtree and foxsprite1 < xtree + treewidth or foxsprite1 + treewidth > xtree and foxsprite1 + treewidth < xtree + treewidth: print ("COLLIDE") xtree is the x coordinate of the tree, treewidth is the width of the tree, and foxsprite1 is the fox. 回答1:

Sprite mask collision problems in pygame

泄露秘密 提交于 2019-12-20 03:52:35
问题 I am attempting to create a racing game in pygame. I want it such that when the car goes off the track, it slows down. I have tried to do this by having another sprite that is an outline of the track and when the car touches that sprite, it slows down. This does not work and I don't know why. Is there a better way to do this? Img is the car image Back is the racetrack BackHit is the outline I receive this error code: Traceback (most recent call last): File "C:\Users\Daniella\Desktop\Python

Pygame collision detect with object and rect

ε祈祈猫儿з 提交于 2019-12-20 02:52:33
问题 Yep, I'm asking another question about this program :D Anyway, I currently a program that creates two lines on the screen with a gap in between them that can scroll. From here, I obviously need to see if the two objects are colliding. Since I only have one sprite and one rectangle I thought it was slightly pointless and overkill to make two classes for them. However, I can only find tutorials relating to classes which I obviously don't need. So, my question really is: Is it possible to test