31 lines
775 B
C++
31 lines
775 B
C++
#pragma once
|
|
#include <SFML/Window.hpp>
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
class BrickGrid;
|
|
class Paddle;
|
|
|
|
struct Ball
|
|
{
|
|
inline static const float initialVelocity = 700;
|
|
inline static const sf::Color color {246, 213, 92};
|
|
float radius;
|
|
sf::Vector2f position;
|
|
sf::Vector2f velocity;
|
|
|
|
Ball(float radius, sf::Vector2f position, sf::Vector2f velocity);
|
|
|
|
void update(float dt);
|
|
|
|
void draw(sf::RenderWindow& window);
|
|
|
|
std::pair<sf::Vector2f, bool> findClosestPoint(const sf::FloatRect& rect) const;
|
|
|
|
bool handleRectCollision(const sf::FloatRect& rect);
|
|
|
|
void handleWallsCollision(sf::FloatRect boundary);
|
|
|
|
std::pair<int, int> handleBrickGridCollision(const BrickGrid& brickGrid);
|
|
|
|
void handlePaddleCollision(const Paddle& paddle);
|
|
};
|