All pastes #346439 Raw Edit

Mirchiss

public cpp v1 · immutable
·published 2007-02-09 11:26 UTC
rendered paste body
#ifndef SDL_VALUE_H_1134123#define SDL_VALUE_H_1134123 //The headers#include "SDL/SDL.h" //Event structureSDL_Event event; //For ending programbool quit = false;     int mouse_x=0;int mouse_y=0; #ifndef SDLSIDEKICK_H_1123123#define SDLSIDEKICK_H_1123123 #include "SDL_Sidekick.h"#include <windows.h>#include <string>using namespace std; //Load image functionSDL_Surface *load_image( char filename [50] ){    //Temporary storage for 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 );       //If nothing went wrong in loading the image#    if( loadedImage != NULL )#    {#        //Create an optimized image#        optimizedImage = SDL_DisplayFormat( loadedImage );#       #        //Free the old image#        SDL_FreeSurface( loadedImage );#       #        //Map the color key#            Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 255, 0, 255);#           #            //Set all pixels of color R 0, G 0xFF, B 0xFF to be transparent#            SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey );#    }#    //Return the optimized image#    return optimizedImage;#}# #void apply_surface( 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 );#}# #int init_SDL()#{#   #  //Initialize all SDL subsystems#  if( SDL_Init( SDL_INIT_EVERYTHING) == -1 )#  {#    MessageBox(NULL,"ERROR","SDL has failed to init",MB_OK);#    return 0;   #  }#  //Set up the screen#  Screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );# #  //Set the window caption#  SDL_WM_SetCaption( "SQRT", NULL);# #  //If there was in error in setting up the screen#  if( Screen == NULL )#  {#    MessageBox(NULL,"ERROR","Error setting video mode",MB_OK);#    return 0;   #  }#}# # ##endif //The attributes of the screen#const int SCREEN_WIDTH = 640;#const int SCREEN_HEIGHT = 480;#const int SCREEN_BPP = 32;# #//surfaces#SDL_Surface *Screen = NULL;#SDL_Surface *Background = NULL;#SDL_Surface *Box = NULL;# ##endif