iNET Interactive - Online Advertising Agency
          
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > Bitblt Collision


Reply
 
Thread Tools Display Modes
  #1  
Old 03-23-2004, 04:41 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default Bitblt Collision

How do you do it with bitblt i have did it with picture boxs but i dunno how you do it with bitblt any help please

p.s yes i have checked out the tutorial it was all using pictures box's witch is not what i need.

(See Attached)

*Newist Code*
Attached Files
File Type: zip D And Coin.zip (97.7 KB, 6 views)
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #2  
Old 03-23-2004, 04:57 PM
CAlex CAlex is offline
Junior Contributor
 
Join Date: Nov 2003
Posts: 373
Default

Why don't you use SpriteMan?
You must use it to check collision - bitblt does nothing except drawing the picture - bitblt doesn't have .Left and .Top.
(wow the background of the forum just changed to the milky colour)
Reply With Quote
  #3  
Old 03-23-2004, 05:06 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default

Can you give me a quick sample please?
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #4  
Old 03-23-2004, 05:11 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

Bitblt collision is different then picture box collision but not by much. For bitblt just use the same function but use variables. What way did you do it with picture boxes?
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #5  
Old 03-23-2004, 05:14 PM
CrashDaddy CrashDaddy is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
Default

What the heck is 'Spriteman?'
Reply With Quote
  #6  
Old 03-23-2004, 05:22 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

Here's a quick example of the funtion but just use varaibles from the bitblt to check for collision:

Code:
Public Function Contact(E1 As Control, E2 As Control) As Boolean
Contact = False
If E1.Left + E1.Width + 4 >= E2.Left And E1.Left <= E2.Left + E2.Width And E1.Top + E1.Height >= E2.Top And E1.Top - 20 <= E2.Top + E2.Height Then
    Contact = True
End If
End Function
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #7  
Old 03-23-2004, 05:32 PM
Abusedpanda Abusedpanda is offline
Regular
 
Join Date: Mar 2004
Posts: 95
Default

Quote:
Originally Posted by Bljashinsky
Here's a quick example of the funtion but just use varaibles from the bitblt to check for collision:

Code:
Public Function Contact(E1 As Control, E2 As Control) As Boolean
Contact = False
If E1.Left + E1.Width + 4 >= E2.Left And E1.Left <= E2.Left + E2.Width And E1.Top + E1.Height >= E2.Top And E1.Top - 20 <= E2.Top + E2.Height Then
    Contact = True
End If
End Function
Just curious, what are E1 and E2? (This looks like collision detection with pictureboxes, or images, not bitblt, unless thats what your explaining)
Reply With Quote
  #8  
Old 03-23-2004, 05:56 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

Yeah, that's from picture boxes but what i am saying is use the same idea but use variables that you are using to bitblt your image.
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #9  
Old 03-23-2004, 05:58 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

I forgot to ask if you are using tiles because I have seen people blt a non-collision picture on a collision tile. CrashDaddy's collision detection was very good so if you have check out that example.
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #10  
Old 03-23-2004, 06:00 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default

I have the same problem as befor i know how to do collision but i cant put my bitblted image into one verible like e1 i dunon how im really stuck on it cos you got the mask and the char how do you do it?
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #11  
Old 03-23-2004, 06:03 PM
Abusedpanda Abusedpanda is offline
Regular
 
Join Date: Mar 2004
Posts: 95
Default

Quote:
Originally Posted by Giglimesh
I have the same problem as befor i know how to do collision but i cant put my bitblted image into one verible like e1 i dunon how im really stuck on it cos you got the mask and the char how do you do it?
Its not so much putting the image into a variable as storing the position of where your character is in a variable/variables. And then you store the position of walls and everything and check to see if those (the positions) collide.
Reply With Quote
  #12  
Old 03-23-2004, 06:03 PM
CrashDaddy CrashDaddy is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
Default

I just load a map as a graphic and have a corresponding array that shows the non-walkable tiles and I check them before moving the sprite.

And I am starting to learn from painful experience that it is the wrong way to do it. If I was going to do it right, I would have kept the entire tilesets in the program and just drawn the maps off of them at runtime with data from a text file instead of making each and every map and a text file to go with it for non-walkable tiles!
Reply With Quote
  #13  
Old 03-23-2004, 06:09 PM
CrashDaddy CrashDaddy is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
Default

Here's a little sample:

This is a map:
000000000000000000
000000000000000000
000000000000000000
000000000000100000
000000000000100000
0000000x0000100000
000000000000100000
000000000000100000

That's an array that I load from a text file. I have two different tiles and I read through the array and bibtblt either tile 0 or tile 1 to the screen. When I run into that 'x' I bitblt the player.

Then if I'm going to move right, I check the next tile, and if it's a 0 I can move, but if it's a 1 then I can't. In this example I can move right four times, but if I try to move right again I can't because the next tile is a '1' tile (non-walkable)...

pcode:

user pressed right
add 24 to X and check to see what tile I would be in
here we have options
1 oh no! It's a non-walkable tile!!! ---> don't move and leave the X the way it was
2 Yay! It's a walkable tile!
Move the character to the right and wait for another keypress...
Reply With Quote
  #14  
Old 03-23-2004, 06:11 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

Ok, if you are not using tiles then you ahve to use your variables to check where stuff is. Use your left and top variables and then just use the same function I am using that I already put up. I am not sure what the best way to do collision detection is, that sounds like a question for an expert.
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #15  
Old 03-23-2004, 06:19 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default

As i have said befor i know how to do it i just dont know how to call up my bitbblted image so please stop posting how to do collision cos i know how to do that i need to know how to define my bitblt image
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #16  
Old 03-23-2004, 06:28 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

I am confused. Here's an example of how I do bitblt with variables:


Code:
'Bitblt Boat
BitBlt mainbackground.hDC, Boat.x, Boat.Y, 100, 100, picBoatMask.hDC, Boat.CurX, Boat.CurY, vbSrcAnd
BitBlt mainbackground.hDC, Boat.x, Boat.Y, 100, 100, picBoat.hDC, Boat.CurX, Boat.CurY, vbSrcPaint
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #17  
Old 03-23-2004, 06:31 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default

i Ok let em try and explane this better i dont mean like that what i mean is you know if you was doign collision with box's you would do like

if box.left < wall.left + wall.width

and so on blah blah blah its easy for the picture box cos your using the name i dunno what to put in the "box" bit my bitblted image im not very good at explaning stuff im sorry hopfuly you will understand now
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #18  
Old 03-23-2004, 06:43 PM
Bljashinsky's Avatar
Bljashinsky Bljashinsky is offline
Senior Contributor
 
Join Date: Nov 2003
Location: California
Posts: 1,016
Default

Ok, let me explain this. Switch the box.left with intleft or whatever your left variable is and do the same for the wall and the walls width.
__________________
Check out my website:
Reimagine Memories
Reply With Quote
  #19  
Old 03-23-2004, 06:49 PM
Giglimesh Giglimesh is offline
Centurion
 
Join Date: Feb 2004
Location: Bristol
Posts: 161
Default

This didnt work

Code:
If ILeft.Left + ILeft.Width + 4 >= x.Left And ILeft.Left <= x.Left + ILeft.Width And ITop.Top + y.Height >= y.Top And ITop.Top - 20 <= y.Top + y.Height Then
__________________
"Those Who Cant Buy Software.........Make It"
Reply With Quote
  #20  
Old 03-23-2004, 06:49 PM
Abusedpanda Abusedpanda is offline
Regular
 
Join Date: Mar 2004
Posts: 95
Default

Quote:
Originally Posted by Bljashinsky
Ok, let me explain this. Switch the box.left with intleft or whatever your left variable is and do the same for the wall and the walls width.
To further explain: When you Blit something you have to give coordinates to where the image goes, for instance, playerx and playery. WHen your doing collision detection instead of using box.left, use playerx, instead of box.top, playery. Hope that helps.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining IcePlug's Idea Collision Detection jefrey1983 Game Programming 4 01-26-2004 08:32 AM
BitBlt Tutorial Pino Tech Discussions 5 12-08-2003 04:02 PM
Bitblt animation?? SockBox Game Programming 5 08-30-2003 08:03 AM
collision detection with bitblt blursea Game Programming 3 08-23-2001 06:37 AM
Collision Detection with bitblt Spike Game Programming 2 08-21-2001 12:32 AM

Advertisement: