1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-05 08:28:06 +00:00
LO27/matrixmain.c
2016-12-28 21:39:42 +01:00

64 lines
1.4 KiB
C

/*********************************************************************************
* File Name : main.c
* Created By : klmp200
* Creation Date : [2016-12-10 01:06]
* Last Modified : [2016-12-10 01:07]
* Description :
**********************************************************************************/
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <matrix.h>
#include <pixel.h>
int main(){
Matrix m1 = CreateMatrix();
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;
}
}
}
m2 = matrixFromRules(m1, 4, rules);
freeMatrix(m1);
freeMatrix(m2);
return 0;
}