I want to create a traffic simulator like here: http://www.doobybrain.com/wp-content/uploads/2008/03/traffic-simulation.gif But I didn't thougt very deep about this.
I would create the class car. Every car has his own color, position and so on.
And I could create the road with an array.
But how to tell the car where to go? Could I hear your ideas?
EDIT: Is it forbidden to get new ideas from good programmers? Why do some people want to close this thread? Or were to ask such questions? I dont understand them. :(
EDIT2: Next time I will go to a gamer-forum. I like the ideas until now. Thanks!
You don't tell a car where to go. It goes anyway due to its velocity. By looking ahead (where will it be a few timesteps from now, and is there still a road?) you can see whether you need to adjust the velocity.
And a road isn't an array; it's a matrix or bitmap. You can't go all that fast in the corner or you'll fly from the road.
It's always a good idea to clearly formulate the goals and scope first. In this case, you would be thinking about the extent of the modeling (the physics involved) and the complexity of the car movements (collisions, following bend roads, and so on).
I find that if you can state your concept clearly in plain English (or Dutch in my case), writing the code becomes much easier, almost trivial sometimes.
EDIT
For clarity, when I'm talking about velocity I'm talking about a vector, which has both magnitude (10MPH) and direction. Your vectors would have 2 elements, x and y, unless you also want airplanes, or want to model hills and such (you don't want hills 'cause you'd also have to take gravity into account:) where a z position and velocity are used.