Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2008, 09:48 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


 
Old May 1st, 2008, 11:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add multiple labels to a form at run time peter-h Visual Basic 2005 Basics 5 September 22nd, 2007 04:29 AM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
Run time Help Dazzer96 Access VBA 2 May 3rd, 2006 07:03 AM
Add static controls in run time & change font/bkg firstreflex Visual C++ 0 December 17th, 2004 12:24 PM
Any run time version? jeffcflam Crystal Reports 0 March 8th, 2004 04:43 PM





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