Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Help needed with waypoints for 2D sprite movement

Author
Message
DemonHill
17
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 24th Mar 2008 23:29
I have looked in the forum and can only find one example of a "waypoint" piece of coce. What I need help with though is some code that will allow a 2D car sprite follow points (waypoints) around a 2D track.

Any help gratefully recieved... thanks
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Mar 2008 03:55
Basically, you store the screen X and Y co-ordinates of all the waypoints in an array. As the car reaches a waypoint, it heads for the next one and so on.

This is easy in 3D as you just point the car at the next waypoint's X, Y and Z co-ordinates using the Point Object command and use Move Object to set it on it's way.

However in 2D, there are no Point, Rotate or Move commands for sprites so you have to calculate the sprite's direction and movement manually.

I've attached a very rough example I just knocked together to show the basic idea. (Download button bottom right).

Done in a hurry, it's neither optimized nor an example of good coding, but is simple enough to follow what's going on...

TDK_Man

Attachments

Login to view attachments
DemonHill
17
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 25th Mar 2008 13:45
Many thx, BTW I am using your IDE editor for DBC, is 0.1b the lastest ? if not where can I please download the latest version... thx
DemonHill
17
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 4th Apr 2008 23:04
TDK thx for the above code. I have been racking my brains how to have 20 x cars going round track without a massive duplicated code.. any pointers (or code) to help. Clearly they would all use the same waypoints but would be lagging or leading each other.... help......

Login to post a reply

Server time is: 2025-06-04 03:31:36
Your offset time is: 2025-06-04 03:31:36