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:
As you can see, when you press up, the sprite moves up, etc.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
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.




Reply With Quote