//
// Player.cpp
//

// Engine includes.
#include "EventKeyboard.h"
#include "EventStep.h"
#include "GameManager.h"
#include "LogManager.h"
#include "WorldManager.h"

// Game includes.
#include "main.h"
#include "Player.h"

Player::Player() {
  setType(PLAYER_TYPE);
  setSprite(SPRITE_LABEL);
  setPosition(df::Vector(
			 (int) WM.getBoundary().getHorizontal()/2.0f,
			 (int) WM.getBoundary().getVertical()/2.0f));
  registerInterest(df::KEYBOARD_EVENT);
}

Player::~Player() {
}

int Player::eventHandler(const df::Event *p_e) {

  if (p_e->getType() == df::KEYBOARD_EVENT) {
    const df::EventKeyboard *p_ke =
      dynamic_cast <const df::EventKeyboard *> (p_e);
    switch(p_ke -> getKey()) {
    case df::Keyboard::ESCAPE:        // quit
    case df::Keyboard::Q:	      // quit
      if (p_ke -> getKeyboardAction() == df::KEY_PRESSED) {
	GM.setGameOver();
	return 1;
      }
    default:
      break;
    }
  }

  return 0;
}
