17 constexpr
double gridW = 9.0;
18 constexpr
double gridH = 7.0;
24 void World::checkCollisions() {
26 ball->bounceIfPossible<
Wall>(walls);
28 vector<int> collisions = std::move(ball->bounceIfPossible<
Block>(blocks));
30 int blocksDeleted = 0;
31 for(
auto c: collisions) {
43 if(playerSpeedBlock) {
47 blocks.erase(blocks.begin() + c - blocksDeleted);
52 ball->bounceIfPossible(player);
55 void World::update() {
59 for(
auto &b: blocks) {
69 if(ball->getPosition().y > gridH || ball->getPosition().y < 0 ||
70 ball->getPosition().x > gridW || ball->getPosition().x < 0) {
77 void World::draw()
const {
79 for(
const auto &b: blocks) {
84 for(
const auto &w: walls) {
89 void World::addBlock(unique_ptr<arkanoid::Block> block) {
90 blocks.push_back(std::move(block));
93 void World::addWall(unique_ptr<arkanoid::Wall> wall) {
94 walls.push_back(std::move(wall));
97 void World::setBall(unique_ptr<arkanoid::Ball> newBall) {
98 ball = std::move(newBall);
101 void World::setPlayer(unique_ptr<arkanoid::Player> newPlayer) {
102 player = std::move(newPlayer);
105 bool World::levelEnded()
const {
106 return blocks.size() == 0;
109 void World::reset() {
A "special" Block: when hit with a Ball, speed up or slow down the Player.
void effectBall(unique_ptr< Ball > &ball) const
void effectBall(unique_ptr< Ball > &ball) const
A "special" Block: when hit with a Ball, make the Ball invisible.
void effectPlayer(unique_ptr< Player > &player) const
The Block in the Arkanoid game, can be hit and destroyed by the Player.
The Wall (left/right/top side) in the Arkanoid game that represents a single "square".
All the game logic of the Arkanoid game.
A "special" Block: when hit with a Ball, speed up or slow down the Ball.