SFML community forums

Help => General => Topic started by: spagheta96 on June 29, 2013, 01:29:37 pm

Title: Help making multiple objects
Post by: spagheta96 on June 29, 2013, 01:29:37 pm
Hi, i'm new to SFML 2.0, and i would like to get some advice in making multiple shapes. I have tried to store them into an array using a struct type where i got my coords and alive bool
struct enemy
{
    float x;
    float y;
    bool alive = true;
    RectangleShape enemyShape;
};
........
enemy Ai[20];
    for(int i=1;i<=10;i++)
    {
        Ai[i].y = 200;
        Ai[i].x = i*50;
        Ai[i].enemyShape.setPosition(Ai[i].x,Ai[i].y);
        Ai[i].enemyShape.setFillColor(sf::Color(255, 100, 150, 255));
    }
.....
        for(int i=1;i<=10;i++)
          if(Ai[i].alive == true)
            window.draw(Ai[i].enemyShape);
 

I'm having problems as my screen doesn't output any of these shapes.  My screen is 800x600, none of the shapes go out of my screen.
Title: Re: Help making multiple objects
Post by: Geheim on June 29, 2013, 02:41:51 pm
Do you display the window?

And your shapes have no size?