You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

32 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);
};