|
-
Jan 28th, 2003, 05:47 PM
#1
Thread Starter
Addicted Member
PaintPicture
I have a tile map and a bunch of tiles, each with its own image box, meaning I have like 20 pictures. Now I want to have all the tiles in one picture and choose which tiles from that picture to draw. Hope this makes sense any help would be useful
-
Jan 29th, 2003, 06:13 PM
#2
Stuck in the 80s
So...what exactly do you need help with?
-
Jan 29th, 2003, 06:18 PM
#3
Thread Starter
Addicted Member
I have a tile map and it draws the pictures like this, see how i have two pictures, one for each tile.
Code:
Case Is = "A"
Picture1.PaintPicture imgshort.Picture, (X + 3) * 25, (Y + 3) * 25
Case Is = "B"
Picture1.PaintPicture imgtall.Picture, (X + 3) * 25, (Y + 3) * 25
well i want it to do this with just one picture that contains both tiles. how would I do this? make sense yet?
-
Jan 29th, 2003, 06:40 PM
#4
Stuck in the 80s
Originally posted by jeb2022
well i want it to do this with just one picture that contains both tiles. how would I do this? make sense yet?
Yeah, I gotcha. My suggestion would be to use BitBlt. It allows you to specify where on the tile picture you want to take the image from.
It's declaration is:
VB Code:
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
You can just throw that in the top of your form, or remove the keyword 'Private' and put it in a module.
Then to use it, just replace the PaintPictures with:
VB Code:
Case "A"
BitBlt Picture1.hdc, (x + 3) * 25, (y + 3) * 25, 25, 25, _
imgTiles.hdc, 0, 0, vbSrcCopy
Where Picture1.hdc is where you're painting to, the next two parameters are the x and y of where you're painting to, the two 25s are the width and height, respectively. imgTiles.hdc is the picture with all the tiles, and the two 0s are the x and y of where that tile starts on the tile picture.
So if it's the first tile, it'll be 0, 0. The second tile, it'll probably be 24, 0, if the tile are going across horizontally.
Do you follow?
Edit: Added BitBlt declaration.
-
Jan 29th, 2003, 06:53 PM
#5
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|