 |
|

03-23-2004, 04:41 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
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*
|
__________________
"Those Who Cant Buy Software.........Make It"
|

03-23-2004, 04:57 PM
|
|
Junior Contributor
|
|
Join Date: Nov 2003
Posts: 373
|
|
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)
|
|

03-23-2004, 05:06 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
|
|
Can you give me a quick sample please?
|
__________________
"Those Who Cant Buy Software.........Make It"
|

03-23-2004, 05:11 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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?
|
|

03-23-2004, 05:14 PM
|
|
Junior Contributor
|
|
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
|
|
What the heck is 'Spriteman?'
|
|

03-23-2004, 05:22 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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
|
|

03-23-2004, 05:32 PM
|
|
Regular
|
|
Join Date: Mar 2004
Posts: 95
|
|
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)
|
|

03-23-2004, 05:56 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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.
|
|

03-23-2004, 05:58 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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.
|
|

03-23-2004, 06:00 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
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"
|

03-23-2004, 06:03 PM
|
|
Regular
|
|
Join Date: Mar 2004
Posts: 95
|
|
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.
|
|

03-23-2004, 06:03 PM
|
|
Junior Contributor
|
|
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
|
|
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!
|
|

03-23-2004, 06:09 PM
|
|
Junior Contributor
|
|
Join Date: Oct 2003
Location: Joplin, Mo
Posts: 248
|
|
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...
|
|

03-23-2004, 06:11 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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.
|
|

03-23-2004, 06:19 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
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"
|

03-23-2004, 06:28 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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
|
|

03-23-2004, 06:31 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
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"
|

03-23-2004, 06:43 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
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.
|
|

03-23-2004, 06:49 PM
|
|
Centurion
|
|
Join Date: Feb 2004
Location: Bristol
Posts: 161
|
|
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"
|

03-23-2004, 06:49 PM
|
|
Regular
|
|
Join Date: Mar 2004
Posts: 95
|
|
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.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
| |
|