The function draw a circle and a second counting arrow and redraw the circle every second, the parameter time hast to initialized outside the while loop.
void putpixel(SDL_Surface* screen, int x, int y)
{
Uint32 *pixel = (Uint32*)screen->pixels;
Uint32 *p = pixel + y*screen->pitch/4 + x;
*p = SDL_MapRGB(screen->format, 0x00, 0x64,0x00);
}
void DrawCircle(SDL_Surface* screen, float time)
{
for(int i = 0; i<=360; i++)
{
putpixel(screen, (200 + (100*cos(i))), (100 + (100*sin(i))));
}
for(int j = 0; j<=100; j++)
{
putpixel(screen, (200 + (j*cos(time))), (100 + (j*sin(time))));
}
Sleep(1000);
}
No comments:
Post a Comment