05-04-2007, 06:18 AM
For some reason, my computer doesn't recognize user input when I am blitting...Any suggestions(detailed stuff is below)...
First off, this involves 2 projects. The first project has a form with 4 lines drawn on it. It also has a Label. The code for it is this
It simply displays which key you pressed and then displays a line in that direction.
The next project involves Blitting. I have 2 pic boxes. One has a 32 x 32 image in it of a sprite. I blit this onto the other picbox and try to get input from the user. Using almost the exact same code as before, I try to get key input. But, it doesn't work at all...
The project also has a timer on it.
First off, this involves 2 projects. The first project has a form with 4 lines drawn on it. It also has a Label. The code for it is this
Code:
Private Sub Block()
Line1.Visible = False
Line2.Visible = False
Line3.Visible = False
Line4.Visible = False
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
Label1.Caption = "Right"
Block
Line4.Visible = True
Case vbKeyLeft
Label1.Caption = "Left"
Block
Line1.Visible = True
Case vbKeyUp
Label1.Caption = "Up"
Block
Line3.Visible = True
Case vbKeyDown
Label1.Caption = "Down"
Block
Line2.Visible = True
End Select
End Sub
Private Sub Form_Load()
Block
End Sub
The next project involves Blitting. I have 2 pic boxes. One has a 32 x 32 image in it of a sprite. I blit this onto the other picbox and try to get input from the user. Using almost the exact same code as before, I try to get key input. But, it doesn't work at all...
The project also has a timer on it.
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
Dim SX As Integer
Dim SY As Integer
Private Sub BlitStan(ByVal X As Long, ByVal Y As Long)
BitBlt picMain.hDC, 32 * SX, 32 * SY, 32, 32, picStan.hDC, 0, 0, vbSrcPaint
End Sub
Private Sub Form_Load()
SX = 0
SY = 0
BlitStan SX, SY
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
SX = SX + 1
Case vbKeyLeft
SX = SX - 1
Case vbKeyUp
SY = SY - 1
Case vbKeyDown
SY = SY + 1
End Select
End Sub
Private Sub timMain_Timer()
picMain.Cls
BlitStan SX, SY
picMain.Refresh
End Sub