/******************************************************************** File: Player.cc Author: Dana Vrajitoru Description: The class handling the player. Project: A sprite moving through a maze application. Last updated: February 10, 2017. ********************************************************************/ #include "glheader.h" #include "Player.h" // constructor Player::Player() { } // initializes the display lists of components void Player::draw() { // assume that you draw the object at position 0 here } // displays the player on screen void Player::display() { glPushMatrix(); glTranslatef(posX, 0, posY); // whatever else you are drawing glPopMatrix(); } // places the player at a given position on the board void Player::teleport(float x, float y) { posX = x; posY = y; } // check for collision with the walls and other elements in the maze // return true if there is a collision that cannot be resolved by removing // the cell in the maze, such as for food bool Player::checkCollision() { return false; } // move the player horizontally, negative value for left, positive for right // this function should check for collision with the maze cells and if there // is collision with the walls, it should not make the move void Player::moveHorizontal(float val) { posX += val; if (checkCollision()) // are we running into a wall? posX -= val; // go back } // move the player vertically, negative value for left, positive for right // this function should check for collision with the maze cells and if there // is collision with the walls, it should not make the move void Player::moveVertical(float val) { }