Files
graphical_pong/include/graphics.hpp
T
2026-02-24 16:01:56 -05:00

46 lines
693 B
C++

#ifndef GRAPHICS_HPP
#define GRAPHICS_HPP
// Ball, Paddle
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/System/Vector2.hpp>
#include "globals.hpp"
struct Ball
{
Ball(sf::Vector2f pos) : velocity({ VELOCITY_X, VELOCITY_Y })
{
object.setSize({ (float)SIZE_X / 2, (float)SIZE_X / 2 });
object.setPosition(pos);
};
sf::Vector2f velocity;
sf::RectangleShape object;
};
struct Paddle
{
Paddle(sf::Vector2f pos)
{
rect.setSize({ SIZE_X, SIZE_Y });
rect.setPosition(pos);
};
int points;
sf::RectangleShape rect;
};
void
check_and_move();
void
handle_ball();
extern Paddle p1;
extern Paddle p2;
extern Ball ball;
#endif