Source Example: Displaying a background

Nokturn, 09. Oct. 2002

This source example shows how easy it is to load an image and blit it to the whole screen, using GameBlade. Please download the distribution EXBackground20021007 which includes all the files, including a sample background. Just run "make" and see :)
Requirements for this are: SDL, SDL_image, SDL_mixer (www.libsdl.org) and a C++ compiler (like GCC). If you are using VisualC++, you will need an additional setup.

#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>

#include "GameBlade.h"

GB_Background Title;

int main( void )
{
GB_PrintGameInfo();
GB_SetupSDL_Video();

Title.GB_LoadBackground( "gfx/back.jpg" );
Title.GB_ShowBackground();

while( !GameQuitSignal )
{
GB_FilterEvents_BASIC();
SDL_Flip( Screen );
SDL_Delay( 50 );
}

GB_PrintGameQuitInfo();
SDL_Quit();
}

Screenshot:

SourceForge Logo