Skip to main content
gamedev.net
🔒 Locked

Coordinate Systems

Started by Ozz 2 replies 450+ views
Original Post
Ozz
Ozz
I have a rather nice environment coded for my boat racing project, my problem is that I need to know exactly where each boat is during the race on the race coarse (open ocean), what direction it is pointed and where each buoy on the coarse is. I am wondering about setting up the coordinate system, does anyone have ideas?
vbisme
vbisme
I would say to use arrays. Let''s say this is your track.
/ /
/ /
/ /
/ /
/ /
setup an 2D array
int array[5][3];
use the elements in the array as coordinates
(0,0),(0,1),(0,2)
(1,0),(1,1),(1,2)
(2,0),(2,1),(2,2)
(3,0),(3,1),(3,2)
(4,0),(4,1),(4,2)

then in your boat object let''s say:
typedef struct Position
{
int x;
int y;
};
class Boat
{
private:
Position CurrentPosition;
public:
GetPosition();
};
Boat::GetPosition()
{
return (CurrentPosition);
}

Ozz
Ozz
Thanks for the input. What about scaling of the coordinate points, I really need an exact location, i.e what if the boat is in between two coords.
Demon Lord
Demon Lord
Use floats?
----------------------------------------"Inash neteia haeg joa kavari quilm..." SD4

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.