Vehicle simulation

For the Operating Systems class, I'm going to write a planning simulator, Jurrasic Park.

The ultimate goal is that I have a series of cars on a given path, and passengers waiting in line at a certain place, so that these cars return so that they can be taken and taken on a tour. This will be a simple 2nd, top-down view of the track and cars moving along it.

Although I can easily code this without having to visually display anything, I'm not entirely sure that the best way is to implement a car moving along a fixed track.

To get started, I'm just going to use OpenGL to draw my cars in the form of rectangles, but I'm still a little confused about how to approach updating the position of the car and ensure its movement along the given path for the park theme being modeled.

Do I have to store the tops of the track in the list and each call update()move the cars one step closer to the next top?

+3
source share
4 answers

, , , . , . , . - , , , . , , , .

, , . , , , , . , "" "" , , , . , , . , . , "", .

/ . . , , , , "".

, , tick(), , . , , , .

+2

:

( 100 ), . , 2D- ( ?).

(, 30 ), 30 * 10 ... . , ? 9 , (x + = dx/9, y + = dy/9).

:)

0

, - , , - . "" . , , .

, , , .

A * . , .

0

, , , , , , .

, , , , , , , .

, , , IMO, .

Another approach is to have it based on a tile, so you just look at the tiles in front of you and have different tiles to change the direction of movement, so you know how to turn the car so that it stays on the tile.

It will not be so smooth, but also easy to do.

0
source

Source: https://habr.com/ru/post/1706490/


All Articles