Exemplo n.º 1
0
//The main update function
void Update()
{
	//Update gametime
	gameTime = glutGet(GLUT_ELAPSED_TIME);

	//Check how much time has passed between clock ticks, in milliseconds
	deltaT = (gameTime - prevgameTime);
	physicsLagTime += deltaT;

	//See how many physics simulations we need to go through
	//Ideally it should be 1, but this makes it so if there's lag anywhere, everything will still behave the same way
	while (physicsLagTime > fixedupdatetime)
	{
		//Perform a physics simulation
		MovePhysicsObject(GolfBall);
		WallCollision(GolfBall);

		int temp = FindCurrentTile(GolfBall, GolfBall.ObjectTile.TileID, getTiles());
		GolfBall.ObjectTile = getTiles()[temp - 1];

		physicsLagTime -= fixedupdatetime;
	}

	//Set the previous game time to the current game time
	prevgameTime = gameTime;
}
Exemplo n.º 2
0
///	更新
void CPatrollerMove::Update()
{
	auto player = (task->GetComponent<CPlayer>(CGameManager::PlayerName, 0)->transform.GetPos());
	auto scroll = (task->GetComponent<CScroll>(CGameManager::Scroll, 0)->transform.GetPos());
	auto patroller_pos = (task->GetComponent<CPatroller>(CEnemyManager::Patroller, 0)->transform.GetPos());
	auto patroller_scale = (task->GetComponent<CPatroller>(CEnemyManager::Patroller, 0)->transform.GetScale());

	Move(Direc(player, scroll, patroller_pos, patroller_scale));

	WallCollision();

	Stop();

	task->GetComponent<CPatroller>(CEnemyManager::Patroller, 0)->transform.Translate(velocity);
}