Sign in to follow this  
SleepySlowpoke

SFML Directory or File not found

Recommended Posts

I'm starting off and making my first video game, as of now I'm working on the starting screen and title screen. I've made a GameScreen, SplashScreen, and finally a ScreenManager file.
 
The ScreenManager file itself is coded as so (Reminder: I just started this a few hours ago and don't entirely know what I'm doing so don't judge).
 

#ifndef SCREENMANAGER_H
#define SCREENMANAGER_H
#include<string>
#include<iostream>
#include"GameScreen.h"
#include"SplashScreen.h"

#define ScreenWidth 1600
#define ScreenHeight 900
class ScreenManager
{
    public:
        ~ScreenManager();
        static ScreenManager &GetInstance();
        void Initialize();
        void LoadContent();
        void Update();
        void Draw(sf:: RenderWindow &Window)

        virtual ~ScreenManager();
    protected:
    private:
        GameScreen *currentScreen, *newScreen;
        ScreenManager();
        ScreenManager(ScreenManager const&);
        void operator=(ScreenManager const&);
};

#endif // SCREENMANAGER_H

My main file is as so
 

#include <iostream>
#include<SFML/Graphics.hpp>
#include<ScreenManager.hpp>

using namespace std;

int main()
{
sf::RenderWindow Window(sf::VideoMode(ScreenWidth, ScreenHeight, 32), "Dash")



while(Window.isOpen())
{
sf::Event event
if(Window.GetEvent(event))
{
if(event.Type == sf::Event::Closed || event.key.code == sf::Key::Escape)
Window.close();
}
}

return 0;
}

I get an error with #include<ScreenManage.h> saying that there is no such file or directory when compiling.

 

I've checked the name and don't really have enough knowledge or experience to fix the problem by myself, google as well hasn't really helped so if anyone could help me or direct me to a tutorial on how to fix this I would greatly appreciate it.

Share this post


Link to post
Share on other sites

The problem isn't related to SFML. I think you should #include "ScreenManager.h" in your main instead of the cpp cause (even if it didn't pop error)-logically that's your class definition and where creating an object should apply.

 

Hope I helped and goodluck with your game =]

 

//Haven't used it yet but FLARE (rpg) game engine could be helpful in case you're a novice like me, it seems clean and awesome. smile.png

Edited by rijvgt

Share this post


Link to post
Share on other sites

The problem isn't related to SFML. I think you should #include "ScreenManager.h" in your main instead of the cpp cause (even if it didn't pop error)-logically that's your class definition and where creating an object should apply.

 

Hope I helped and goodluck with your game =]

 

//Haven't used it yet but FLARE (rpg) game engine could be helpful in case you're a novice like me, it seems clean and awesome. smile.png

 

I changed it to <ScreenManager.h> but it still gives me the same error

Share this post


Link to post
Share on other sites

 

The problem isn't related to SFML. I think you should #include "ScreenManager.h" in your main instead of the cpp cause (even if it didn't pop error)-logically that's your class definition and where creating an object should apply.

 

Hope I helped and goodluck with your game =]

 

//Haven't used it yet but FLARE (rpg) game engine could be helpful in case you're a novice like me, it seems clean and awesome. smile.png

 

I changed it to <ScreenManager.h> but it still gives me the same error

 

Mhh you havent posted the file where you implement the screenmanager... but you can see examples from the flare engine on what you are trying to achieve. Even if it has nothing to do with the fact that you're both using SFML, they seem to be following C++ standards.

 

For example you can see the #include "GameSwitcher.h" in the main https://github.com/clintbellanger/flare-engine/blob/master/src/main.cpp

 

And how it is implemented:

https://github.com/clintbellanger/flare-engine/blob/master/src/GameSwitcher.h

https://github.com/clintbellanger/flare-engine/blob/master/src/GameSwitcher.cpp

Edited by rijvgt

Share this post


Link to post
Share on other sites

Change it to
#include "ScreenManager.h"

^As I recall, all of your personal includes(files that you create yourself) should be surrounded by quotes and not angle brackets. At least that's the rule I follow and it seems to work. As Spyderzone said I believe this is the issue and not xxx.h vs xxx.hpp

Share this post


Link to post
Share on other sites

^As I recall, all of your personal includes(files that you create yourself) should be surrounded by quotes and not angle brackets. At least that's the rule I follow and it seems to work. As Spyderzone said I believe this is the issue and not xxx.h vs xxx.hpp


That is not true in general. While it is true that the big three C++ compilers (MSVC, gcc, Clang) use a similar heuristic for "" #includes (add the including file's directory to the search paths), this is not actually enforced by the standard (the standard allows adding an implementation defined heuristic to "" compared to <> but does never qualify what to do). So, writing really standard compliant code would require setting the correct include directory search paths in the build system.

That is something I in general prefer to follow in non-trivial projects.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this