Results 1 to 10 of 10

Thread: moving circle-tracker system

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    moving circle-tracker system

    I would like for a circle to be drawn with a piece of writing comming off it. I then want the circle to just move from say one side of a large label to halfway.
    Seemed easy at first but now it seems a little harder. Please note i need to be able to click on this circle to bring up another form.

    I am attempting to make a simple tracking system. A 2d map will be drawn, by which these circles represent people. When i click on the people, another form will show showing there details.
    There are 20 people in the system, but i only need one moving.

    Any help on this is much appreciated

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    a little help from anybody?..............................

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Let me know if this helps you.
    Attached Files Attached Files
    This world is not my home. I'm just passing through.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    It has been really useful, its what i wanted.
    I am having trouble adapting the code to what i want, i was wondering if u cud help me.
    I would like it to start from the right hand side, (not completly, bout a quarter in). Then move a little to the left and then move up.
    I have been playing with the code, but find the program feezes. Here is the main form code for what i have.
    I have left the second circle, as i want to get one working first.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    f1 = New Form2()
    f1.Name = "John"
    Me.AddOwnedForm(f1)

    ' f2 = New Form2()
    ' f2.Name = "Roy"
    'Me.AddOwnedForm(f2)

    f1.Visible = True
    f1.Top = Me.Top + 375
    f1.Left = Me.Right - 70

    'f2.Visible = True
    'f2.Top = Me.Top + 40
    'f2.Left = Me.Left + 120

    Me.Visible = True


    Dim i As Integer
    Dim startPoint As Integer = 120
    Dim endPoint As Integer = 80
    Dim stp As Integer = 1

    While blnRunning
    For i = startPoint To endPoint Step stp
    f1.Left = Me.Right + i * 2
    'f2.Top = Me.Top + i
    Thread.Sleep(25)
    Application.DoEvents()
    If Not blnRunning Then
    Exit For
    End If
    Next
    If stp = 1 Then
    stp = -1
    startPoint = 80
    endPoint = 120
    Else
    stp = 1
    startPoint = 120
    endPoint = 80
    End If
    End While

    f1.Close()
    f2.Close()

    End Sub

  5. #5
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    There are two sections of code that you need to change. The following are the corrected versions.

    VB Code:
    1. Dim i As Integer
    2.         Dim startPoint As Integer = 120
    3.         Dim endPoint As Integer = 80
    4.         Dim stp As Integer = -1

    VB Code:
    1. If stp = -1 Then
    2.                 stp = 1
    3.                 startPoint = 80
    4.                 endPoint = 120
    5.             Else
    6.                 stp = -1
    7.                 startPoint = 120
    8.                 endPoint = 80
    9.             End If
    This world is not my home. I'm just passing through.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    I worked out how to make the object move right to left and straight up. I am having a problem moving another object at the same time. Nothing happens, the object (named f8) doesnt move. Everything has been declared and boolean has been set to true. Do u know whats wrong? I am trying to get the object to move in a diagonal direction, ( i found that having a left and top does thi but its not working).

    Dim i As Integer
    Dim startPoint As Integer = 400
    Dim endPoint As Integer = 200
    Dim stp As Integer = 1
    Dim start As Integer = 350
    Dim ends As Integer = 200

    While blnRunning
    For i = startPoint To endPoint Step stp
    f1.Left = Me.Left + i * 2
    Thread.Sleep(25)
    Application.DoEvents()
    If Not blnRunning Then
    Exit For
    End If
    Next
    If stp = 1 Then
    stp = -1
    startPoint = 400
    endPoint = 150
    Else
    stp = 1
    blnRunning = False
    bqrunning = True
    End If
    End While

    While bqrunning
    For i = start To ends Step stp
    f1.Top = Me.Top + i
    Thread.Sleep(25)
    Application.DoEvents()
    If Not bqrunning Then
    Exit For
    End If
    Next
    If stp = 1 Then
    stp = -1
    start = 350
    ends = 160
    Else
    bqrunning = False


    End If
    End While
    'f1.Close()
    f1.Visible = True
    f1.Top = Me.Top + i
    f1.Left = Me.Left + 300


    Dim s As Integer = 10
    Dim en As Integer = 100
    Dim t As Integer

    While f8run
    For t = s To en Step stp
    f8.Left = Me.Left + t * 2
    f8.Top = Me.Top + t
    Thread.Sleep(25)
    Application.DoEvents()
    If Not f8run Then
    Exit For
    End If
    Next
    If stp = 1 Then
    stp = -1
    startPoint = 10
    endPoint = 100
    Else
    f8run = False


    End If
    End While

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    I suggest that you single step through your program (start it by pressing the <F8> key and then keep pressing the <F8> key to go through line by line. If you hover the mouse pointer over the variable names during this process you will see their current values. This should help you see what is going wrong.

    While you are debugging you can view and change variables in the Immediates window (press <CTRL> G to activate this. In this window type ?blnRunning to display the state of blnRunning, or type blnRunning = False to set it to false.
    This world is not my home. I'm just passing through.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    i have noticed that the while statement has from start to end stp.
    That means it works between these points. The problem is i can't get another dot to move in a different location at the same time while the initial one is moving.
    I need it in a different part of the screen and not the bounds set in the initial while statement.

    Could you help me with this please?

  9. #9
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Here you go. I quite like this.

    The positions array holds 100 points for each Form2 object. f1's points are in positions(,0) and f2's points are in positions(,1). You don't have to use the For Next loop to populate positions - you could write 100 lines of code to create a different point for every element if you wanted.

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         f1 = New Form2()
    3.         f1.Name = "John"
    4.         Me.AddOwnedForm(f1)
    5.  
    6.         f2 = New Form2()
    7.         f2.Name = "Roy"
    8.         Me.AddOwnedForm(f2)
    9.  
    10.         Dim positions(180, 2) As Point
    11.  
    12.         Dim p As Integer
    13.         For p = 1 To 180
    14.             positions(p, 0) = New Point(p + 40 + Me.Left, p + 40 + Me.Top)
    15.             positions(p, 1) = New Point(2 * p + Me.Left, 100 + (Math.Sin(p / 10) * 80) + Me.Top)
    16.         Next p
    17.  
    18.         f1.Visible = True
    19.         f1.Location = positions(1, 0)
    20.  
    21.         f2.Visible = True
    22.         f1.Location = positions(1, 1)
    23.  
    24.         Me.Visible = True
    25.  
    26.  
    27.         Dim i As Integer
    28.         Dim startPoint As Integer = 1
    29.         Dim endPoint As Integer = 180
    30.         Dim stp As Integer = 1
    31.  
    32.         While blnRunning
    33.             For i = startPoint To endPoint Step stp
    34.                 f1.Location = positions(i, 0)
    35.                 f2.Location = positions(i, 1)
    36.                 Thread.Sleep(25)
    37.                 Application.DoEvents()
    38.                 If Not blnRunning Then
    39.                     Exit For
    40.                 End If
    41.             Next
    42.             If stp = -1 Then
    43.                 stp = 1
    44.                 startPoint = 1
    45.                 endPoint = 180
    46.             Else
    47.                 stp = -1
    48.                 startPoint = 180
    49.                 endPoint = 1
    50.             End If
    51.         End While
    52.  
    53.         f1.Close()
    54.         f2.Close()
    55.  
    56.     End Sub
    This world is not my home. I'm just passing through.

  10. #10
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Another thought.

    Rather than populating the positions array programatically you could write all your points in a CSV file (easily editted using Excel for example) and have your program read them in from this file.
    This world is not my home. I'm just passing through.

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