RocketSim Documentation¶
Warning
This documentation site is a work in progress. There are some issues and missing features.
Index¶
Getting Started¶
Here’s a basic example of creating an Arena, adding a Car, and simulating with custom inputs:
#include "./RocketSim/src/Sim/Arena/Arena.h"
// Make an arena instance (this is where our simulation takes place, has its own btDynamicsWorld instance)
Arena* arena = Arena::Create(GameMode::SOCCAR);
// Make a new car
// NOTE: The ball and all cars are freed from memory when their arena is deconstructed, you don't need to do it yourself
Car* car = arena->AddCar(Team::BLUE);
// Set up an initial state for our car
CarState carState = {};
carState.pos = { 0.f, 0.f, 17.f };
carState.vel = { 50.f, 0.f, 0.f };
car->SetState(carState);
// Setup a ball state
BallState ballState = {};
ballState.pos = { 0.f, 400.f, 100.f };
arena->ball->SetState(ballState);
// Make our car drive forward and turn
car->controls.throttle = 1;
car->controls.steer = 1;
// Simulate for 100 ticks
arena->Step(100);
// Lets see where our car went!
std::cout << "After " << arena->tickCount << "ticks, our car is at: " << car->GetState().pos << std::endl;
// Destroy the arena once we are done
delete arena;