collision-detection

How do I create collision detections for my bouncing balls?

I have coded an animation (in python) for three beach balls to bounce around a screen. I now wish to have them all collide and be able to bounce off each other. I would really appreciate any help that can be offered. import pygame import random import sys class Ball: def __init__(self,X,Y): self.velocity = [1,1] s...

How do I reverse the direction that my rectangles travel?

I am very new at programming as it was only just introduced into my school as a subject and I need some help. I have been given the task to have an animation of three balls (rectangle images) bouncing around the screen and off each other. I have the three balls and the bouncing of the walls all down good, but I don't know how to have the...

Per-pixel collision problem in C#

I am writing a small 2d game engine in C# for my own purposes, and it works fine except for the sprite collision detection. I've decided to make it a per-pixel detection (easiest for me to implement), but it is not working the way it's supposed to. The code detects a collision long before it happens. I've examined every component of the ...

WPF: Collision Detection between 2 ModelVisual3Ds

Hi, I would like to know when a ModelVisual3D has overlapped another ModelVisual3D (I am uncertain as if they are in the same Viewport3D or not). The models are in XAML form. I have searched and searched for a solution without success. ANY help would be appreciated. Thanks Q PS I am working with VB.NET - but will accept C# code. Th...

Pygame - Different sided collision question!

Hi there everyone! I'm making a Pygame of, basically, "Breakout". I'm using collisions, and want a simple way to have different bounce effects of the different sides of one rectangle. What I currently have for the ball-to-bat collision is this: "dot" = ball; "bat" = bat; so you all understand. if dot.rect.colliderect(bat.rect):<br> dot...

Tiled movment

heres what Im working with now if (osl_keys->held.down) { sprite_position = DOWN; SpriteAnimate(); sceKernelDelayThread(20000); sprite->y += 16; SpriteAnimate(); sceKernelDelayThread(20000); sprite->y += 16; } if (osl_keys->held.up) { sprite_position = UP; SpriteAnimate(); sceKernelDelayThread(20000); sprite->y -= 16; SpriteAnimate(); s...

Fast Collision Detection for Circle Insertion into 2D Plane

Hello all. I know there are lots of posts about collision detection generally for sprites moving about a 2D plane, but my question is slightly different. I'm inserting circles into a 2D plane. The circles have variable radii. I'm trying to optimize my method of finding a random position within the plane where I can insert a new circl...

Basic pathfinding with obstacle avoidance in a continuous 2D space

I'm writing a simulation in which a creature object should be able to move towards some other arbitrary object in the environment, sliding around obstacles rather than doing any intelligent pathfinding. I'm not trying to have it plan a path -- just to move in one general direction, and bounce around obstacles. It's a 2D environment (ove...

Ball to Ball Collision - Gains significant velocity upon collision

I implemented the code from the question "Ball to Ball Collision - Detection and Handling" in Objective-C. However, whenever the balls collide at an angle their velocity increases dramatically. All of the vector math is done using cocos2d-iphone, with the header CGPointExtension.h. What is the cause of this undesired acceleration? The f...

How to subdivide a 2d game world for better collision detection

I'm developing a game which features a sizeable square 2d playing area. The gaming area is tileless with bounded sides (no wrapping around). I am trying to figure out how I can best divide up this world to increase the performance of collision detection. Rather than checking each entity for collision with all other entities I want to onl...

Should games rely on frame rate only?

Hello, I would like your suggestion about this problem... To make it simple, I'll consider only the x axis. Image an object in position 10, and its width also 10 units, which is moving forward 100 units per second, and due to low frame, on each update it should move 80 units. After the first update is called, its position is now 90 an...

XNA collision detection

I have a ball moving inside a cube, and I detect when it goes outside of the cube (with a bounding sphere and a bounding box). Now I would like to detect from which side the ball goes out. Then I could redirect the ball in the correct direction. How can I do this with the ball's “world” matrix? Should I keep track of the ball's coordina...

Simple 2d physics tutorial for terrain collision detection

Hi, I am looking for a tutorial which will show me how to do simple 2d physics like the ones in this (http://www.teagames.com/games/tgmotocross/play.php). The part that I am most interested in is how the collision detection is done between the character / player and the terrain, as well as how to store / generate the terrain. The langua...

Circle line collision detection

I have a line from A to B and a circle positioned at C with the radius R. This is in two dimensions. Which is a good algorithm to use to check whether the line intersects the circle? And at what coordinate along the circles edge it occurred? ...

Looking for tutorials/examples for educating myself on per-poly 3D collision

I've been looking for a tutorial on 3D per-vertex collision systems (using C# and XNA, since I have that readily available), but have only been able to put together bits and pieces. I have a pretty good understanding at this point, but there's one rather large, glaring hole in my understanding. Basically, my problem comes down to: how d...

Continuous collision detection between two moving tetrahedra

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 t...

How did older games do collision detection with walls, floors and ceilings?

I have been reading about collision detection in games on stackoverflow and other sites. A lot of them talk about BSPs, bounding elipses, integration etc. However, on the NES, they managed to do floor and wall collision detection in games and I find it hard to believe that they did many calculations to detect wall collisions. I guess ...

collision detection

Can any one help me in adding collision detection between the object and camera. I am Using flex SDK and Sandy 3D library. Models are imported from 3DS Max. I heard sandy does not directly support collision classes. ...

how can i get UIImages to stack on top of each other with xcode

im making a game kind of like tetris but i cannot figure out how to get the blocks to stack on top of each other. this is the code im using to try and get the to have collision. if (CGRectIntersectsRect(shapeView.frame,shape2View.frame)) { } but it doesnt work. this is the shapeView and shape2View code UIImageView *shapeView = [[UI...

UIImageView collision

HI I have 10 imageviews moving around on my screen. when any 2 images overlap or collide i need to handle the collision. i cannot use CGRectIntersectsRect(image1.frame, image2.frame) as i wont know at run time which 2 images out of 10 collided. i need to know which images participated in the collision. Based on this i should write som...