Tile Map in visual basic
Posted on 2003-03-15
I am confused with an answer I recieved I am trying to just get an example of a Window Moded VB map that I can scroll around and it still be decent. I tried example below but cant get it to draw right it ends up drawing part of the form and willl not let me scroll to left and will not draw into map picture box only the back buffer one.
The Picture Boxes are all set to scalemode vbPixel.
The Backbuffer and Source are set to AutoRedraw.
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByBal 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
Public Sub RefreshMap()
'picSrc = Invisible Picture Box containing whole map
'picBack = Invisible Picture Box for back buffer and work.
'picDest = Picture Box for displaying to user.
Dim picSrc As PictureBox
Dim picBack As PictureBox
Dim picDest As PictureBox
Dim StartX As Long
Dim StartY As Long
Set picSrc = MainForm.pbSource
Set picBack = MainForm.pbBack
Set picDest = MainForm.pbMap
StartX = -MainForm.HScrollMap.Value
StartY = -MainForm.VScrollMap.Value
BitBlt picBack.hDC, 0, 0, _
picBack.ScaleWidth, picDest.ScaleHeight, _
picSrc.hDC, StartX, StartY, vbSrcCopy
'Do other things to picBack here like draw
'on map text messages, sprites, etc.
BitBlt picDest.hDC, 0, 0, _
picDest.ScaleHeight, picDest.ScaleWidth, _
picDest.hDC, 0, 0, vbSrcCopy