Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDLSprite???

Started by NES_Boy Feb 26, 2003 at 3:35 AM 0 replies 250+ views
Original Post
NES_Boy
NES_Boy
Hi!! I wondfer if some one could tell me whats wrong with this code: #include <SDL.h> #include "SDLSprite.h" #include "SDLSpriteList.h" #include <iostream.h> int xpos = 97, ypos = 384; SDL_Surface *screen; SDLSprite *robot; SDL_Surface *bg; int InitImages() { bg = SDL_LoadBMP("bg.bmp"); return 0; } //Fuktinon för att rita sprites void sprite() { SDLSprite * robot = new SDLSprite("robot.bmp", 200, 200, 1); robot->SetColorKey(0, 255, 0); robot->InitShadow(6, 6, 125, 70); robot->SetPos( 155, 250 ); robot->SetFrame(1) ; } //Funktion för att starta SDL void SDL() { SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO); atexit(SDL_Quit); screen=SDL_SetVideoMode (800, 600, 32, SDL_FULLSCREEN|SDL_HWPALETTE|SDL_DOUBLEBUF); SDL_ShowCursor(0); } int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); void DrawIMG(SDL_Surface *img, int x, int y) { SDL_Rect dest; dest.y = y; dest.x = x; SDL_BlitSurface(img, NULL, screen, &dest); } void DrawBG() { DrawIMG(bg, 0, 0); } void DrawScene() { SDL_Flip(screen); } int main(int argc, char *argv []) { SDL(); InitImages(); DrawBG(); sprite(); robot->Draw(screen, 0, 0); DrawScene(); int done = 0; while(done == 0) { SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) { done = 1; } if(event.type == SDL_KEYDOWN) { if(event.key.keysym.sym == SDLK_ESCAPE) { done=1; } } } } return 0; } The problem is that the window just comes and goes directly. plz help me NES_Boy The One And Only
NES_Boy The One And Only

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.