Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help making multiple objects  (Read 1246 times)

0 Members and 1 Guest are viewing this topic.

spagheta96

  • Newbie
  • *
  • Posts: 1
    • View Profile
Help making multiple objects
« 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.

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Help making multiple objects
« Reply #1 on: June 29, 2013, 02:41:51 pm »
Do you display the window?

And your shapes have no size?
« Last Edit: June 29, 2013, 02:43:33 pm by Geheim »
Failing to succeed does not mean failing to progress!

 

anything