Hi all! TBH I'm a newbie when it comes to C++, also SFML is the first attempt at a C++ framework for games (have used LibGDX and Love2D before thought). Have been using them for 2 days
just recently.
Then, right now I'm making a Pong clone, and while trying to make custom classes, right now Game, Ball and Paddle, I try to forward declare classes from SFML, but the thing is I don't exactly know how to
. As an example here is the PongGame class definition and implementation:
PongGame.hpp
#ifndef PONGGAME_H
#define PONGGAME_H
// INCLUDES
#include "PongBall.hpp"
#include "PongPaddle.hpp"
//FORWARD DECLARE
class Event;
class Time;
class RenderWindow;
// CLASS
class PongGame
{
private:
/* fields */
PongBall ball;
PongPaddle paddle_left;
PongPaddle paddle_right;
public:
PongGame();
void processEvent(const sf::Event& event);
void update(const sf::Time& elapsed);
void draw(const sf::RenderWindow& window);
};
#endif
PongGame.cpp:
#include "PongGame.hpp"
#include <SFML/System/Time.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
PongGame::PongGame()
{
this->ball = PongBall();
this->paddle_left = PongPaddle(/*PongPaddle::Player::Left*/);
this->paddle_right = PongPaddle(/*PongPaddle::Player::Right*/);
}
void PongGame::processEvent(const sf::Event& event)
{
}
void PongGame::update(const sf::Time& elapsed)
{
}
void PongGame::draw(const sf::RenderWindow& window)
{
}
Thanks for any help!
P.S: And yep... I regret preceding each custom class with the word Pong.