C++ Project 2016-2017: Arkanoid
player.cpp
Go to the documentation of this file.
1 
3 #include "player.h"
4 #include "../../math/vector2D.h"
5 
6 #include <iostream>
7 
8 using namespace std;
9 
10 namespace arkanoid {
11 
12  Player::Player() {}
13 
14  Player::Player(double x, double y, double newSpeed, pair<double, double> size) : velocity(newSpeed, 0), speed(newSpeed), origin(x, y), originalSpeed(newSpeed), notMoving(true), Entity(x, y, size) {}
15 
17 
18  void Player::update() {}
19 
20  void Player::draw() const {}
21 
22  void Player::speedUp(double factor) {
23  if(speedUpDuration == 0) {
24  // Prevent multiple speed ups
25  speed *= factor;
26  speedUpDuration = 180; // 180 frames = 3 seconds
27  }
28  }
29 
30  void Player::reset() {
31  speed = originalSpeed;
32  position = origin;
33  notMoving = true;
34  speedUpDuration = 0;
35  }
36 
37 }
void update()
Definition: player.cpp:18
virtual void reset()
Definition: player.cpp:30
Vector2D origin
The initial position of the Player.
Definition: player.h:21
void speedUp(double factor)
Definition: player.cpp:22
Vector2D position
The current position of the Entity (in the 9x7 grid).
Definition: entity.h:17
int speedUpDuration
In frames.
Definition: player.h:25
void draw() const
Definition: player.cpp:20
All the game logic of the Arkanoid game.
Definition: ball.cpp:15
An Entity represents an "object" (like Player, Ball, Block, ...) in the game World.
Definition: entity.h:15