Here's the code:
Code:
#include <SDL/SDL.h>
SDL_Surface *screen = NULL;
SDL_Surface *background = NULL;
bool gameRunning = true;
SDL_Event event;
void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination)
{
SDL_Rect rect;
rect.x = x;
rect.y = y;
SDL_BlitSurface(source,NULL,destination,&rect);
}
int main(int argc, char* argv[])
{
//initialize
SDL_Init(SDL_INIT_VIDEO);
//load
screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
background = SDL_LoadBMP("background.bmp");
//game loop
while(gameRunning)
if(SDL_PollEvent(&event))
{
if(event.type == SDL_Quit)
{
gameRunning = false;
}
}
//apply surface
apply_surface(0,0,background,screen);
//update screen
SDL_Flip(screen);
SDL_Quit();
return 0;
}
This is a simple SDL program designed to show a selected bmp file when running. When I try to compile this program in Code::Blocks, I recieve one error which occurs at line 34 ( ON THIS POST IT WILL SHOW LINE 22), stating "error: ISO C++ forbids comparision between pointer and integer." And it's the only error.
Well, at line 34 is the code for the image to contionously loop until exit.
Code:
//game loop
while(gameRunning)
if(SDL_PollEvent(&event))
{
if(event.type == SDL_Quit)
{
gameRunning = false;
}
Any help would be GREATLY appreciated!
P.S. Even though it didn't compile, I went to the C++ files for code::blocks, found my program, and double clicked on its exe. file and it opened up for a split second, showing the bmp file I selected, and exited. So I know for sure everything works, but it's just the loop that is failing.