2
\$\begingroup\$

I am developing XNA game like following screenshot.

enter image description here

I created my 3D objects and camera so I have models. But how can I implement scrolling road in XNA?

enter image description here

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

What you generally see in these games are repeated parts of the level. You can create "chunks" which contain a piece of road and the related props (trees, road markers, signs, etc).

You can create many different of these chunks, just make sure that the end of a chunk matches the next one. Then, when your car is moving forward (or the chunks move backwards to create the illusion of a moving car), make sure you place a new chunk in front of the current. As the car drives, it will go onto the next chunk and you can reclaim the previous chunk by laying it in front again to create an endless loop.

Implementation (rough steps)

[Init]

  • Load road chunks (mesh, texture...). Make sure you have at least two chunks (or create two instances of the same chunk)

[Render]

  • Render the first chunk under the car (you can place it using the translation part of the world matrix)
  • Render the second chunk in front (you can place it using the same world matrix as the first chunk PLUS the size of the chunk in the road's direction)

[Update]

  • Movement: you can either move the car forward OR move the chunks downward.
  • Check if the current chunk has moved out of the camera view. If this is the case, place it in front of the chunk that is under the car.
\$\endgroup\$
2
  • \$\begingroup\$ May you suggest me any tutorial about this topic? \$\endgroup\$
    – Mr. White
    Apr 11, 2014 at 12:44
  • \$\begingroup\$ I do not know any related tutorials, but the general steps are quite doable on your own (Given the fact that you can already load and render your car model). I've added them to my answer. \$\endgroup\$
    – Miklas
    Apr 11, 2014 at 13:07

Not the answer you're looking for? Browse other questions tagged .