Be a Supporter!

Vb6 Directdraw Blt Collision Detec.

  • 638 Views
  • 6 Replies
New Topic Respond to this Topic
mrnugger
mrnugger
  • Member since: Aug. 8, 2005
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Vb6 Directdraw Blt Collision Detec. 2005-08-08 14:32:41 Reply

Alright, i've recently been learning DirectDraw7 in Visual basic 6, and I've got a simple Alien Invaders type game going, I got the enemies, bullets, and player processed. Now, I've met yet anotehr problem, I don't kow how to do rectangular collision detection to check if the Ship.RECT meets Enemy.RECT or Bullet.RECT so on and so forth.
If someone knows how to do this, I would greatly appreciate your help!

Ravens-Grin
Ravens-Grin
  • Member since: Jun. 3, 2003
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 14:35:04 Reply

Just check to see if one of the coordinates of one rectangle is in the other rectangle.

mrnugger
mrnugger
  • Member since: Aug. 8, 2005
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 14:37:43 Reply

Could you post an example code please?
Cause if I check the current X position on the ship to the CurrentX position of the enemie, it would just check for one pixel of space, which would be a shit collision system :|.

LordAba
LordAba
  • Member since: Nov. 2, 2000
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 14:57:24 Reply

At 8/8/05 02:37 PM, mrnugger wrote: Could you post an example code please?
Cause if I check the current X position on the ship to the CurrentX position of the enemie, it would just check for one pixel of space, which would be a shit collision system :|.

if(ship.x + ship.width =< enemy.x + enemy.width and ship.x >= enemy.x) then
'It's in range of the x position
if(ship.y + ship.width =< enemy.y + enemy.width and ship.y >= enemy.y) then
'In range of the y position HIT
endif
endif

Now I forgot how the y position is handled in VB, so you may need to change some stuff around.


What may man within him hide, though angel on the outward side.

BBS Signature
mrnugger
mrnugger
  • Member since: Aug. 8, 2005
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 15:15:59 Reply

Hehe, it worked, danke!

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 15:16:28 Reply

be sure to use the FastBlt function if you're not featuring any transparency or flip/rotate effects.


"no sound in ass"

mrnugger
mrnugger
  • Member since: Aug. 8, 2005
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Vb6 Directdraw Blt Collision Detec. 2005-08-08 15:48:00 Reply

Nah, I hate fastblt, I use Blt :D. ( I have transparency effects)