Hack Forums
[.NET] How to refresh graphics when it's moving around? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] How to refresh graphics when it's moving around? (/showthread.php?tid=5801161)



How to refresh graphics when it's moving around? - Ajumma - Feb 18, 2018

Say for example I draw a box on my screen. The box's X and Y coord will change pretty much all the time. When I am drawing the box and all of it's new position, a new box keeps appearing. I want to draw the same box, and as its location is changed, draw that same box on the new location.

Example :

Box1 : X/Y = 0,0 Box1 (new X/Y) = 0,15

I now have 2 box on my screen.

Dim doo As Integer = 1

Code
While doo = 1
    For i As Integer = 0 To MonsterCount
        Dim xx As Integer = GetPrivateProfileInt("iPC=" & i, "X-Int:", 0, INI)
        Dim yy As Integer = GetPrivateProfileInt("iPC=" & i, "Y-Int:", 0, INI)
        Box(i) = New Box(xx, yy)

        If Box(i).x > -10 And Box(i).y > -10 And Box(0).x <= 1920 And Box(0).y <= 1080 Then
            Dim rect As New Rectangle(Box(i).x, Box(i).y, 120, 80)
            e.Graphics.DrawRectangle(Pens.Green, rect)
            Invalidate()
        End If

    Next i

    Threading.Thread.Sleep(5)
End While

Thank you for any help!


RE: How to refresh graphics when it's moving around? - Vyxn - Feb 18, 2018

You keep making a new instance of rectangle on your code.