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

Author Topic: help with sfShape circleS  (Read 4551 times)

0 Members and 1 Guest are viewing this topic.

lucasben

  • Newbie
  • *
  • Posts: 3
    • View Profile
help with sfShape circleS
« 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:)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: help with sfShape circleS
« Reply #1 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.
Laurent Gomila - SFML developer

lucasben

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: help with sfShape circleS
« Reply #2 on: November 03, 2013, 11:38:25 pm »
Thanks,

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