Results 1 to 3 of 3

Thread: Unexplainable lag?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    2

    Exclamation Unexplainable lag?

    Hey guys, im hoping one of u can help me out.
    ive made a very very basic pong game and the coding looks perfect to me.

    but when it's played, both from the form and when compiled. the paddle (pad) has a tendancy to freeze up and then reappear where it was meant to be moved to. ill put the coding below. im not sure if i will be able to get back to this site but ill try. if not would somebody be so kind as to email me their thoughts? its [Email removed by Mod for members protection from spam]. thanks very much
    Code:
    Dim X As Integer, Y As Integer, score As Integer, z As Integer
    
    Const numcells = 96
    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 Form_Load()
    ball.Left = 2500
    ball.Top = 1300
    X = -50
    Y = -50
    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
            
    reset.Visible = True
    Timer1.Enabled = False
    Label1.Caption = ""
    Else
    Y = Y * -1.05
    X = X * 1.05
    score = score + 1
    
    
    Randomize
    If score >= 0 And score <= 9 Then
    For z = 0 To numcells - 1
    Shape1(z).BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
    Next z
    End If
    
    
    scorecard.Caption = "Score: " & score
        If (ball.Left + ball.Width / 2) < (pad.Left + pad.Width / 2) Then
                If X > 0 Then
                    X = X * -1
                End If
            Else
                If X < 0 Then
                    X = X * -1
                End If
            End If
        End If
    End If
    
    If score = 30 Then
    winreset.Visible = True
    Timer1.Enabled = False
    End If
    
    End Sub
    
    
    
    Private Sub Timer2_Timer()
    If score = 0 Then
    ball.BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
    Label1.Caption = ""
    End If
    
    If score > 0 And score <= 9 Then
    ball.BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
    Label1.Caption = "You are Tripping Out!"
    Label1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
    End If
    
    If score >= 10 And score <= 19 Then
    ball.BackColor = vbBlack
    ball.BorderColor = &HC0C0C0
    ball.BorderStyle = 1
    For z = 0 To numcells - 1
    Shape1(z).BackColor = vbBlack
    Next z
    Label1.Caption = "Welcome to the twilight zone"
    Label1.ForeColor = &H808080
    End If
    
    If score >= 20 And score <= 30 Then
    ball.BackColor = vbWhite
    ball.BorderColor = &HC0C0C0
    ball.BorderStyle = 1
    For z = 0 To numcells - 1
    Shape1(z).BackColor = vbWhite
    Next z
    Label1.Caption = "   Oh no! A Blizzard!"
    Label1.ForeColor = &HC0C0C0
    End If
    
    
    
    
    
    
    
    End Sub
                              
    Private Sub winreset_Click()
    ball.Left = 2500
    ball.Top = 1300
    X = -50
    Y = -50
    winreset.Visible = False
    score = 0
    scorecard.Caption = "Score: " & score
    Label1.Caption = ""
    Timer1.Enabled = True
    
    For z = 0 To numcells - 1
    Shape1(z).BackColor = vbWhite
    Next z
    
    End Sub
    Private Sub Reset_Click()
    ball.Left = 2500
    ball.Top = 1300
    X = -50
    Y = -50
    reset.Visible = False
    score = 0
    scorecard.Caption = "Score: " & score
    
    Timer1.Enabled = True
    
    For z = 0 To numcells - 1
    Shape1(z).BackColor = vbWhite
    Next z
    
    End Sub
    Last edited by RobDog888; Aug 12th, 2008 at 01:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width