To give more exciting feeling to the game play, more bots are rendered. For this purpose, the track matrix data is taken from replay.cs which contains the position and rotation of the bot at the specific time. The following code
Matrix bestReplayCarMatrix = RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime( RacingGameManager.Player.GameTimeMilliseconds / 1300.0f); |
Source code 3‑2: Matrix data used from best replay
Before rendering the car, the rotation of the car is created to make sure the car stay correctly on the road.
bestReplayCarMatrix = Matrix.CreateRotationX Matrix.CreateRotationZ bestReplayCarMatrix; |
Source code 3‑3: Rotate the car to stay correctly on the road.
Finally, the car is rendered with a specific texture, colour and matrix to the world.
RacingGameManager.CarModel.RenderCar( 1, RacingGameManager.CarColors[5], false, bestReplayCarMatrix); |
Source code 3‑4: Rendering the bot
each bot is given unique matrix:
Matrix bestReplayCarMatrix =
RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(
RacingGameManager.Player.GameTimeMilliseconds / 1300.0f);
Matrix bestReplayCarMatrix2 =
RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(
RacingGameManager.Player.GameTimeMilliseconds / 1200.0f);
Matrix bestReplayCarMatrix3 =
RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(
No comments:
Post a Comment