Question Setting up a perimiter around an image

danarchy

Member
Joined
Oct 19, 2010
Messages
9
Programming Experience
1-3
Basically, im creating a basic pacman/snake game, ive got the movements set up and all my bits and bobs but im having trouble setting up a perimiter around the "food" image to detect if the pacman is within it to allow him to "eat" the food.

The pic below explains what i mean...
View attachment example.bmp


Ive tried creating a box around the image which is +10, -10 for each edge on the x and y axis but it wont let me do it and is showing the following error.

View attachment example2.bmp

any help would be greatly apreciated!

Thanks
 
Location is a Point, which is a combined x/y coordinate. You can't compare that to the leftedge (x) coordinate.

This is easier done using rectangles. Rectangle has a IntersectsWith method that you can use to see if the pacman rectangle intersects with the food rectangle.
 

Latest posts

Back
Top