Beispiel #1
0
void ProcessGravity1(PSpot* spotList,int length)
{
	int len = length;
	while (true)
	{
		double process = 1;
		int sp = -1;
		for(int i=0;i<len;i++)
		{
			if (spotList[i].mass > 0 && spotList[i].process < process)
			{
				process = spotList[i].process;
				sp = i;
			}
		}
		if (sp != -1)
		{
			CalcGravity(sp, spotList, &len);
		}
		else
		{
			break;
		}
	}
}
Beispiel #2
0
// Display objects and update them
void Display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if(gameState == MENU)
	{
		startButton->Update();
		startButton->Render();

		bezier->Update();
		bezier->Display();
	}
	else if(gameState == INSTRUCTIONS)
	{
		instructions->Update();
		instructions->Render();
	}
	else if(gameState == PAUSE)
	{
		pauseImage->Update();
		pauseImage->Render();

		resetButton->Update();
		resetButton->Render();

		quitButton->Update();
		quitButton->Render();
	}
	else if(gameState == PLAY)
	{
		CalcGravity();

		asteroidButton->Update();
		asteroidButton->Render();
	}
	else if(gameState == CREDITS)
	{
		credits->Update();
		credits->Render();
	}

	if(gameState == PLAY || gameState == PAUSE)
	{
        for (int i = 0; i < NUM_BODIES; i++)
        {
			if(gameState == PLAY)
			{
				//octree->performUpdate(bodies, octree);
                bodies[i]->Update();
			}

            bodies[i]->Render();
        }
	}

	glfwSwapBuffers(window);
}
Beispiel #3
0
void Object::GetNetForce(){
	std::vector<Object*>::iterator it;

	ZeroForce();

	for( it = AllObjects.begin(); it != AllObjects.end(); ++it ){
		if( *it != this ){
			force = force + CalcGravity(**it);
		}
	}
}
Beispiel #4
0
static bool
GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
{
	DWORD rand_val;

	if (matchWorld (solarSys, world, 0, 0))
	{
		/* Spathiwa's moon */
		if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES)
				&& StartSphereTracking (SPATHI_SHIP))
		{
			NotifyOthers (SPATHI_SHIP, IPNL_ALL_CLEAR);
			PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
			ReinitQueue (&GLOBAL (ip_group_q));
			assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);

			CloneShipFragment (SPATHI_SHIP, &GLOBAL (npc_built_ship_q),
					INFINITE_FLEET);

			SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
			GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
			InitCommunication (SPATHI_CONVERSATION);

			if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
			{
				GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
				ReinitQueue (&GLOBAL (npc_built_ship_q));
				GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
			}
			return true;
		}
		
		DoPlanetaryAnalysis (&solarSys->SysInfo, world);
		rand_val = RandomContext_GetSeed (SysGenRNG);

		solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;
		GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL, NULL);
		rand_val = RandomContext_GetSeed (SysGenRNG);

		solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
		GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL);

		solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;

		solarSys->SysInfo.PlanetInfo.Weather = 0;
		solarSys->SysInfo.PlanetInfo.Tectonics = 0;
		solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28;
		if (!GET_GAME_STATE (UMGAH_BROADCASTERS))
		{
			LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
			solarSys->PlanetSideFrame[1] =
					CaptureDrawable (LoadGraphic (UMGAH_BCS_MASK_PMAP_ANIM));
			solarSys->SysInfo.PlanetInfo.DiscoveryString =
					CaptureStringTable (LoadStringTable (UMGAH_BCS_STRTAB));
			if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES))
			{	// The first report talks extensively about Spathi
				// slave-shielding selves. If they never did so, the report
				// makes no sense, so use an alternate.
				solarSys->SysInfo.PlanetInfo.DiscoveryString =	
						SetAbsStringTableIndex (
						solarSys->SysInfo.PlanetInfo.DiscoveryString, 1);
			}
		}
		LoadPlanet (NULL);
		return true;
	}
	else if (matchWorld (solarSys, world, 0, MATCH_PLANET))
	{
		/* visiting Spathiwa */
		DoPlanetaryAnalysis (&solarSys->SysInfo, world);
		rand_val = RandomContext_GetSeed (SysGenRNG);

		solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val;
		GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL);
		rand_val = RandomContext_GetSeed (SysGenRNG);

		solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;

		solarSys->SysInfo.PlanetInfo.PlanetRadius = 120;
		solarSys->SysInfo.PlanetInfo.SurfaceGravity =
				CalcGravity (&solarSys->SysInfo.PlanetInfo);
		solarSys->SysInfo.PlanetInfo.Weather = 0;
		solarSys->SysInfo.PlanetInfo.Tectonics = 0;
		solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31;

		LoadPlanet (NULL);
		return true;
	}
	
	GenerateDefault_generateOrbital (solarSys, world);

	return true;
}
Beispiel #5
0
static void
generate_orbital (void)
{
	COUNT i;
	DWORD rand_val;

		/* Starbase */
	if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[2]
			&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
	{
		PutGroupInfo (0L, (BYTE)~0);
		ReinitQueue (&GLOBAL (npc_built_ship_q));

		battle_counter = 0;
		GLOBAL (CurrentActivity) |= START_ENCOUNTER;
		SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
		return;
	}

	rand_val = DoPlanetaryAnalysis (&pSolarSysState->SysInfo,
			pSolarSysState->pOrbitalDesc);
	if (rand_val)
	{
		pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] =
				rand_val;
		i = (COUNT)~0;
		rand_val = GenerateMineralDeposits (&pSolarSysState->SysInfo, &i);
	}

	if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])
	{
		i = pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc;
		switch (i)
		{
			case 0: /* MERCURY */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 98;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 38;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 3;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 2;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 59 * 240;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 165;
				break;
			case 1: /* VENUS */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 9000;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 95;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 95;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 177;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 243 * 240;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 457;
				break;
			case 2: /* EARTH */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = EARTH_ATMOSPHERE;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 100;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 100;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 23;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 240;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 22;
				break;
			case 3: /* MARS */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 1;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 72;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 53;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 24;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 246;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -53;
				break;
			case 4: /* JUPITER */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0xFFFF;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 24;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 1120;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 3;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 98;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -143;
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 520L / 100;
				break;
			case 5: /* SATURN */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0xFFFF;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 13;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 945;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 27;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 102;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -197;
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 952L / 100;
				break;
			case 6: /* URANUS */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0xFFFF;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 21;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 411;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 98;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 172;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -217;
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 1916L / 100;
				break;
			case 7: /* NEPTUNE */
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0xFFFF;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 28;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 396;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 30;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 7;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 182;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -229;
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 2999L / 100;
				break;
			case 8: /* PLUTO */
				if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
				{
					pSolarSysState->SysInfo.PlanetInfo.LanderFont =
							CaptureFont (
									LoadGraphic (LANDER_FONT)
									);
					pSolarSysState->PlanetSideFrame[1] =
							CaptureDrawable (
							LoadGraphic (SPAPLUTO_MASK_PMAP_ANIM)
							);
					pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
							CaptureStringTable (
									LoadStringTable (SPAPLUTO_STRTAB)
									);
				}

				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 33;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 18;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 119;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 1533;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -235;
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 3937L / 100;
				break;
		}

		pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity =
				CalcGravity (pSolarSysState->SysInfo.PlanetInfo.PlanetDensity,
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius);
		LoadPlanet (i == 2);
	}
	else
	{
		i = pSolarSysState->pOrbitalDesc->pPrevDesc
				- pSolarSysState->PlanetDesc;
		pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 0;
		pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 0;
		pSolarSysState->SysInfo.PlanetInfo.Weather = 0;
		switch (i)
		{
			case 2: /* moons of EARTH */
				pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val;

				if (!GET_GAME_STATE (MOONBASE_DESTROYED))
				{
					pSolarSysState->SysInfo.PlanetInfo.LanderFont =
							CaptureFont (
									LoadGraphic (LANDER_FONT)
									);
					pSolarSysState->PlanetSideFrame[1] =
							CaptureDrawable (
							LoadGraphic (MOONBASE_MASK_PMAP_ANIM)
							);
					pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
							CaptureStringTable (
									LoadStringTable (MOONBASE_STRTAB)
									);
				}
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 60;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
				pSolarSysState->SysInfo.PlanetInfo.AxialTilt = 0;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 240 * 29;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -18;
				break;
			case 4: /* moons of JUPITER */
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 520L / 100;
				switch (pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc)
				{
					case 0:
						pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 69;
						pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
						pSolarSysState->SysInfo.PlanetInfo.Tectonics = 3;
						pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 390;
						pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -163;
						break;
					case 1:
						pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 54;
						pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 25;
						pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
						pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 840;
						pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -161;
						break;
					case 2:
						pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 35;
						pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 41;
						pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
						pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 1728;
						pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -164;
						break;
					case 3:
						pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 35;
						pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 38;
						pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
						pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 4008;
						pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -167;
						break;
				}
				break;
			case 5: /* moons of SATURN */
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 952L / 100;
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 160;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 2;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 34;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 40;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 1;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 3816;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -178;
				break;
			case 7: /* moons of NEPTUNE */
				pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist = EARTH_RADIUS * 2999L / 100;
				pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = 10;
				pSolarSysState->SysInfo.PlanetInfo.Weather = 1;
				pSolarSysState->SysInfo.PlanetInfo.PlanetDensity = 95;
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius = 27;
				pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0;
				pSolarSysState->SysInfo.PlanetInfo.RotationPeriod = 4300;
				pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = -216;
				break;
		}

		pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity =
				CalcGravity (pSolarSysState->SysInfo.PlanetInfo.PlanetDensity,
				pSolarSysState->SysInfo.PlanetInfo.PlanetRadius);
		LoadPlanet (FALSE);
	}
}