Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Collision Detection help PLZ!!!

This topic is 6199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry for so many questions but I am making a game and here is how I did it, First I made 2 types like this: Public Type aMan x As Integer y As Integer End Type Public Type aWall x As Integer y As Integer End Type public Man as aMan public Wall as aWall Then I loaded in my pictures and displayed them on the screen with the PaintPicture method. What I want to do now is detect collsion between my person and the wall if I do this : If man.x <= wall.x then man.x = man.x - 200 it kind of works but even when I go around the wall it stops me. Anybody know a way I can detect just the wall and not the whole row? Thanks a lot.

Share this post

Link to post
Share on other sites
This looks like you''re doing it in VB or QB, so that''s what I''ll be responding in...
First, add two things to your man and your wall: a width and a height that describes their size.

IF ( man.x + man.width >= wall.x AND_
man.x <= wall.x + wall.width AND_
man.y + man.height >= wall.y AND_
man.y <= wall.y + wall.height )
collision = true;

( the _ in the code denotes a continuation to the next line...
if you''re doing this in QB, you''ll have to put it all on
the same line, but I THINK that will work in VB ).

This will test the "bounding boxes" to see if they collide.
Once you know if there''s a collision, you can determine which direction the collision is taking place in and prevent the character from moving any further in that direction.
It may not be the best way, but it should work. :-D


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!