i have a bot moving between red rectangles. when the bot gets near a rectangle, i want him to alter his position to avoid the red. how could i accomplish this , using c#? thanks for reading my post.
You will have to draw the drawings in a bitmap, because you cannot check for red on a form (unless you use API). After the bot moves, use your bitmaps .GetPixel to check if it hits red. If it does, move it back in the opposite direction that it just moved.
no , the bot is supposed to work by itself to avoid objects . i dont think color detection is the way though. if i can find a way to make the bot start turning left or right when an object(wall or other bot) comes within my bots field of vision ( maby the width of the bot*3 in front of the bot). hope this is a little clearer
Ive tried Color collision detection..
What you gotta do is use the GetPixel command to get the color of your pixel and then calculate collision based on that.. my experience is, its very slow.
Hmm.. I know im stating an obvious, but youd have to develop an algorithm for what direction the bot moves in after he hits something.
You can modify it so that it checks for collision constantly, but youd have to develop an algorithm to tell the bot where to move after it collides - obviously going in the opposite direction, but youd want to add a bit of "Randomness" and allow for more directions (still going the other way, just not directly opposite every time)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.