Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
  • Leaders
Posted

Are you controlling the bot with the keyboard?

 

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 bitmap's .GetPixel to check if it hits red. If it does, move it back in the opposite direction that it just moved. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
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
Posted

I've 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 i'm stating an obvious, but you'd have to develop an algorithm for what direction the bot moves in after he hits something.

 

View my tutorial on collision detection between square objects, it speaks about proximity algorithms and bounding boxes, perhaps you can modify that a little bit for your program:

http://www.vbprogramming.8k.com/tutorials/CollisionDetection.htm

 

You can modify it so that it checks for collision constantly, but you'd have to develop an algorithm to tell the bot where to move after it collides - obviously going in the opposite direction, but you'd want to add a bit of "Randomness" and allow for more directions (still going the other way, just not directly opposite every time)

 

-The Pentium Guy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...