Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
I need to make a system that detects collision between two images in some control. Can anybody explain to me how to do that? Any tutorial?

Thanks in advance!
Posted
Comments
Zoltán Zörgő 18-Sep-13 17:26pm    
Please explain first what you mean by collisions between two images.
Sergey Alexandrovich Kryukov 18-Sep-13 17:53pm    
Most likely, this is game physics. Developers creates "envelopes" over the image, detect the moment when they intersect, all that stuff...
I tried to answer, please see.
But of course, too little information, so only a very general answer is possible.
—SA
[no name] 18-Sep-13 17:54pm    
I have 2 images.
First one ( not movable) : Black image 600x600 with vertical BLUE line in the middle from the top to the bottom.
Second one ( movable) : It can move through black image but i need to make that it can only move until it hits the blue line. So when it hits the blue line image should stop moving to the right side and stay on the left side of the blue line.

1 solution

This is called "game physics". You can get started to be acquainted with the topic if you read these articles and follow the links provided:
http://en.wikipedia.org/wiki/Game_physics[^],
http://en.wikipedia.org/wiki/Physics_engine#Collision_detection[^].

—SA
 
Share this answer
 
v2
Comments
[no name] 18-Sep-13 18:25pm    
Thanks!

I was trying to make something like this:

I am moving red image(R) throug black image(B) by drawing on new points x and y.
When red image(R) hit blue line on those points x and y i read pixel color and if pixel color is blue image(R) should stop moving.. But i am getting wrong reading of pixel color so i cant solve it...
Sergey Alexandrovich Kryukov 18-Sep-13 18:29pm    
You are just moving in wrong direction. The problem is simple: don't get pixel reading. Move the model of the motion/physics, not the images. And, based on the model, render images. Isn't it obvious? Then you can detect collision in mathematics, not in "reading".
—SA
[no name] 18-Sep-13 18:43pm    
Thanks, i will try to do on that way.. But first need to learn some game physics..
Sergey Alexandrovich Kryukov 18-Sep-13 19:01pm    
Good idea. Good luck...
—SA
[no name] 18-Sep-13 19:43pm    
Thanks..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900