Ich arbeite zur Zeit mit SDL und c++ und möchte ein einfaches Bild in meiner Console darstellen.
Jetzt habe ich diesen einfachen Code hier, aber unten bei apply_surface(0,0,background,screen); sagt er das apply_surface falsch ist.
Error: Der Bezeichner ""apply_surface"" ist nicht definiert.
Code:
#include <SDL.h>
SDL_Surface *screen = NULL;
SDL_Surface *background = NULL;
bool gameRunning = true;
SDL_Event event;
void applay_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[])
{
//Init
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Apply image to screen",NULL);
//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);
}
if (event.type==SDL_QUIT)
return 0;
}






