Now that I've got to mess with it again, I've got another question.
I want to make different classes to manage different game functions and link all the separate classes to a primary class to manage the other classes.
Such as this:
I have the same code as posted before, but an added Sprite Manager Class, to load the images. Then I link it with the Application Class, and I load the image, but my Spr_Mgr is undeclared.
#include <SFML/Graphics.hpp
//////////////////////
//Declare Sprite Class
//////////////////////
class SpriteManager
{
private:
sf::Image Image1;
public:
void LoadPicture();
};
////////////////////////
//Sprite Class Functions
////////////////////////
void SpriteManager::LoadPicture()
{
if( !Image1.LoadFromFile("Image1.png") ){}
sf::Sprite Image_1(Image1);
Image_1.SetPosition(150,150);
}
////////////////////
//Declare Game Class
////////////////////
class Application
{
private:
sf::RenderWindow Window;
sf::String Hello;
void DrawStuff();
public:
Application();
void Run();
SpriteManager Spr_Mgr(); //Create Sprite Manager for Application
};
//////////////////////
//Game Class Functions
//////////////////////
Application::Application()
{
Window.Create(sf::VideoMode(400, 600), "Title");
Spr_Mgr.LoadPictures(); //Load Pictures with Sprite Manager - ERROR, Spr_Mgr not recognized!!
Hello.SetText("Hello!");
Hello.SetColor(sf::Color(0, 128, 128));
Hello.SetPosition(100.f, 100.f);
Hello.SetSize(30.f);
}
void Application::DrawStuff()
{
Window.Draw(Image_1); //Display the Picture
Window.Draw(Hello);
}
void Application::Run()
{
while (Window.IsOpened())
{
sf::Event Event;
while (Window.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Window.Close();
}
DrawStuff();
Window.Display();
}
}
///////////
//Main Game
///////////
int main()
{
Application Game;
Game.Run();
return 0;
}
///END///
Any help is appreciated