VB Code:
Private Sub form_load()
ShipX = picBackBuffer.ScaleWidth / 2 - Picture1.ScaleWidth / 2
ShipY = picBackBuffer.ScaleHeight - 24
End Sub
Private Sub Timer1_Timer()
Timer = Timer + 1
If Timer = 6 Then
Call GetKeyDown(keyRight, ShipSpeedX, 2)
Call GetKeyDown(keyLeft, ShipSpeedX, -2)
Call GetKeyDown(keyDown, ShipSpeedY, 2)
Call GetKeyDown(keyUp, ShipSpeedY, -2)
Call GetNoKeyDown
Call DrawEverything
End If
If Timer > 6 Then Timer = 0
Label1.Caption = Timer
End Sub
Private Function DrawEverything()
BitBlt picBackBuffer.hDC, ShipX + ShipSpeedX, ShipY + ShipSpeedY, _
Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcCopy
BitBlt picFrontBuffer.hDC, 0, 0, picBackBuffer.ScaleWidth, _
picBackBuffer.ScaleHeight, picBackBuffer.hDC, 0, 0, vbSrcCopy
End Function
Private Function GetKeyDown(Key, Action, Amount)
If GetAsyncKeyState(Key) = 1 Then
Action = Amount
End If
End Function
Private Function GetNoKeyDown()
If GetAsyncKeyState(keyRight) = 0 And GetAsyncKeyState(keyLeft) = 0 Then
ShipSpeedX = 0
End If
If GetAsyncKeyState(keyUp) = 0 And GetAsyncKeyState(keyDown) = 0 Then
ShipSpeedY = 0
End If
End Function
I know there is nothing wrong with the bitblt stuf, because it works when I put it in the form load event. The real reason I made this is ust to test out moving things around with that API function GetAsyncKeyState.