Ejemplo n.º 1
0
void RenderCallback()
{
	// Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ProcessCameraKeys();
	SetupCamera();

	UpdateEmitterPosition();

	if (gScene && !bPause)
	{
		GetPhysicsResults();
		ProcessInputs();
		StartPhysics();
	}

	// Display scene
	RenderActors(bShadows);

	RenderFluid();

	if (bForceMode)
		DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
	else
		DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
	gForceVec = NxVec3(0,0,0);

	if (bEmitterWireframe)
	{
		NxMat34 fluidEmitterMat = fluidEmitter->getGlobalPose();
		NxVec3 fluidEmitterPos, fluidEmitterDir;
		fluidEmitterPos = fluidEmitterMat.t;
		fluidEmitterMat.M.getColumn(2,fluidEmitterDir);

		DrawArrow(fluidEmitterPos, fluidEmitterPos + fluidEmitterDir, NxVec3(0,0,1)); 
		DrawEllipse(20, fluidEmitter->getGlobalPose(), NxVec3(0.5,0,0.5), fluidEmitter->getDimensionX(), fluidEmitter->getDimensionY());
	}

	if (!bPause)
	{
		if (gDeltaTime < 10)  gTotalTime += gDeltaTime;
	}

	// Render HUD
	hud.Render();

	glFlush();
	glutSwapBuffers();
}
Ejemplo n.º 2
0
Monster::Monster(int positionX, int positionY) : MOVEMENT_TIME_DELAY(5.0f), MONSTER_LIFE_TIME(200.0f)
{
	position.x = static_cast<float>(positionX);
	position.y = static_cast<float>(positionY);

	walkingSpeed = 1;
	movementTimer = 0.0f;
	lifeTimer = 0.0f;

	// Zero the audio emitter.
	SecureZeroMemory(&audioEmitter, sizeof(X3DAUDIO_EMITTER));

	// Update emitter position.
	UpdateEmitterPosition();
	audioEmitter.Position.y = 0;
	audioEmitter.ChannelCount = 1;
} // End of Constructor
Ejemplo n.º 3
0
void Monster::ProcessTurn(const float dt, const D3DXVECTOR2 playerPosition, const X3DAUDIO_LISTENER* playerListener)
{
	// Check if the monster is still alive.
	if (CheckIfAlive(dt))
	{
		UpdateEmitterPosition();
		ApplySoundEffects(playerListener);

		// If time to move
		if (TimerCheck(movementTimer, dt, MOVEMENT_TIME_DELAY))
			ProcessMovement(playerPosition);
	}
	else
	{
		// The monster is dead, set alive value to false and play death sound.
		alive = false;
		deathSound->Play();
	}
} // End of ProcessTurn function.