Wii SDL not showing ,png images? August 11, 2010 03:22AM | Registered: 14 years ago Posts: 29 |
player=SDL_LoadBMP("sd:/pngmove/data/graphics/player.bmp");
rwop=SDL_RWFromFile("sd:/pngmove/data/graphics/player.png", "rb"); player=IMG_Load(rwop);
player=IMG_Load("sd:/pngmove/data/graphics/player.png");
// normal includes #include#include #include #include #include // SDL includes #include #include // screen surface, the place where everything will get print onto SDL_Surface *screen = NULL; SDL_Surface *player = NULL; int playerX = 50; int playerY = 50; SDL_RWops *rwop; void init(){ // initialize SDL video. If there was an error SDL shows it on the screen if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError() ); SDL_Delay( 5000 ); exit(EXIT_FAILURE); } // button initialization WPAD_Init(); // make sure SDL cleans up before exit atexit(SDL_Quit); SDL_ShowCursor(SDL_DISABLE); // create a new window screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF); if ( !screen ) { fprintf(stderr, "Unable to set video: %s\n", SDL_GetError()); SDL_Delay( 5000 ); exit(EXIT_FAILURE); } } // this will be used in further lessons, not in lesson 1 void apply_surface ( int x, int y, SDL_Surface* source, SDL_Surface* destination ){ // make a temporary rectangle to hold the offsets SDL_Rect offset; // give the offsets to the rectangle offset.x = x; offset.y = y; // blit the surface SDL_BlitSurface( source, NULL, destination, &offset ); } void cleanup(){ // we have to quit SDL SDL_Quit(); exit(EXIT_SUCCESS); } int main(int argc, char** argv){ // main function. Always starts first // to stop the while loop bool done = false; // start init() function init(); fatInitDefault(); player=SDL_LoadBMP("sd:/pngmove/data/graphics/player.bmp"); if(player == NULL) printf("error!"); // this is the endless while loop until done = true while (!done) { // scans if a button was pressed WPAD_ScanPads(); u32 held = WPAD_ButtonsHeld(0); SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 33, 33)); apply_surface(playerX, playerY, player, screen); if(held){ if(WPAD_BUTTON_HOME){ done=true; SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); } if(WPAD_BUTTON_UP){ playerY-=2; } if(WPAD_BUTTON_DOWN){ playerY+=2; } if(WPAD_BUTTON_LEFT){ playerX-=2; } if(WPAD_BUTTON_RIGHT){ playerX+=2; } } // SDL_Flip refreshes the screen so it will show the updated screen SDL_Flip(screen); } // start cleanup() function cleanup(); return 0; }
Re: Wii SDL not showing ,png images? August 11, 2010 05:15AM | Admin Registered: 16 years ago Posts: 5,132 |
Re: Wii SDL not showing ,png images? August 11, 2010 07:48AM | Moderator Registered: 16 years ago Posts: 441 |
Re: Wii SDL not showing ,png images? August 11, 2010 11:27AM | Registered: 14 years ago Posts: 25 |
Re: Wii SDL not showing ,png images? August 11, 2010 06:44PM | Moderator Registered: 15 years ago Posts: 703 |
Re: Wii SDL not showing ,png images? August 11, 2010 07:01PM | Registered: 14 years ago Posts: 29 |
Re: Wii SDL not showing ,png images? August 11, 2010 10:41PM | Moderator Registered: 15 years ago Posts: 703 |
Re: Wii SDL not showing ,png images? August 12, 2010 09:38PM | Registered: 14 years ago Posts: 29 |
Re: Wii SDL not showing ,png images? August 13, 2010 08:14AM | Moderator Registered: 15 years ago Posts: 703 |
Re: Wii SDL not showing ,png images? August 13, 2010 10:03AM | Registered: 14 years ago Posts: 29 |
Re: Wii SDL not showing ,png images? August 15, 2010 01:38AM | Moderator Registered: 15 years ago Posts: 703 |
Re: Wii SDL not showing ,png images? August 16, 2010 12:18AM | Registered: 14 years ago Posts: 29 |