Projects Inventory

Simulation of Solar System Gaming Project in C++

Explanation

  1. CelestialBody Class:
    • Attributes:
      • name: Name of the celestial body (e.g., planet).
      • distanceFromSun: Average distance from the Sun (in arbitrary units).
      • Advertisement
      • orbitalPeriod: Time taken to complete one orbit (in arbitrary time units).
      • angle: Current angle of the body in its orbit.
      • Advertisement
      • x, y: Cartesian coordinates of the body.
    • Methods:
      • updatePosition(double time): Updates the position of the celestial body based on time. The angle of the body is calculated and then converted to Cartesian coordinates.
      • printInfo(): Prints the current position of the celestial body.
  2. Main Function:
    • Celestial Bodies Initialization: Creates a list of CelestialBody objects representing planets in the solar system.
    • Simulation Loop:
      • Time Update: Advances the simulation time in discrete steps.
      • Position Update: Updates and prints the position of each celestial body based on the current time.
      • Advertisement

Usage

Exit mobile version