Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Erkoren

Pages: [1]
1
Hi!

If I try to run this code from the SFML Game Development Book. I can run it if the class and the main() are in the same file but once I put the class in its own header file, which I include in the main file XCode won't let me compile. I'm on Mac OSX 10.10.

#include <SFML/Graphics.hpp>
class Game
{
public:
  Game();
  void run();
private:
  void processEvents();
  void update();
  void render();
private:
  sf::RenderWindow mWindow;
  sf::CircleShape  mPlayer;
};

Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application") , mPlayer()
{
  mPlayer.setRadius(40.f);
  mPlayer.setPosition(100.f, 100.f);
  mPlayer.setFillColor(sf::Color::Cyan);
}
void Game::run()
{
  while (mWindow.isOpen())
  {
    processEvents();
    update();
    render();
  }
}

void Game::processEvents()
{
  sf::Event event;
  while (mWindow.pollEvent(event))
  {
    if (event.type == sf::Event::Closed)
      mWindow.close();
  }
}

void Game::update()
{
 
}

void Game::render()
{
  mWindow.clear();
  mWindow.draw(mPlayer);
  mWindow.display();
}

int main()
{
  Game game;
  game.run();
}

Pages: [1]
anything