
-----------------------------------
CompN
Sun Nov 26, 2006 9:32 pm

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 :)

-----------------------------------
md
Sun Nov 26, 2006 11:12 pm


-----------------------------------
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 :P

-----------------------------------
[Gandalf]
Sun Nov 26, 2006 11:33 pm


-----------------------------------
Hmm... Actually I think this is a case of posting in the wrong section.  He has "Visual Basic" in the topic title. :)

-----------------------------------
CompN
Mon Nov 27, 2006 2:50 pm

Re: 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 :)
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




-----------------------------------
CompN
Mon Nov 27, 2006 3:58 pm


-----------------------------------
http://i20.photobucket.com/albums/b212/Bengaltigeress/graph-1.jpg

-----------------------------------
md
Mon Nov 27, 2006 5:02 pm


-----------------------------------
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.

-----------------------------------
cool dude
Mon Nov 27, 2006 7:32 pm


-----------------------------------
pretty easy. i'll help you when you properly indent your code and attach the form.
