Computer Science Canada

Graphics Help Visual Basic

Author:  CompN [ Sun Nov 26, 2006 9:32 pm ]
Post subject:  Graphics Help Visual Basic

Can somebody give me some hints on how to stop the that thing that is moving on the screen. For example I made the classic ball in the box, where the ball bounces off the perimeter.

How would I make the ball stop as in freeze when I click a button.

Any help would be great Smile

Author:  md [ Sun Nov 26, 2006 11:12 pm ]
Post subject: 

Uhh... C/C++ doesn't have built in graphics, so you must be using some graphics library. Since you didn't say what that was it's impossible help. Even if you did say which library, I have no idea what you are talking about... so unless code and or a screenshot is provided it's REALLY impossible to help.

So, what graphics library; and screnshot/code Razz

Author:  [Gandalf] [ Sun Nov 26, 2006 11:33 pm ]
Post subject: 

Hmm... Actually I think this is a case of posting in the wrong section. He has "Visual Basic" in the topic title. Smile

Author:  CompN [ Mon Nov 27, 2006 2:50 pm ]
Post subject:  Re: Graphics Help Visual Basic

CompN wrote:
Can somebody give me some hints on how to stop the that thing that is moving on the screen. For example I made the classic ball in the box, where the ball bounces off the perimeter.

How would I make the ball stop as in freeze when I click a button.

Any help would be great Smile
Private Sub start_Click()
Dim Start As Integer
Dim nd As Integer
Dim changex As Integer
Dim changey As Integer
Dim x As Double
Start = 0
nd = 0
changex = 50
changey = 50
Do
ball.Left = ball.Left + changex
If ball.Left + ball.Width > Picture1.Width Then
changex = changex * -1
ElseIf ball.Left < 0 Then
changex = changex * -1
End If
ball.Top = ball.Top + changey
If ball.Top + ball.Height > Picture1.Height Then
changey = changey * -1
ElseIf ball.Top < 0 Then
changey = changey * -1
End If

For x = 0 To 1000
DoEvents
Next x
Loop
End Sub

This is the code



Author:  CompN [ Mon Nov 27, 2006 3:58 pm ]
Post subject: 

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Author:  md [ Mon Nov 27, 2006 5:02 pm ]
Post subject: 

As this is VB can a mod move it to the Basic section? I haven't done anything in VB for so long I don't even want to try helping out here.

Author:  cool dude [ Mon Nov 27, 2006 7:32 pm ]
Post subject: 

pretty easy. i'll help you when you properly indent your code and attach the form.


: