Results 1 to 17 of 17

Thread: Making a Timer Move a picture Multiple Directions (EX:up then down then left then up)

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Heaven........ Whats that fire doing here?
    Posts
    39

    Question Making a Timer Move a picture Multiple Directions (EX:up then down then left then up)

    I have an image, ts called Img1, once I press the CmdStart button, I want it to move left to "9600", then I want it to move down to "120" then left to "360" then right to "9600".....

    Something like that, you get the picture, once the Img1.left = that number, I want it to change directions and go to another number....... AND I DO NOT WANT TO USE 50000 TIMERS...

    I HAVE NO CLUE HOW TO DO THIS...........

    THANKS SO MUCH

    (P.S. PLEASE HELP!!!!!!)
    []:::::::::::[];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;/

    Did you know that you can be your own grandpa?! It's really cool. . . . . .
    ------------------------------------------------
    But I'm not. . . Im just Myself. . . . .
    Not my own grandpa. . . . . .

    I put on my own pants today. . . . .
    Im so proud of myself. . . . .

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Make a timer with an interval of 1000 or something (1 second)
    Set it's property, Enabled to false so it doesn't start straight away

    then put this code in it.

    VB Code:
    1. counter = counter + 1
    2.  
    3. Select Case counter
    4.     Case 1
    5.         img1.left = 9600
    6.     Case 2
    7.         img1.top = 120
    8.     Case 3
    9.         img1.left = 360
    10.     Case 4
    11.         img1.left = 9600
    12. End Select

    In the command button click event put

    VB Code:
    1. Timer1.Enabled = True
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    The main thing is whether you want a gradual move or an instant move. If instant, then SLH's code is fine. If you want gradual movement it's a little bit trickier, but still easy.
    -Show me on the doll where the music touched you.

  4. #4
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375

    Talking

    Sorry to interrupt your post, but i'm just checking to see if my counter works.
    -Show me on the doll where the music touched you.

  5. #5
    Lively Member flamer2010's Avatar
    Join Date
    Apr 2002
    Posts
    96
    you could loop it

    VB Code:
    1. Do
    2. Pic1.Left = Pic1.Left + 10
    3. Loop Until Pic1.Left = 9600
    4. Do
    5. Pict1.Top = Pic1.Top - 10
    6. Loop Until Pic1.Top = -120

    and so on

  6. #6
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    Actually, since he's moving the picture down, the code would be:

    VB Code:
    1. Pict1.Top = Pic1.Top + 10
    2. Loop Until Pic1.Top = 120
    -Show me on the doll where the music touched you.

  7. #7
    Lively Member jamieoboth's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    116
    Actually, while we are on this subject (and I can't be bothered to start a new thread), I need to know how to get the object (say a picture box) to follow your character, but gradually, not just to jump to it. For example, if you click on the point x,x with your mouse, I want the object to slowly move to that position. HOW!?
    Ich widerstehe allem - nur nicht der Versuchung

    (I can resist anything but temptation)

  8. #8
    Lively Member flamer2010's Avatar
    Join Date
    Apr 2002
    Posts
    96
    You could get the x,y positions of both the picturebox and the mouseclick. Once you have them, make a loop of adding 10 to the x, y position of the picture box until it reaches the mouseclick x y positions. Within the loop make the box move to the new position each time it loops.
    There's probably much better ways to do this though API

  9. #9
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    That would be the best way to do it. Instead of a loop, you could use a timer, though.
    -Show me on the doll where the music touched you.

  10. #10
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    If you want to do nonlinear motion (i.e. Move faster if the charactor is far a way from the mouse) then instead of 10, you could use the distance/100 or something
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  11. #11
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    Or if you want an oddly moving object, use a random number and divide the distance by that.
    -Show me on the doll where the music touched you.

  12. #12
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Also, if you want the object to follow your charactor like in some RPGs (Final Fantesy...) then log every n (depending on how accuratly u want it to follow, and how fast your charactor moves) movenments your charactor, in an array, then move the following objecy to the last one in the array, then shift them all down 1 (inserting the current location of your charactor in the first element of the array).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    The way SLH suggests is the best way. However it won't work if it's something like a cloud layer that you want to follow.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    What's a cloud layer?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  15. #15
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Something else that he might want to scroll with him, in this case my example was clouds. It would look very jerky.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  16. #16
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    Yes, it would look jerky. If you want a decent RPG, C++ is normally the best way to go. I tried to amke one with VB but it didn't work very well.
    -Show me on the doll where the music touched you.

  17. #17
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Making a Timer Move a picture Multiple Directions (EX:up then down then left then up)

    Originally posted by spyplayer
    Did you know that you can be your own grandpa?! It's really cool. . . . . .
    Sounds like fun...
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


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