1
General / 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
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.
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);
{
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.