Ejemplo n.º 1
0
//==============================================================================
//
void MapEditor::OnLoop()
{
        // Move camera
        MoveCamera();

	// Check to make sure that the camera didn't move out of bounds - if so, change map view
	Camera::CameraControl.CheckBounds();

	// Change player character state
	Camera::CameraControl.AnimateCharacter();

	// De-spawn entities if too far from player or marked for despawning
	DeSpawnEntities();

	// Move entities and animate
	for(unsigned int i = 0; i < EntityList.size(); ++i) EntityList[i]->OnLoop();

	// Check for collision between player character and Entities
	CheckEntityCollisions();

	// Check for collision between bullets and enemies
	CheckBulletCollision();

	// Check to see if player is dead
	if(playerHealth < 1) Running = false;

	// Decide whether to spawn enemy
	if(numEnemies<20 && rand()%50<1) SpawnEnemy();

}
Ejemplo n.º 2
0
void CheckLoss() 
{
    // We call this function when the focus block is at the top of that 
    // game area. If the focus block is stuck now, the game is over. 
    if ( CheckEntityCollisions(g_FocusBlock, DOWN))
    {
        // Clear the old squares vector 
        for (int i=0; i<g_OldSquares.size(); i++)
        {
            delete g_OldSquares[i];
        }
        g_OldSquares.clear();

        // Pop all states 
        while (!g_StateStack.empty())
        {
            g_StateStack.pop();
        }

        // Push the losing state onto the stack 
        StateStruct lose;
        lose.StatePointer = GameLost;

        g_StateStack.push(lose);
    }
}
Ejemplo n.º 3
0
void Character::Move(void) {
  x += xVel;
  tileX = ((x + (w / 2)) / TILE_WIDTH);
  tileY = ((y + (h / 2)) / TILE_HEIGHT);

  if((x < 0) || (x + w) > levelWidth)     x -= xVel;
  if(CheckTileCollisions())               x -= xVel;
  if(CheckEntityCollisions())             x -= xVel;
  if(CheckCharacterCollisions())          x -= xVel;

  y += yVel;
  tileX = ((x + (w / 2)) / TILE_WIDTH);
  tileY = ((y + (h / 2)) / TILE_HEIGHT);

  if((y < 0) || (y + h) > levelHeight)    y -= yVel;
  if(CheckTileCollisions())               y -= yVel;
  if(CheckEntityCollisions())             y -= yVel;
  if(CheckCharacterCollisions())          y -= yVel;
}