All pastes #824315 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-19 22:07 UTC
rendered paste body
#include <SDL/SDL.h>
#include <time.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.
 */

SDL_Surface *screen = NULL;

int Draw_poly (float X, float Y, char *Str ,int ScreenX,int ScreenY)
{
    float A=600;
    float B=600;
    SDL_Rect rect;
    int iteration=0;
    rect.x = ScreenX;
    rect.y = ScreenY;
    rect.w = 1;
    rect.h = 1;
    X = X/A;
    Y = Y/B;

    //Start of MAGIC
    while( X < 2 && Y < 2)
    { 
        iteration++;
        if(Str[iteration] == 0)
        { 
            int temp = X;  
            X =X -Y;
            Y = Y- temp;
        }
        else if(Str[iteration] == 1)
        {      
            X = X*X;
            X = 2*X;
            
            Y = Y*Y;
            Y = 2*Y;
        }
        else
        {
            int temp = X;
            X = X+Y;
            Y = temp+Y;
            
        }
        if(iteration > 32) {break;}    
    }
    //End of MAGIC

    SDL_FillRect (screen, &rect, SDL_MapRGB (screen->format,  iteration*8, 0, 0));
    return iteration;
}

int main (int argc, char *argv[])
{   
    int done;
    SDL_Event event;   
    int i=0, j=0;

    /* Initialize SDL */
    if (SDL_Init (SDL_INIT_VIDEO) < 0){/*Error here*/}

    SDL_Rect BG;   
    BG.h = 600; BG.w = 600; BG.y=0; BG.x=0;

    screen = SDL_SetVideoMode (BG.h, BG.w, 24, SDL_SWSURFACE | SDL_DOUBLEBUF);
    if (screen == NULL){/*Error here*/}
    
    SDL_WM_SetCaption ("Weird Draw - MiR", NULL);
    SDL_FillRect (screen, &BG , SDL_MapRGB (screen->format, 0, 0, 0));
    done = 0;
    
    //Setting up parameters for drawing
    char RandomString[32];
    int k=0;
    while(k < 32) { RandomString[k]= rand()%3; k++; }
    
    while (!done)
    { 
        //mutation shit
        int MutationSpeed = 3;
        k=0;
        while(k < MutationSpeed) { RandomString[ (rand()%29)+3 ] = rand()%3; k++; }
        
        /* Check for events */
        while (SDL_PollEvent (&event))
        {
            switch (event.type)
            {
                case SDL_KEYDOWN:
                    break;
                case SDL_QUIT:
                    done = 1;
                    break;
                default:
                    break;
            }
        }        
        //1024, 768 Draw to screen
        i=0;
        while (i < BG.h && !done)
        {
			j=0;	
            while (j < BG.w && !done) 
            {
                Draw_poly( j, i, RandomString, j, i); 
                j++; 
            } 
            i++;
        }
        SDL_Flip( screen);
    }
    return 0;
}