Results 1 to 25 of 25

Thread: Stumped, PLEASE HELP!

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    I'll kick yo' @$$!!
    Posts
    44

    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:
    1. Private Sub form_load()
    2.   ShipX = picBackBuffer.ScaleWidth / 2 - Picture1.ScaleWidth / 2
    3.   ShipY = picBackBuffer.ScaleHeight - 24
    4. End Sub
    5. Private Sub Timer1_Timer()
    6.   Timer = Timer + 1
    7.   If Timer = 6 Then
    8.     Call GetKeyDown(keyRight, ShipSpeedX, 2)
    9.     Call GetKeyDown(keyLeft, ShipSpeedX, -2)
    10.     Call GetKeyDown(keyDown, ShipSpeedY, 2)
    11.     Call GetKeyDown(keyUp, ShipSpeedY, -2)
    12.     Call GetNoKeyDown
    13.     Call DrawEverything
    14.   End If
    15.   If Timer > 6 Then Timer = 0
    16.   Label1.Caption = Timer
    17. End Sub
    18.  
    19. Private Function DrawEverything()
    20.   BitBlt picBackBuffer.hDC, ShipX + ShipSpeedX, ShipY + ShipSpeedY, _
    21.     Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcCopy
    22.   BitBlt picFrontBuffer.hDC, 0, 0, picBackBuffer.ScaleWidth, _
    23.     picBackBuffer.ScaleHeight, picBackBuffer.hDC, 0, 0, vbSrcCopy
    24. End Function
    25. Private Function GetKeyDown(Key, Action, Amount)
    26.   If GetAsyncKeyState(Key) = 1 Then
    27.     Action = Amount
    28.   End If
    29. End Function
    30. Private Function GetNoKeyDown()
    31.   If GetAsyncKeyState(keyRight) = 0 And GetAsyncKeyState(keyLeft) = 0 Then
    32.     ShipSpeedX = 0
    33.   End If
    34.   If GetAsyncKeyState(keyUp) = 0 And GetAsyncKeyState(keyDown) = 0 Then
    35.     ShipSpeedY = 0
    36.   End If
    37. 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
  •  



Click Here to Expand Forum to Full Width