Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 1st, 2008, 09:48 AM
Registered User
 
Join Date: Apr 2008
Location: karachi, pakistan, Pakistan.
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


Reply With Quote
  #2 (permalink)  
Old May 1st, 2008, 11:15 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:19 PM.


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