|
-
Apr 30th, 2005, 06:25 AM
#1
Thread Starter
Junior Member
Keydown problem - Help!!
I have beenn pulling my hair out all night about this. Ok. I'm making a PacMan game using BitBlt. Here's my code for the form thats the problem:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
MLeft
Case vbKeyRight
MRight
Case vbKeyUp
MUp
Case vbKeyDown
MDown
End Select
End Sub
Sub Render()
'blit it on the buffer, mask first
BitBlt BackBuffer.hDC, PacMan2.x, PacMan2.y, 56, 58, SpriteMask.hDC, 0, 0, vbMergePaint
BitBlt BackBuffer.hDC, PacMan2.x, PacMan2.y, 56, 58, Sprite.hDC, 0, 0, vbSrcAnd
End Sub
Private Sub Form_Load()
'Show the form
Show
Draw
MainLoop
End Sub
Sub Draw()
'Set where the pacman starts
PacMan2.x = 40
PacMan2.y = 40
End Sub
Sub MainLoop()
Do
DoEvents
BackBuffer.Cls
Render
Loop
End Sub
Sub MDown()
PacMan2.y = PacMan2.y + 15
End Sub
Sub MUp()
PacMan2.y = PacMan2.y - 15
End Sub
Sub MLeft()
PacMan2.x = PacMan2.x + 15
End Sub
Sub MRight()
PacMan2.x = PacMan2.x - 15
End Sub
As you can see, when you press up, the sprite moves up, etc.
HOWEVER, nothing happens when I do. Even if I type the wrong thing, for example: MUp22 (which is not a Sub or anything), I dont get an error message, meaning that the program isnt responding to the key at all, none of them actually.
What am i doing wrong? thanks in advance.
-
Apr 30th, 2005, 06:43 AM
#2
Re: Keydown problem - Help!!
Is the KeyPreview property of the Form set to True?
-
May 3rd, 2005, 06:13 PM
#3
Hyperactive Member
Re: Keydown problem - Help!!
Also, I don't see you refreshing the form either
-
May 3rd, 2005, 06:29 PM
#4
Re: Keydown problem - Help!!
 Originally Posted by Venom555
Also, I don't see you refreshing the form either
Well the code he posted is not using any continious loop or anything so the Form will refresh itself since most of the time none of the code will run at all.
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
|