Skip to content
Snippets Groups Projects
Commit 30ee4521 authored by CARDILE VINCENT's avatar CARDILE VINCENT
Browse files

Merge branch 'bonus' of git.unistra.fr:vcardile/casse_briques into bonus

parents 211b3a12 8b7c536f
Branches
No related merge requests found
......@@ -2,6 +2,8 @@
#define __BONUS_HPP
#include <SDL.h>
#include <algorithm>
#include <random>
#include <memory>
#include "GridHandle.hpp"
#include "Draw.hpp"
......
......@@ -6,7 +6,10 @@ Bonus::Bonus(std::shared_ptr<Player> player ,std::shared_ptr<Ball> ball ,u_int16
this->ball = ball;
this->screenWidth = screenWidth;
this->screenHeight = screenHeight;
this->type = std::time(0) % 5;
std::random_device rd;
std::mt19937 gen(rd());
std::discrete_distribution<> dis({0.2 ,0.1, 0.2, 0.1, 0.4});
this->type = dis(gen);
this->updateBonusAttributes(x,y);
}
/**
......@@ -29,7 +32,6 @@ Bonus::moveBonus()
destroy = true;
else{
this->y += this->speed * this->directionY;
std::cout << "ICI" << std::endl;
destroy = false;
}
......@@ -108,7 +110,7 @@ void
Bonus::updateBonusAttributes(u_int32_t x , u_int32_t y)
{
this->radius = this->screenWidth/45;
this->speed = this->screenWidth/125;
this->speed = this->screenWidth/250;
this->directionY = 1;
this->x = x;
this->y = y;
......
......@@ -21,7 +21,7 @@ BrickRect::BrickRect(u_int32_t x, u_int32_t y, u_int16_t w, u_int16_t h, SDL_Col
this->setLife(life);
this->setId(id);
this->setType(type);
this->setHasItem(true);
this->setHasItem(rand() % 2);
}
/**
......
......@@ -191,7 +191,7 @@ Physics::collisionBonusPlayer(std::shared_ptr<Player> player, Bonus* bonus)
case 3:
if (bonus->getBall()->getRadius() - bonus->getScreenWidth()/150 < 0)
{
bonus->getBall()->setRadius(10);
bonus->getBall()->setRadius(20);
}
else
bonus->getBall()->setRadius(bonus->getBall()->getRadius() - bonus->getScreenWidth()/150);
......
......@@ -140,7 +140,6 @@ main(int argc, char** argv)
|| grid->getNbBricks() == 0) {
menu->gameOver();
}
SDL_RenderPresent(renderer);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment