|
-
Jan 24th, 2000, 12:42 PM
#1
New Member
I'm making a hunting game in VB6, and I'm trying to figure out how to implement BitBlt into it.
I have some sample source that I found from vb-world, but I need to figure out how to make it so that I can use a timer to move the mask/picsource to a new destination every second or so. Here's what I have for code, please somebody help:
[Form1 code]
Dim xdest As Long
Dim ydest As Long
Sub refreshscreen()
Form1.Cls
Call BitBlt(picbuf.hDC, 0, 0, 214, 161, picback.hDC, 0, 0, SRCCOPY)
Call BitBlt(picbuf.hDC, xdest, ydest, 32, 32, picMask.hDC, 0, 0, SRCAND)
Call BitBlt(picbuf.hDC, xdest, ydest, 32, 32, picsource.hDC, 0, 0, SRCINVERT)
Call BitBlt(Form1.hDC, 0, 0, 214, 161, picbuf.hDC, 0, 0, SRCCOPY)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
xdest = xdest + 5
refreshscreen
Case vbKeyLeft
xdest = xdest - 5
refreshscreen
Case vbKeyUp
ydest = ydest - 5
refreshscreen
Case vbKeyDown
ydest = ydest + 5
refreshscreen
End Select
If xdest < 10 Then xdest = 10
If xdest > 170 Then xdest = 170
If ydest < 10 Then ydest = 10
If ydest > 120 Then ydest = 120
End Sub
Private Sub Form_Load()
Dim leftd, topd
leftd = Int(Rnd * picback.Width)
topd = Int(Rnd * picback.Height)
xdest = 100
ydest = 100
refreshscreen
End Sub
Private Sub picsource_Click()
End Sub
Private Sub Timer1_Timer()
picbuf.Left = leftd
picsource.Left = picbuf.Left
picbuf.Top = topd
picsource.Top = picbuf.Top
End Sub
[Module code]
Public 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
Global Const White = 16777215
Global Const SRCAND = &H8800C6
Global Const SRCCOPY = &HCC0020
Global Const SRCINVERT = &H660046
Global Const srcpaint = vbSrcPaint
What am I doing wrong? I'm trying to move the picture to a new spot every second, and it doesn't move. (I also have the keyboard input, where it moves using the arrow keys, but how do I get it to work like I want it to?)
Thanks for any help I get.
-BLiNDPiG
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
|