Ok first off I have a feeling that what ever I did is ridiculously stupid but I can't seem to figure it out.
Any way I am new to C++ so thanks for teaching me.
I declared a public typedef struct
in a header file.
I use it in the header file but never use it in my main. For some reason the file with my main is throwing a error that some aspects of it are never defined but I don't define them because I don't use the,
there's a good bit more but its irrelevant
Main.cpp just has sfml code that opens a window and runs a few voids bassed on user input. Those voids do use the structure but never Main.cpp. Can someone help me fix the error.
Thanks sorry if the answer is easy and this is a waste of time.
My Simplified SFML Code
typedef struct KeyStruct {
static sf::Image Img;
static sf::Texture Tex;
static sf::Sprite Sprite;
}Key;
static void DrawKey(string key)
{
sf::Clock clock;
//Declair Key
Key Key;
Key.Img.loadFromFile("Assets/Images/A.png");
if (key == "A")
Key.Img.loadFromFile("Assets/Images/A.png");
else if (key == "D")//ect
Key.Tex.loadFromImage(Key.Img);
Key.Sprite.setTexture(Key.Tex);
//Open Window
sf::RenderWindow window(sf::VideoMode(Key.Img.getSize().x, Key.Img.getSize().y, 32), "Key", sf::Style::None);
//Handle Events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
//While Open Loop
while (window.isOpen())
{
window.clear(sf::Color::Transparent);
window.draw(Key.Sprite);
window.display();
}
}
Main
int main()
{
sf::RenderWindow window(sf::VideoMode(100, 100, 32), "Main Window", sf::Style::None);
while (window.isOpen())
{
sf::Event event;
//Handle Events
while (window.pollEvent(event))
{
//Key Presses
if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::A)
MakeKey::DrawKey("A");
else if (event.key.code == sf::Keyboard::D)
MakeKey::DrawKey("D");//ect
}
//Close
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Transparent);
window.display();
}
return EXIT_SUCCESS;
}