PONG GAME (VB6)

St4nley

Member
Apr 13, 2013
469
76
Ok so i'm making pong, i got basically all collision start from space bar but, when it collides even if the paddle isnt there it'll still collide and go back the other way,

heres my code

Code:
Dim goodVel As Integer
Dim goodvel1 As Integer
Private Sub Form_Load()
        goodVel = 50
        goodvel1 = 0
End Sub
Private Sub Timer1_Timer()
imgball.Left = imgball.Left - goodvel1
 
If imgball.Left + imgball.Width > imgPaddle.Left + 400 Then
    goodvel1 = goodvel1 * -1
End If
 
If imgball.Left < imgPaddle.Height - 1000 Then
goodvel1 = goodVel * -1
End If
 
End Sub
 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
imgPaddle.Top = Y
imgPaddle.Width = Form2.ScaleHeight
End If
End Sub
Private Sub Form_keydown(keycode As Integer, Shift As Integer)
    If keycode = vbKeySpace Then
        goodvel1 = goodVel * -1
        imgball.Top = imgball.Top - goodVel
    End If
End Sub

if you have vb6 and want to try this yourself then i can simply send you a paddle and a ball to implement this yourself.
 

St4nley

Member
Apr 13, 2013
469
76
What happened to Billiards?

first off i forgot to thank you last night for your help, i apolgize and i sincerly appreciate it deeply, i was just busy and wanted to reply i did
secondly, i figured it is way to hard, i do not have enough time or support. PONG is almost done, except the computer needs to follow the ball i need to figure that out
and i need to make the ball go past the paddle if the player doesnt catch it in time.

Billiards i had an issue with collision because it would colid at the line of where the bottom of the balls would be, not the actual ball.

so yeah, im pretty much screweed. im gonna try this for another 3 hours, if i can't get anywhere ill send him my 3 games i tried to make and all failed

(PONG, billiards, pinball) and i'll study for the exam maybe that will save me

Thanks again Weed:)
 

Weed

Member
Jul 11, 2010
31
2
I don't actually know any VB, I've done games in another languages. I'm shooting in the dark here. :p

Make the computer move to the height the ball is at. So grab it's Y position on the X Y scale, and make the computer move to that height.

Wherever your infinite game loop is, add a line of code to check the ball's Y, and set the paddle to it's Y.

Code:
        If Ball.Location.Y > 5 And Ball.Location.Y < Pad.Height - 40 _
        - paddlePlayer.Height Then _
        paddleComputer.Location = New Point(paddleComputer.Location.X, gameBall.Location.Y)

If you don't have a gameloop, it's sort of vastly important for anything requiring images that refresh/move.
 

Users who are viewing this thread

Top