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.


Messages - Erkoren

Pages: [1]
1
Hi!

Problem was solved once I put the implementation of the methods into the .cpp file and the class in the .h file.

When it didn't work, the Game.h file had the exact same code from above (minus the main), the Game.cpp was simply empty and the main file had the include and the main function.

I'm sorry to have bothered you something this simple. Anyways thanks for your help.


2
clang: error: linker command failed with exit code 1 (use -v to see invocation)

3
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