Exemple #1
0
// ------------------------------------------------------------------
// Name : resizeWindow
// ------------------------------------------------------------------
void DisplayEngine::resizeWindow()
{
    //if (m_bLookAtMode)
    //{
    //  m_dScreenRatio = 16.0f / 9.0f;
    //  double hMargin = 0;
    //  double vMargin = 0;
    //  if (m_pClientParams->screenXSize > m_dScreenRatio * (double) m_pClientParams->screenYSize)
    //    vMargin = ((double) m_pClientParams->screenXSize - m_dScreenRatio * (double) m_pClientParams->screenYSize) / 2;
    //  else if (m_pClientParams->screenYSize > (double) m_pClientParams->screenXSize / m_dScreenRatio)
    //    hMargin = ((double) m_pClientParams->screenYSize - (double) m_pClientParams->screenXSize / m_dScreenRatio) / 2;
    //	glViewport(vMargin, hMargin, m_pClientParams->screenXSize - vMargin, m_pClientParams->screenYSize - hMargin);
    //}
    //else
    //{
    glViewport(0, 0, m_pClientParams->screenXSize, m_pClientParams->screenYSize);
    m_dScreenRatio = BASE_WIDTH / BASE_HEIGHT;
//    m_dScreenRatio = (double) m_pClientParams->screenXSize / (double) m_pClientParams->screenYSize;
    //}
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glFrustum(-m_dScreenRatio, m_dScreenRatio, 1.0f, -1.0f, NEARPLANE, FARPLANE);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    moveCameraTo(m_f3CamPos);
}
/*This is the update function
double dt - This is the amount of time in seconds since the previous call was made

Game logic should be done here.
Such as collision checks, determining the position of your game characters, status updates, etc
If there are any calls to write to the console here, then you are doing it wrong.
If your game has multiple states, you should determine the current state, and call the relevant function here.*/
void update(double dt)
{
    //Gets the delta time
    elapsedTime += dt;
    deltaTime = dt;
	
	//Updates the world grid. Only do it once per level. Set bupdateWorldGrid to true whenever you load a new level.
	//It will turn itself off after it update once.
	if (bupdateWorldGrid == true) {
		updateWorldGrid(g_levelNumber);
		bupdateWorldGrid = false;
	}

	//Updates the position of the camera.
	moveCameraTo();

	//Checks if you should change states or do something else with the game, e.g. pause, exit.
    processUserInput(); 
    
	//Sets the position of the teleporters in the level and check if the player can teleport through them in this frame.
	setItemsInLevel();

	//Updates the position of the monsters and if the player is killed by them.
	monsterUpdate();

	//Moves the character, collision detection, physics, etc
	moveCharacter();

	//Updates the position of the box. Ensure that this is called AFTER moveCharacter to prevent glitches.
	boxesUpdate();

	//Checks if the player has walked over an item.
	detectItemsCollision();
	
	//Update the bullet(?)
	bulletUpdate();

}
Exemple #3
0
// ------------------------------------------------------------------
// Name : setLookAtMode
// ------------------------------------------------------------------
void DisplayEngine::setLookAtMode(bool bLookAt)
{
    m_bLookAtMode = bLookAt;
    moveCameraTo(m_f3CamPos);
//  resizeWindow();
}
Exemple #4
0
// ------------------------------------------------------------------
// Name : moveCameraBy
// ------------------------------------------------------------------
void DisplayEngine::moveCameraBy(Coords3D d3Delta)
{
    moveCameraTo(m_f3CamPos + d3Delta);
}