|
-
Oct 12th, 2003, 12:27 PM
#1
Thread Starter
Fanatic Member
What's wrong with this code? [SOLVED]
I have no problems getting the ball to wrap to the other side of the screen, but now I'm trying to get it to bounce like it does in a Breakout-type game. The code snippet below doesn't work, the ball just sticks to the bottom of the screen.
NOTE: Right now I'm testing the code in a command button's click procedure inside a practice program, just to see if I can get it working.
VB Code:
Private Sub Command1_Click()
Dim T1 As Long, T2 As Long
myBackBuffer = CreateCompatibleDC(GetDC(0))
myBufferBMP = CreateCompatibleBitmap(GetDC(0), 320, 256)
SelectObject myBackBuffer, myBufferBMP
BitBlt myBackBuffer, 0, 0, 320, 256, 0, 0, 0, vbWhiteness
mySprite = LoadGraphicDC(App.Path & "\sprite1.bmp")
mySprite1 = LoadGraphicDC(App.Path & "\mask.bmp")
cmdTest.Enabled = False
T2 = GetTickCount
Do
DoEvents
T1 = GetTickCount
If (T1 - T2) >= 0.15 Then
BitBlt myBackBuffer, SpriteX - 1, SpriteY - 1, 32, 32, 0, 0, 0, vbBlackness
BitBlt myBackBuffer, SpriteX - 1, SpriteY - 1, 32, 32, 0, 0, 0, vbSrcAnd
BitBlt myBackBuffer, SpriteX, SpriteY, 32, 32, mySprite, 0, 0, vbSrcAnd
BitBlt myBackBuffer, SpriteX, SpriteY, 32, 32, mySprite1, 0, 0, vbSrcPaint
BitBlt Me.hdc, 0, 0, 320, 256, myBackBuffer, 0, 0, vbSrcCopy
SpriteX = SpriteX + 1
SpriteY = SpriteY + 1
T2 = GetTickCount
End If
If SpriteX = 320 Then
SpriteX = SpriteX - 1
SpriteY = SpriteY - 1
ElseIf SpriteY = 256 Then
SpriteX = SpriteX - 1
SpriteY = SpriteY - 1
End If
Loop
End Sub
The code works fine when I take it out of the If SpriteX = 320/If SpriteY = 256 statements, so it must be the correct code.
Last edited by hothead; Oct 12th, 2003 at 07:10 PM.
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
|