rendered paste body#include <SDL/SDL.h>
#include <windows.h>
#include <stdlib.h>
/*
PLEASE NOTE: the program will require SDL.dll which is located in
dev-c++'s dll directory. You have to copy it to you
program's home directory or the path.
*/
/* The screen surface */
SDL_Surface *screen = NULL;
void Draw_poly (float X, float Y, char *Str )
{
float A=800;
float B=600;
SDL_Rect rect;
//int value = 150;
int iteration=0;
rect.x = (int)X;
rect.y = (int)Y;
rect.w = 1;
rect.h = 1;
X = X/A;
Y = Y/B;
//char Temp[100];
//sprintf(Temp,"X:%d Y:%d %:%d",rect.x,rect.y, (rect.y*100)/(480*100) );
//SDL_WM_SetCaption (Temp, NULL);
while( X < 2 && Y < 2)
{
//int Random = rand()%3;
iteration++;
if(Str[iteration] == 0)
{
X =X -Y;
Y = rect.y/B;
}
else if(Str[iteration] == 1)
{
X = X*X + X;
Y = Y*Y + Y;
}
else
{
X+Y;
}
if(iteration > 64) {break;}
}
//char Temp[100];
//sprintf(Temp,"iteration number: %i",iteration);
//SDL_WM_SetCaption (Temp, NULL);
//SDL_Delay(5);
SDL_FillRect (screen, &rect, SDL_MapRGB (screen->format, iteration*4, 0, 0));
return;
}
int main (int argc, char *argv[])
{
int done;
int i=0, j=0;
/* Initialize SDL */
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{
}
SDL_Rect BG;
BG.h = 800;
BG.w = 600;
BG.y=0;
BG.x=0;
/* Set 640x480 16-bits video mode */
screen = SDL_SetVideoMode (BG.h, BG.w, 24, SDL_SWSURFACE | SDL_DOUBLEBUF);
if (screen == NULL)
{
}
SDL_WM_SetCaption ("Mii Particle Simulation", NULL);
SDL_FillRect (screen, &BG , SDL_MapRGB (screen->format, 150, 0, 0));
done = 0;
while (!done)
{
SDL_Delay(2000);
char RandomString[64];
char Text[64];
int k=0;
while(k < 64)
{
RandomString[k]= rand()%3;
if(RandomString[k]==0) Text[k] = '0';
else if(RandomString[k]==1) Text[k] = '1';
else if(RandomString[k]==2) Text[k] = '2';
k++;
}
SDL_WM_SetCaption (Text, NULL);
SDL_Event event;
/* Check for events */
while (SDL_PollEvent (&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
//1024, 768
i=0;
while (i < BG.h && !done)
{
j=0;
while (j < BG.w && !done)
{
Draw_poly( j, i, RandomString);
j++;
}
i++;
//char Temp[100];
//sprintf(Temp,"%i",i);
//SDL_WM_SetCaption (Temp, NULL);
//SDL_Flip( screen);
}
//SDL_WM_SetCaption ("DONE", NULL);
SDL_Flip( screen);
}
return 0;
}