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 - Jacob309

Pages: [1]
1
General / Re: Define structure with a sf::RenderWindow in it.
« on: March 21, 2020, 10:40:06 pm »
Holy fuck i'm a dumbass.  Anyway I have one more question this time hopefully its less stupid. So i'm trying to get multiple windows open at once and im trying to do that by having a void that functions like the while loop would. It has a for loop that goes through a array of my structure key.

Key
    typedef struct KeyStruct {
        sf::Image Img;
        sf::Texture Tex;
        sf::Sprite Sprite;
        sf::RenderWindow* Window;//pointer because it is uncopyable
    }NewKey;

This is my void
 
   static void StepWindows()
    {
        sf::Clock clock;
        int i;
        for (i = 0; i > KeyArray.size(); i++)
            MakeTopWindow(KeyArray[i].Window);
            setShape(KeyArray[i].Window, KeyArray[i].Img);
            KeyArray[i].Window.clear(sf::Color::Transparent);
            KeyArray[i].Window.draw(KeyArray[i].Sprite);
            KeyArray[i].Window.display();
            if (clock.getElapsedTime().asMicroseconds() > 1000)
            {
                KeyArray[i].Window.setPosition(MakeKey::Gravity(KeyArray[i].Window, KeyArray[i]));
            }
    }

When Ever I try to use KeyArray.Window it says expression must have class type. How do I fix this?

2
Window / Re: Render Window Attempting to Reference deleted function
« on: March 21, 2020, 09:49:43 pm »
If I use pointers when I try to use .clear or .draw or any of those they get a error saying that it doesn't have that operator. I think there is a possibility i am declaring a am declaring or using the pointer wrong.

If there is a way to do something like push_back that doesn't copy that would be great.

3
Window / Render Window Attempting to Reference deleted function
« on: March 21, 2020, 04:08:17 am »
So I know from other posts that this error occurs when you try to copy something uncountable. Problem is obviously that when I push back the window it copys it. Theoretically the solution to that is a vector of refrances. When I make it a vector of refrances and obviously push back refrances files xmemory and vector freak out, give >20 errors all saying that pointers to refrances are illegal.  How show should I go about fixing this or what is a different method to use.

If this doesn't work I am trying to make a void that spawns a new window and adds it to the vector. The vector runs in a void and functions like the while loop in just one window. I run the void from the while loop of a main window.

The Struct I've made
typedef struct KeyStruct {
    sf::Image Img;
    sf::Texture Tex;
    sf::Sprite Sprite;
    //there is more but its not necessary
}NewKey;

Step Windows
static vector <sf::RenderWindow> WindowArray;
static vector <NewKey> KeyArray;
static void StepWindows()
{
    sf::Clock clock;
    int i;
    for (i = 0; i > WindowArray.size(); i++)
        MakeTopWindow(WindowArray[i].getSystemHandle());
    WindowArray[i].clear(sf::Color::Transparent);
    WindowArray[i].draw(KeyArray[i].Sprite);
    WindowArray[i].display();
    if (clock.getElapsedTime().asMicroseconds() > 1000)
    {
        WindowArray[i].setPosition(MakeKey::Gravity(WindowArray[i], KeyArray[i]));
    }
}

Draw Key
static void DrawKey(string input)
{
    //Declair Key
    NewKey Key;
    NewKey& KeyRef = Key;
    if (input == "A")
        Key.Img.loadFromFile("Assets/Images/A.png");
    else if (input == "D")
        Key.Img.loadFromFile("Assets/Images/D.png");
    //ect
    Key.Tex.loadFromImage(Key.Img);
    Key.Sprite.setTexture(Key.Tex);

    sf::RenderWindow window(sf::VideoMode(Key.Img.getSize().x, Key.Img.getSize().y, 32), "Key", sf::Style::None);
    sf::RenderWindow& windowRef = window;
    window.setPosition(MakeKey::RandSpawn(Key.Img));
    MakeKey::WindowArray.push_back(windowRef);
    MakeKey::KeyArray.push_back(KeyRef);
}

And My Main
int main()
{
    sf::RenderWindow window(sf::VideoMode(100, 100, 32), "Main Window", sf::Style::None);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            MakeKey::MakeTopWindow(window.getSystemHandle());
            //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();
        }
        MakeKey::MakeTopWindow(window.getSystemHandle());
        MakeKey::StepWindows();
    }
    return EXIT_SUCCESS;
}

Thanks for the help

4
General / Define structure with a sf::RenderWindow in it.
« on: March 20, 2020, 11:36:37 pm »
So im trying to define a structure that has a render window in it. Having this is not necessary to my program but I would like to learn how to do this if its possible because I am obviously trying to do it wrong.

My code:
    typedef struct KeyWindowStruct {
        sf::RenderWindow;
    }KeyWindow;

Thanks for your help.

Pages: [1]