1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2025-07-11 15:49:23 +00:00

Encapsulation de la SDL

This commit is contained in:
2016-12-28 23:59:43 +01:00
parent 430fb4d2c0
commit 23e82f4832
3 changed files with 65 additions and 32 deletions

View File

@ -17,42 +17,12 @@ int main(){
int rules[] = {2, 32, 8, 128};
Matrix m2;
BooleanMatrix bmatrix = CreateBooleanMatrix(300, 300);
int keypress = 0;
SCREEN screen;
screen.WIDTH = 300;
screen.HEIGHT = 300;
if (SDL_Init(SDL_INIT_VIDEO) < 0){
return 1;
}
SDL_CreateWindowAndRenderer(screen.WIDTH, screen.HEIGHT,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_SHOWN,
&(screen.window), &(screen.renderer));
if (screen.window == NULL || screen.renderer == NULL){
SDL_Quit();
return 1;
}
bmatrix = RandomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix);
FreeBooleanMatrix(bmatrix);
while (!keypress){
DisplayMatrixSDL(&screen, m1);
while(SDL_PollEvent(&screen.event)){
switch (screen.event.type){
case SDL_QUIT:
keypress = 1;
break;
case SDL_KEYDOWN:
keypress = 1;
break;
}
}
}
NewWindowFromMatrix(m1);
m2 = matrixFromRules(m1, 4, rules);
freeMatrix(m1);