Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   move along a track? (http://www.alice.org/community/showthread.php?t=622)

 axeraider131 02-10-2007 01:33 PM

move along a track?

hello again,

my new idea was to have a game where a character moves along a hidden track (that isnt in a straight line). somewhat like Kirby 64. with curves and turns. if it is possible to do this, please respond, any help would be greatly appreciated. thank you.

 DrJim 02-11-2007 06:49 PM

See example in text for a start.

This will take a little work, but is definitely possible. :)

For a start, I suggest you look at problem 4 in Chapter 6 of the textbook by Dunn, et all. This outlines the basic approach, which is to have the object move from point to point along a mathematically defined curve. This works well for some motions - swimming with sine waves per the example, ringing effects with sine waves that also decrease with time, parabolic curves for missle or cannon shells, etc.

For arbitrary curves, you will need to do curve fitting of some type - for a start, see the links at [url]http://en.wikipedia.org/wiki/Curve_fitting[/url]. These generally do point by point fits - however this is still quite helpful, since it doesn't take a lot of points to define a fairly complex path. You just have to experiment a bit. It would be nice however to be able to simply fit to a drawn curve - anyone have any links for that? :confused:

The Tick?

What do you mean the Tick?

Sorry

 chuck 02-18-2007 08:36 PM

I like the curve fitting method suggested by Dr. Jim, but is does require some math skills. Parametric equations work well for this. Think of it as plotting a curve, but the object will move from plotted point to plotted point. If you are only vaguely familiar with the math, then this is a good way to learn more about it while playing around with Alice.

A second approach is to place objects, such as the cone from the shapes gallery, along a path, then have the moving object move from one to the next, then the next, and so on, using the "move to" command together with the "turn to face" command. I suggest something like the cone because it is very simple object (only 2kb). You can leave it visible until you get the path the way you want it, then make the marker objects invisible by changing either the opacity property or the isShowing property for each of them.

You could also set up either a list or an array of the marker objects, then iterate through them with a loop. Chapter 8 in my first Alice book (An introduction to Programming using Alice) and chapter 5 in Joel Adams' first book (Alice in Action) cover arrays and lists. The Dann, Cooper and Pausch book (Learning to Program with Alice) does as well, but I don't have a copy handy to look up the chapter reference.

 All times are GMT -5. The time now is 03:04 AM.