Results 1 to 4 of 4

Thread: Slope

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    All right heres the problem, I have tried numerous times and each time it doesn't work right. My goal is to have your guy on a map move to where you click the mouse in a straight line. When I do it I can get the guy to move in a basic line, but he jumps to where the mouse is. So my question is how can I move my guy in a straight line, while on each step he takes place a new animation for the guy, without him jumping or skipping around.

    THANKS

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How does your movement algoritm look like? how fast does it update? Is there a graphical problem or a problem with arranging the coordinates for the guy? What are you using to specify the coordinates for him?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Private Sub Map_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    rx = x
    ry = y
    DeltaX = Xpos - rx
    DeltaY = Ypos - ry
    holdx = WalkIcon.Left
    holdy = WalkIcon.Top
    If rx >= Xpos Then
    NegX = 1
    Else
    NegX = -1
    End If
    If ry >= Ypos Then
    NegY = 1
    Else
    NegY = -1
    End If
    If DeltaX > DeltaY Then ' run greater than rise
    XSlope = 1 * NegX
    If DeltaX <> 0 Then
    YSlope = DeltaY / DeltaX * NegX
    Else
    XSlope = 0
    End If
    ElseIf DeltaX < DeltaY Then
    YSlope = 1 * NegY
    If DeltaY <> 0 Then
    XSlope = DeltaX / DeltaY * NegY
    Else
    YSlope = 0
    End If
    Else
    XSlope = 1 * NegX
    YSlope = 1 * NegY
    End If
    Do Until holdx = rx Or holdy = ry
    DoEvents
    holdx = holdx + XSlope
    holdy = holdy + YSlope
    ' draw in the animations and others ect..
    walkicon.left = holdx
    walkicon.top = holdy
    WalkIcon.Picture = LoadPicture(App.Path & "\Graphics\Animation\KnightR1.gif") ' this part has more code to determine which frame it is on, but too lengthy too place

    ' below this no problems here
    loop

    Okay heres what I have looking at I know I could probaly make it more efficient but the problem is when I click the mouse down and hold it, the guy(walkicon) is suppose to move to that location, but when he is moving towards the destination he sometimes just jumps right there without moving in the inbetween parts. I think the problem has something to do with processor speed running the loop, I added a gettickcount to combat this, but sometimes the guy moves fast and other times slower. It has something to do with the slope code and how it evaluates where he is on each loop. Maybe someone could come up with better code that moves the guy on a straight line and has the guy move smoothly and with the same speed to each destination.

    Thanks for your Time

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I think you need to make some real changes to your game, for instance having vectors instead of lot of x and y variables, btw what are all those variables? also you could post that again indented inside code tags, you post code inside code tags by doing:
    [code]
    your code goes here
    [/code]
    then maybe we could understand it better
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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