#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "SDL.h"
#include "SDL_draw.h"
#define N 20// Количесво снежинок
/* Константные выражения для размера экрана */
const int scrwidth = 1024, scrheight = 720 , scrdepth = 32;
int main(int argc, char** argv){
SDL_Surface *screen, *image;
SDL_Event event;
struct snowflake SN[N];
int run=1;
/* Начальная инициализация */
SDL_WM_SetCaption( "SNOWfLAKES",0); // Название окна
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("fon.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;
}
}
}
/* Рисуем фон */
SDL_BlitSurface(image, NULL, screen, NULL);
/* Тут Рисует */
SDL_Delay(1);
SDL_Flip(screen);
}
/* Удаляем поверхности перед выходом */
SDL_FreeSurface(image);
SDL_FreeSurface(screen);
SDL_Quit();
return 0;
}