Collision detection in Visual Basic, has anyone here achieved this?

Started by
8 comments, last by Apollo 24 years, 5 months ago
Depending on your purpose of programming I know two ways. Either you test collision coordinates (assuming it's 2D graphics) on a per pixel basis (mostly really slow in real time) or a rectangle collision test.

Ex.

1. Setup a scene with two bitmaps and keep track of their rectangles.

2. Check if the two rectangles intercepts eachother.

3. Perform action if they do

[This message has been edited by Spiff (edited November 14, 1999).]

============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Advertisement
What I honestly, truly need to know, is how I can prevent my character from entering certain regions of the form. Can this be done? If so, how?

I'm, once again, trying to make a game similar to Zelda 3. I need to do the same thing done in that game, you can walk anywhere except on bricks, rocks, enemies, and the like. Does anyone know how to do this? What conditions would I have to check for?

I guess what we need to know from you is, how do you store the player's location and the map? If you store it as tiles, then simply marking tiles that the player should not be able to walk on should suffice. Otherwise, if the locations are in true X and Y coordinates, then you need to pursue collision detection.

- Splat

Well I'm using the image's left, and top properties for storing it's position.

Tell me though, how can I do tile map storage? Is it better than Left and Top properties? Are there any drawbacks?

Any help is appreciated.

Well, assuming you are making a game that has a map larger than the size of the screen, and you can do with tile graphics and not one big bitmap, then yes, a tile system would work nice.

The trick to, at least in this case, is finding out what is and is not "walkable on". How do you / will you store this information. Obviously, the game needs to know this in order to restrict the players movement.

With a tile system, it is very simple. Before you move the player, check to see if the tile he is moving to is marked impassable. If it is, then don't move him!

On a side note, in addition to knowing the player's Top and Left you will need to keep track of the position of the upper-left corner of the displayed area relative to the upper-left of the world / level map. With those two bits you can know where any object is in the map.

- Splat

Ok, is the tile system an advanced feature, like and API, or is it just a fancy name for checking if the user is allowed to enter a square?

And how would I know if the square/tile he is attempting to enter is impasssible, is it something predefined? Or what?

Not to be snipy, but judging by the messages in this thread, I don't think that a Zelda type game is what you should start off with. A tile map is a semi-intermediate project which I suggest you read a lot of tutors on. The perfect game for you, I believe, would be a space invaders clone. then build up from there.

Would everyone agree on this?

William Reiach - Human Extrodinaire

Marlene and Me


To me it seems like you don't even use BitBlt for graphics drawing and believe me,
I've been there, and in my opinion, Windows GDI is really bad for games programming use and I suggest you start reading DirectX tutorials, there are alot of them and it isn't that hard to create a 2D scrolling game.

Wish you all luck
_____
Spiff

============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Man, I've been trying for 2 days now, and I can only get it to work slightly well. I'm trying to make a game similar to Zelda 3, and I need to make it so the user can only walk in certain areas, and not on pots and stuff like that.

Can anyone give me a method that has worked well for them? Or some sample code...ANYTHING.

"Apollo is the kind of guy who can...no, will create a video game in Visual Basic."
Yes I am using bitblt, I've just never created a game before. It's always difficult when you start something new.

I think I'll just keep doing what I'm doing. It's only a little hobby for me anyway, I'm not going into this professionally. Not yet anyway.

Trust me, I've got animation for my character while he walks, and he is confined to move within a certain area.

If I need more help, I'll be back.

Kay!

This topic is closed to new replies.

Advertisement