Click here to Skip to main content
15,890,845 members
Home / Discussions / C#
   

C#

 
AnswerRe: Parse CSV using RegularExpression Pin
OriginalGriff29-Jun-13 1:44
mveOriginalGriff29-Jun-13 1:44 
GeneralRe: Parse CSV using RegularExpression Pin
haha_c30-Jun-13 15:30
haha_c30-Jun-13 15:30 
GeneralRe: Parse CSV using RegularExpression Pin
OriginalGriff30-Jun-13 22:18
mveOriginalGriff30-Jun-13 22:18 
AnswerRe: Parse CSV using RegularExpression Pin
Mycroft Holmes30-Jun-13 22:09
professionalMycroft Holmes30-Jun-13 22:09 
Questiontransforming a MemoryStream instance into a string Pin
BillWoodruff28-Jun-13 22:27
professionalBillWoodruff28-Jun-13 22:27 
AnswerRe: transforming a MemoryStream instance into a string Pin
OriginalGriff28-Jun-13 22:36
mveOriginalGriff28-Jun-13 22:36 
GeneralRe: transforming a MemoryStream instance into a string Pin
BillWoodruff29-Jun-13 5:49
professionalBillWoodruff29-Jun-13 5:49 
GeneralRe: transforming a MemoryStream instance into a string Pin
OriginalGriff29-Jun-13 5:58
mveOriginalGriff29-Jun-13 5:58 
GeneralRe: transforming a MemoryStream instance into a string Pin
BillWoodruff29-Jun-13 16:41
professionalBillWoodruff29-Jun-13 16:41 
AnswerRe: transforming a MemoryStream instance into a string Pin
Alan N29-Jun-13 8:24
Alan N29-Jun-13 8:24 
GeneralRe: transforming a MemoryStream instance into a string Pin
BillWoodruff29-Jun-13 16:42
professionalBillWoodruff29-Jun-13 16:42 
AnswerRe: transforming a MemoryStream instance into a string Pin
jschell29-Jun-13 11:46
jschell29-Jun-13 11:46 
GeneralRe: transforming a MemoryStream instance into a string Pin
BillWoodruff29-Jun-13 16:59
professionalBillWoodruff29-Jun-13 16:59 
GeneralRe: transforming a MemoryStream instance into a string Pin
jschell1-Jul-13 8:06
jschell1-Jul-13 8:06 
QuestionHow to get cell values in devexpress gridcontrol via a function Pin
Member 253280028-Jun-13 18:37
Member 253280028-Jun-13 18:37 
AnswerRe: How to get cell values in devexpress gridcontrol via a function Pin
Richard MacCutchan28-Jun-13 23:16
mveRichard MacCutchan28-Jun-13 23:16 
GeneralRe: How to get cell values in devexpress gridcontrol via a function Pin
Member 253280030-Jun-13 15:29
Member 253280030-Jun-13 15:29 
GeneralRe: How to get cell values in devexpress gridcontrol via a function Pin
Member 253280030-Jun-13 18:03
Member 253280030-Jun-13 18:03 
GeneralRe: How to get cell values in devexpress gridcontrol via a function Pin
Richard MacCutchan30-Jun-13 21:19
mveRichard MacCutchan30-Jun-13 21:19 
QuestionGrid Based Games Pin
Midnight Ahri28-Jun-13 1:34
Midnight Ahri28-Jun-13 1:34 
AnswerRe: Grid Based Games Pin
Pete O'Hanlon28-Jun-13 2:22
mvePete O'Hanlon28-Jun-13 2:22 
GeneralRe: Grid Based Games Pin
Midnight Ahri28-Jun-13 6:23
Midnight Ahri28-Jun-13 6:23 
AnswerRe: Grid Based Games Pin
Emmanuel Medina28-Jun-13 9:03
professionalEmmanuel Medina28-Jun-13 9:03 
What you are looking for, as the above poster pointed out, is Collision Detection, you should be able to find plenty of sources on it, I will list a few:

Collision Detection[^] on wikipedia (theory)
Testing for Collisions[^] on MSDN, this is for (the now unsupported) XNA Framework
Pacman in C# (map & collision detection)[^] A question here in CodeProject
C# Game Programming for Teens[^] In this book you will follow the chapters to make a 2D Dungeon Crawler. Chapter 4 deals with collision detection

EDIT:

If you are using sprites (which I guess is the case) you have to check if the object's rectangle intersects with any other object's rectangle, take into account that the rectangle also counts the transparent pixels of your sprite. You could do your own way of checking for an intersection between two rectangles, but you can use the IntersectsWith[^] method.

If your object is non-player controlled, it most likely has a velocity, so you can predict the collision by calculating the coordinates for the next iteration and checking for intersections with those coordinates.

Example:

Player controlled object:
C#
public class PlayerObject
{
  public Point Location {get; set;}
  public Size ObjectSize (get; set;}
  public Rectangle Bounds {get; set;}

  public PlayerObject(Point loc, Size objSize)
  {
    Location = loc;
    ObjectSize = objSize;
    Bounds = new Rectangle(Location.X, Location.Y, Location.X + Size.Width, Location.Y + Size.Height);
  }

  //Collision detection
  public bool IsColliding(ref GameObject obj)
  {
    bool collides = Bounds.IntersectsWith(obj.Bounds);
    return collides;
  }
}

If you think you can do a thing or think you can't do a thing, you're right - Henry Ford

Emmanuel Medina Lopez

Question[RESOLVED] Regular Expressions Problem Pin
Sonhospa27-Jun-13 23:13
Sonhospa27-Jun-13 23:13 
AnswerRe: Regular Expressions Problem Pin
Eddy Vluggen28-Jun-13 1:53
professionalEddy Vluggen28-Jun-13 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.