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 April 29th, 2008, 11:23 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default can any one help me in this prog

Dim X As Integer, Y As Integer, Score As Integer

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

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

Private Sub Reset_Click()
Ball.Left = 2500 'reset the balls position
Ball.Top = 1300
X = -50 'reset the speed
Y = -50 'reset the speed
Reset.Visible = False
Score = 0 'reset the score
ScoreCard.Caption = "Score: " & Score 'show the score on our label
Me.Caption = "Score: " & Score 'show the score as our forms caption
Timer1.Enabled = True 'start the timer again to get the ball moving
End Sub

Private Sub Timer1_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
        Me.Caption = "Game Over" 'set the forms captino to read 'Game Over'
        Reset.Visible = True 'make the reset buttone visible
        Timer1.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 / 2) < (Pad.Left + Pad.Width / 2) 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 April 29th, 2008, 12:43 PM
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..

where's the problem? the code alone doesn't help much...

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
In a C prog want to use C variable in WHERE clause turnbui BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 December 6th, 2006 05:22 PM
PROG TO EREASE...help zetkonrad C++ Programming 0 October 20th, 2006 05:38 AM
This is general for advanced prog. teligaurav ASP.NET 1.0 and 1.1 Professional 1 June 13th, 2006 03:53 AM
unable to run prog bharathy JSP Basics 0 March 17th, 2006 01:26 PM
please help to develop this quotation prog mjuliao Access 18 August 29th, 2005 10:28 PM





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