All pastes #607321 Raw Edit

Mirch

public cpp v1 · immutable
·published 2007-07-07 14:34 UTC
rendered paste body
//Mirchiss (C) - targh is noob//Using or copying this library makes you the ultimate noob since copying from Mirchiss is a CNU!/*Contains:  Var:    SDL_Event Event    bool Quit - true means user has quit*/#define SDL_Side_I_CPP#include "SDL/SDL.h"#include <string>SDL_Event Event;bool Quit = false;//Mirchiss (C) - targh is noob//Using or copying this library makes you the ultimate noob since copying from Mirchiss is a CNU!/*Contains:  Var:    -SDL_Surface Screen  Fun:    -Init_Base_SDL    -load_image  "Borrowed from Lazyfoo"    -apply_surface  "Borrowed from Lazyfoo"*/#define SDL_Side_G_CPP#include "SDL/SDL.h"#include <string>SDL_Surface *Screen = NULL;//Sets Up SDL and screen//returns 1 error and 0 on no errorint InitBaseSDL(int Screen_X, int Screen_Y,int Screen_Bit){    //Inits SDL    if (SDL_Init (SDL_INIT_VIDEO) < 0)        {       //Failed       return 1;    }    atexit (SDL_Quit);        //Sets_Screen    Screen = SDL_SetVideoMode (Screen_X, Screen_Y, Screen_Bit, SDL_SWSURFACE | SDL_DOUBLEBUF);    if (Screen == NULL)    {        //Failed        return 1;    }    return 0;}SDL_Surface *LoadImage( std::string filename ) {    //The image that's loaded    SDL_Surface* loadedImage = NULL;        //The optimized image that will be used    SDL_Surface* optimizedImage = NULL;        //Load the image    loadedImage = SDL_LoadBMP( filename.c_str() );        //If the image loaded    if( loadedImage != NULL )    {        //Create an optimized image        optimizedImage = SDL_DisplayFormat( loadedImage );                //Free the old image        SDL_FreeSurface( loadedImage );                //If the image was optimized just fine        if( optimizedImage != NULL )        {            //Map the color key            Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 255, 0, 255 );                        //Set all pixels of color RGB 255,0,255 to be transparent            SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey );        }    }        //Return the optimized image    return optimizedImage;}void ApplySurface( int X, int Y, SDL_Surface* Source, SDL_Surface* Destination ){    //Temporary rectangle to hold the offsets    SDL_Rect Offset;        //Get the offsets    Offset.x = X;    Offset.y = Y;        //Blit the surface    SDL_BlitSurface( Source, NULL, Destination, &Offset );}#include "SDL_Side_G.cpp"#include "SDL_Side_I.cpp"int main(int argc, char *argv[]){            if( InitBaseSDL(640,480,32) == 1)    {        //You failed at life        return 0;    }            //While the user hasn't quit    while( Quit == false )    {        //If there's an event to handle        if( SDL_PollEvent( &Event ) )        {            //Key Stuffs                        //If a key was pressed            if( Event.type == SDL_KEYDOWN )            {                //Set the proper message surface                switch( Event.key.keysym.sym )                {                    //case SDLK_UP: break;                   }            }                        else if( Event.type == SDL_KEYUP )            {                //Set the proper message surface                switch( Event.key.keysym.sym )                {                    //case SDLK_UP: break;                   }            }                        //Mouse Stuffs                        //mouse offsets              //event.button.x;              //event.button.y;                                        else if( Event.type == SDL_MOUSEMOTION )            {                            }                        else if( Event.type == SDL_MOUSEBUTTONDOWN )            {                if( Event.button.button == SDL_BUTTON_LEFT )                {                                    }                else if( Event.button.button == SDL_BUTTON_RIGHT )                {                                     }            }                        else if( Event.type == SDL_MOUSEBUTTONUP )            {                if( Event.button.button == SDL_BUTTON_LEFT )                {                                    }                else if( Event.button.button == SDL_BUTTON_RIGHT )                {                                     }            }            //Some Random Stuffs                        else if( Event.type == SDL_QUIT )            {                //Quit the program                Quit = true;            }        }    }              return 0;}