SFML community forums

Bindings - other languages => C => Topic started by: lucasben on November 03, 2013, 10:46:37 pm

Title: help with sfShape circleS
Post by: lucasben on November 03, 2013, 10:46:37 pm
hello :)
i'm a new user of SFML :) i have a question :)

this is a code (work fine) for print one (1) circle :

sfShape *cercle = sfShape_CreateCircle(20,20,10,blanc,1,gris);

sfRenderWindow_DrawShape(fenetre,cercle);

When i want create more circle ( depends a number by scanf) how to do  ?

i try that :

for(i=0;i<nombre;i++){
sfShape *cercle = sfShape_CreateCircle(20,20,10,blanc,1,gris);
}

for(i=0;i<nombre;i++){
sfRenderWindow_DrawShape(fenetre,cercle);
}
 

but doesn't work so i make a change like that :

for(i=0;i<nombre;i++){
sfShape *cercle = sfShape_CreateCircle(20,20,10,blanc,1,gris);
}

for(i=0;i<nombre;i++){
sfRenderWindow_DrawShape(fenetre,cercle);
}

but it's not working too.

sorry for my english and the name of variable.

thanks for your help:)
Title: Re: help with sfShape circleS
Post by: Laurent on November 03, 2013, 11:27:22 pm
You need an array.

sfShape** cercles;

cercles = (sfShape**)malloc(nombre * sizeof(sfShape*));

for(i=0;i<nombre;i++){
    cercles[i] = sfShape_CreateCircle(20,20,10,blanc,1,gris);
}

for(i=0;i<nombre;i++){
    sfRenderWindow_DrawShape(fenetre,cercles[i]);
}

This is really basic C stuff, you should learn the language before trying to make such complicated things.
Title: Re: help with sfShape circleS
Post by: lucasben on November 03, 2013, 11:38:25 pm
Thanks,

I trying this :)
and i will tell you.. :) Thx