vb Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick, MyBase.Move Dim movepix As Integer movepix = 5 Ball = Me.CreateGraphics Ball.Clear(Color.Gray) If y = 230 Then movepix = (movepix * -1) End If If y = 0 Then movepix = (movepix * -1) End If If x = 230 Then movepix = (movepix * -1) End If If x = 0 Then movepix = (movepix * -1) Else x += movepix y += movepix End If Ball.FillEllipse(Brushes.Yellow, x, y, 20, 20) End Sub
this is what i came up with for moving the ball in a pong game i am creating.....all the ball does is travel at a diagonal until it gets stuck in the lower-right corner.....i can't get the balll to richochet or move around the dimensions of the window.....also, i cant find a good was of clear the ball graphic without changing the backfround color.




Reply With Quote