
-----------------------------------
Knightmare
Tue Mar 18, 2003 9:14 pm

Movement Code
-----------------------------------
I've got an end of the year project im getting a jump  on cause I don't wanna wait till last minute for it (like i did my dice game) and I just wanted to know what you guys thought the most efficient way of getting a character to move to a desired location.  Like I click my character. hes selected, click somewhere else and I want the animation of him moving to play till he gets there...how should I do this?

-----------------------------------
Asok
Tue Mar 18, 2003 9:42 pm


-----------------------------------
first off you should check out the tutorial here: http://www.compsci.ca/bbs/viewtopic.php?t=6

this will teach you how to incorporate your mouse into your turing program, it should be able to help you out.

-----------------------------------
JayLo
Tue Mar 18, 2003 10:22 pm


-----------------------------------
too bad turing can't support animated .gif files or it would be [b]alot{/b] easier! :P

-----------------------------------
Tony
Tue Mar 18, 2003 10:58 pm


-----------------------------------
turing cant support .gifs PERIOD. well in 5 years when they dont have to pay for a licence :?

otherwise, you can animate bmps or jpegs by writing a procedure to loop through the images. Such as instead of drawing an image, you call a procedure which has a counter that determines what image to draw.

-----------------------------------
JayLo
Wed Mar 19, 2003 6:45 pm


-----------------------------------
stupid cheap holtsoft... ya... var leftPic1 : int := Pic.FileNew ("leftPic1.JPG")
var leftPic2 : int := Pic.FileNew ("leftPic2.JPG")
var leftPic3 : int := Pic.FileNew ("leftPic3.JPG")
var x, y : int
procedure movement
    loop
        Pic.Draw (leftPic1, x, y, picMerge)
        Pic.Draw (leftPic2, x, y, picMerge)
        Pic.Draw (leftPic3, x, y, picMerge)
    end loop
end movement

-----------------------------------
Knightmare
Wed Mar 19, 2003 7:08 pm


-----------------------------------
Thanks for the replies but im not looking for how to animate, im looking for moving it from one place to the other. As in the character is at (1,1) and I tell it to go to (5,11) or something like that. I want to know how to calculate how to get him to move to that position

-----------------------------------
Asok
Wed Mar 19, 2003 7:18 pm


-----------------------------------
a variable for currentpos and finalpos for both x and y, get the difference of it. make a for loop count on that difference and increase the x and y coordinateds by thier variables to reach finalpos.

-----------------------------------
Tony
Wed Mar 19, 2003 7:38 pm


-----------------------------------
it works much the same way as the the procedure for drawing a line.

you calculate displacements on X and Y axis (difference between 2 points), total displacement (c^2 = a^2 + b^2). The total displacement is how many steps you take total.

Now you divide X and Y displacements by number of steps, the result is how much you need to move per step to move along a straigh line. Once you got that, you run a for loop from 1 to number of steps and add X and Y step displacement once through each run. That should take you from point A to point B in a straight line  :D

-----------------------------------
Vicous
Thu Mar 20, 2003 11:04 am


-----------------------------------
or are you talking about a board game style, where the charector goes from square to square, one at a time, in which case you should figure out loops to make the charector go left, right, up and down etc. and go from there

-----------------------------------
Knightmare
Thu Mar 20, 2003 9:38 pm


-----------------------------------
Thanks again, actually no its going to be a RTS, i did the ctf game like that for my dice game (mid term proj)
Thanks for everything.
