#include #include #include #include #include const int scrwidth = 1024, scrheight = 720 , scrdepth = 32; struct lcar {Sint16 x0, y0;}; struct car {Sint16 x0, y0;}; void draw_garbage(SDL_Surface * screen, Sint16 x, Sint16 y) {int x1=x; Draw_FillRect(screen, x+60, y-30, 120, 40, SDL_MapRGB(screen->format,101, 67, 33)); return ; } void draw_car (SDL_Surface * screen, Sint16 x) {struct car CAR; CAR.x0=x; CAR.y0=500; Draw_FillCircle(screen, CAR.x0+50, CAR.y0+120, 35, SDL_MapRGB(screen->format,0,0,0)); Draw_FillCircle(screen, CAR.x0+220, CAR.y0+120, 35, SDL_MapRGB(screen->format,0,0,0)); Draw_FillRect(screen, CAR.x0, CAR.y0, 250, 100, SDL_MapRGB(screen->format,255,0, 0)); Draw_FillRect(screen, CAR.x0+250, CAR.y0-20, 80, 120, SDL_MapRGB(screen->format,50,50,50)); } void draw_little_car (SDL_Surface * screen, Sint16 x, Sint16 yp) {struct lcar LCAR; LCAR.x0=x; LCAR.y0=550; Draw_FillCircle(screen, LCAR.x0+30, LCAR.y0+50, 20, SDL_MapRGB(screen->format,0,0,0)); Draw_FillCircle(screen, LCAR.x0+120, LCAR.y0+50, 20, SDL_MapRGB(screen->format,0,0,0)); Draw_FillRect(screen, LCAR.x0+150, LCAR.y0-50, 10, 100, SDL_MapRGB(screen->format,0,0, 255)); Draw_FillRect(screen, LCAR.x0+150, LCAR.y0-50+yp, 200, 10, SDL_MapRGB(screen->format,0,0, 255)); Draw_FillRect(screen, LCAR.x0, LCAR.y0, 150, 50, SDL_MapRGB(screen->format,0,0, 255)); } int main(int argc, char** argv){ SDL_Surface *screen, *image; SDL_Event event; int run=1,flag=1; Sint16 xcar=50, xpaz=50, xgar=50, xost=600, xostp=430; /* Начальная инициализация */ if(SDL_Init(SDL_INIT_VIDEO)<0){ printf("Unable to init SDL: %s\n", SDL_GetError()); return 1; } screen = SDL_SetVideoMode(scrwidth, scrheight, scrdepth, SDL_ANYFORMAT); if(!screen){ printf("Unable to set 1024x720 video: %s\n", SDL_GetError()); return 1; } image=SDL_LoadBMP("image.bmp"); // Грузим картинку while(run) { /* Проверяем действия пользователя */ while(SDL_PollEvent(&event)) { switch (event.type){ case SDL_QUIT: run = 0;break; case SDL_KEYDOWN:{ if (event.key.keysym.sym == SDLK_ESCAPE) run = 0; break; } } } /* Проверяем действия пользователя */ /* while(SDL_PollEvent(&event)) { switch (event.type){ case SDL_QUIT: break; case SDL_KEYDOWN:{ if (event.key.keysym.sym == SDLK_ESCAPE) break; } } }*/ /* Рисуем фон */ SDL_BlitSurface(image, NULL, screen, NULL); //первый этап if(xcar50)) { draw_car(screen, xcar); draw_garbage(screen, xgar, 500); xgar--; draw_little_car(screen, xpaz, 0); xpaz--; //draw_garbage(screen, xgar, 500); //xgar--; } if((flag==0) &&(xpaz==50)) { draw_car(screen, xcar); draw_garbage(screen, xgar, 500); draw_little_car(screen, xpaz, 0); //draw_garbage(screen, xgar, 500); } SDL_Delay(1); SDL_Flip(screen); } SDL_FreeSurface(image); SDL_FreeSurface(screen); SDL_Quit(); return 0; }