All pastes #262129 Raw Edit

Anonymous

public cpp v1 · immutable
#262129 ·published 2006-11-30 05:08 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <SDL/SDL.h>#include <windows.h>#include <math.h>#define SCREEN_WIDTH 800#define SCREEN_HEIGHT 600#define SCREEN_DEPTH 16#define SCALE 10const int radius = 200;int angle = 0;template <class T>T _X(T x) {	return (T)((SCREEN_WIDTH / 2) + (x));}template <class T>T _Y(T y) {	return (T)((SCREEN_HEIGHT / 2) - (y));}template <class T>T degtorad(T deg) {	return (T)(deg * 3.141592654 / 180);}/* The screen surface */SDL_Surface *screen = NULL;void draw (){	angle++;	SDL_Rect box;	box.w = 40;	box.h = 40;	double cx, sy;	cx = cos(degtorad(angle));	sy = sin(degtorad(angle));	box.x = (int)_X(cx) * radius;	box.y = (int)_Y(sy) * radius;		//SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));	SDL_FillRect(screen, &box, SDL_MapRGB(screen->format, 255, 0, 0));    /* Make sure everything is displayed on screen */    SDL_Flip (screen);    /* Don't run too fast */    SDL_Delay (1);}int main (int argc, char *argv[]){    char *msg;    int done;    /* Initialize SDL */    if (SDL_Init (SDL_INIT_VIDEO) < 0)    {        sprintf (msg, "Couldn't initialize SDL: %s\n", SDL_GetError ());        MessageBox (0, msg, "Error", MB_ICONHAND);         free (msg);        exit (1);    }    atexit (SDL_Quit);    /* Set 640x480 16-bits video mode */    screen = SDL_SetVideoMode (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE | SDL_DOUBLEBUF);    if (screen == NULL)    {        sprintf (msg, "Couldn't set 640x480x16 video mode: %s\n",          SDL_GetError ());        MessageBox (0, msg, "Error", MB_ICONHAND);         free (msg);        exit (2);    }    SDL_WM_SetCaption ("Circulator Rotation around a Vertex", NULL);    done = 0;    while (!done)    {        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;            }        }        /* Draw to screen */        draw ();    }    return 0;}