|
-
Apr 16th, 2002, 11:45 AM
#1
Thread Starter
Member
Stumped, PLEASE HELP!
K I'm rather new to VB game programming. Not to game programming in general, but in VB. So this is all wierd to me.
Here's the problem:
I have 2 main picture objects, picBackBuffer and picFrontBuffer. Then there is Picture1, with is simply gonna be bitblitted to the main pictures. The process I have come up with, whether it is efficient or not it is good enough for the class I am taking, is simple: BitBlt everything to the picBackBuffer, then bitblt the backbuffer to the frontbuffer. VERY EASY STUFF. The problem is in the loops, I try using a timer to do this but it's being a 8!7<|-|. I have the bitbltting in a "DrawEverything" function, and I check for arrow keys being down (or not down) through 2 other functions. The timer is enabled at start, and its interval is 1. ITS SOO SIMPLE BUT I DON'T SEE WHY IT ISNT WORKING!! Here is the bulk of the problem:
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.
I could REALLY use someones help here, it seems like it is a very simple problem to fix, some little thing I don't know about VB that I'm doing wrong or something. Thanx!
(PS hehe I don't think I ever actually gave the PROBLEM -- Nothing is drawn, or bitbltted, when I use the timer. It works when I put it in Form_load, but then it only draws once, defeating the purpose of the timer.)
Last edited by Quadamage; Apr 16th, 2002 at 11:54 AM.
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
|