fguihen Posted October 18, 2004 Posted October 18, 2004 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. Quote
Leaders Iceplug Posted October 19, 2004 Leaders Posted October 19, 2004 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. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
fguihen Posted October 19, 2004 Author Posted October 19, 2004 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 Quote
ThePentiumGuy Posted October 19, 2004 Posted October 19, 2004 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 Quote 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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.