Я только начинаю изучать SDL, и я обнаружил, что если я инициализирую переменную SDL_Rect, SDL_Delay не работает.затем, если я установил одно из значений в SDL_Rect, изображение даже не отображается (или пауза).я не понимаюя получил этот код из учебника Lazyfoo и в настоящее время просто возиться с ним
#include <SDL/SDL.h>
#include <iostream>
using namespace std;
int main( int argc, char* args[] ){
int width = 512;
int height = 512;
//The images
SDL_Surface* source = NULL;
SDL_Surface* screen = NULL;
//Start SDL
//SDL_Init( SDL_INIT_EVERYTHING );
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) {
return 1;
}
//Set up screen
screen = SDL_SetVideoMode( width, height, 24, SDL_SWSURFACE );
//Load imagec
source = SDL_LoadBMP( "image.bmp");
//Apply image to screen
SDL_Rect * hello; //here is where it messes up the program
//for(int a = 0; a < width; a++){ // i was trying to make the image move around the screen/window
//hello -> x = 0;
//now -> w = 200;
//now -> h = 200;
//for(int b = 0; b < height; b++){
//now -> y = 0;
//SDL_WM_SetCaption( "ajsncnsc", NULL );
SDL_BlitSurface( source, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
SDL_Delay( 2000 );
// }
//}
//Free the loaded image
SDL_FreeSurface( source );
//Quit SDL
SDL_Quit();
return 0;
}