All pastes #607314 Raw Edit

Mirch

public cpp v1 · immutable
·published 2007-07-07 14:26 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_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 );}