p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning VB 6 (http://p2p.wrox.com/forumdisplay.php?f=75)
-   -   can any one tell me how i can add ball in run time (http://p2p.wrox.com/showthread.php?t=67819)

humera May 1st, 2008 09:48 AM

can any one tell me how i can add ball in run time
 
in runtime how i m add ball one by one i have 3 ball i want one ball 1st time 2nd ball after 5 min come and 3rd after 7 min come how i can this in code i use a timer plz help me
Dim X As Integer, Y As Integer
Dim c As Boolean

Private Sub Form_Load()
ball.Top = 2500
ball.Left = 1300
X = -50
Y = -50
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
pad0.Left = X - pad0.Width
End Sub

Private Sub Timer4_Timer()
ball.Move ball.Left + X, ball.Top + Y
If ball.Top <= 0 Then
    Y = Y * -1
End If

If ball.Left <= 0 Then
    X = X * -1
End If
If ball.Left + ball.Width >= Me.ScaleWidth Then
    X = X * -1
End If
If ball.Top + ball.Height >= pad.Top Then
If (ball.Left + ball.Width < pad.Left) Or (ball.Left > pad.Left + pad.Width) Then 'If the ball is to the left or right of the pad then
ball = ball + 1
Me.Caption = "Game Over" 'set the forms caption to read 'Game Over'
MsgBox "Game over back to menu home !!! ", vbDefaultButton1
Timer4.Enabled = False 'pause the program
Else
Y = Y * -1.05 'speed up the ball
X = X * 1.05
Score = Score + 1 'add 1 more hit to the score
scorecard.Caption = "Score: " & Score 'show the score on our label
'Me.Caption = "Score: " & Score 'show the score as our forms caption
If (ball.Left + ball.Width) < (pad.Left + pad.Width) Then 'if the ball is to the left of the pads centre then
If X > 0 Then 'if it is going right
X = X * -1 'make it go left
End If
Else 'the ball must be on the right of the pad
If X < 0 Then 'if it is going left
X = X * -1 'make it go right
End If
End If
End If
End If
End Sub



gbianchi May 1st, 2008 11:15 AM

Hi there..

I don't understand why you post your code, but if you have a timer, you can count the time and "add" a new ball when you need it..

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========


All times are GMT -4. The time now is 12:44 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.