Hi I am creating a game in which the aim is to guide a red dot (the aeroplane) to a runway dodging items along the way!In the Game you can control the dot using the keys W,A,S,D however i need to make it switch to a different form if you hit the top of a square (the square being the object you have to dodge) Please help PS:Doing a command Like
If Circle1.Location = 17,198 does not work because it says that the location is not static!(it actually says something a lot more complicated but that is simpler)neither does the Command
If Circle1.Location = Square1.Location
simply if you are ineterested it is not actually square1 and circle1 they have different name
You don't specify the language, but it sounds like you need to look up hit testing. If you're using .Net, you can just use System.Drawing.Rectangle.IntersectsWith(). If you need your circle to have a hit-circle and not a hit-box, then you need to do something different. Keep track of the middle of your circle, and expand your square's hit box in all directions by the radius of the circle. If the center of the circle is in the expanded hit box, then you have a collision. That works well enough unless your circle is at the corner of one of the squares.
I am using visual basic and that does not really make sense (i am quite new to this)
to help lets say the circle is called "circle1" and the rectangle is called "rectangle1" what would the code be that i would have to type in
Assuming the circle is of type System.Drawing.Rectangle, then the lazy method would look like: If circle1.IntersectsWith(rectangle1) Then 'The circle's hitbox hit the rectangle. Respond appropriately End If
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |