2016-12-10 01:28:10 +00:00
|
|
|
/*********************************************************************************
|
|
|
|
* File Name : main.c
|
|
|
|
* Created By : klmp200
|
|
|
|
* Creation Date : [2016-12-10 01:06]
|
|
|
|
* Last Modified : [2016-12-10 01:07]
|
2016-12-10 20:11:46 +00:00
|
|
|
* Description :
|
2016-12-10 01:28:10 +00:00
|
|
|
**********************************************************************************/
|
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
#include <SDL2/SDL.h>
|
2016-12-10 01:28:10 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-12-13 14:12:55 +00:00
|
|
|
#include <matrix.h>
|
2016-12-28 20:39:42 +00:00
|
|
|
#include <pixel.h>
|
2016-12-10 20:11:46 +00:00
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
int main(){
|
|
|
|
Matrix m1 = CreateMatrix();
|
|
|
|
int rules[] = {2, 32, 8, 128};
|
2016-12-26 19:44:39 +00:00
|
|
|
Matrix m2;
|
2016-12-28 20:39:42 +00:00
|
|
|
BooleanMatrix bmatrix = CreateBooleanMatrix(300, 300);
|
|
|
|
int keypress = 0;
|
2016-12-27 00:24:27 +00:00
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
SCREEN screen;
|
|
|
|
screen.WIDTH = 300;
|
|
|
|
screen.HEIGHT = 300;
|
2016-12-13 14:55:42 +00:00
|
|
|
|
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0){
|
|
|
|
return 1;
|
|
|
|
}
|
2016-12-11 02:25:21 +00:00
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
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;
|
|
|
|
}
|
2016-12-26 19:44:39 +00:00
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
bmatrix = RandomizeBooleanMatrix(bmatrix);
|
|
|
|
m1 = newMatrix(bmatrix);
|
|
|
|
FreeBooleanMatrix(bmatrix);
|
2016-12-27 21:26:06 +00:00
|
|
|
|
2016-12-28 20:39:42 +00:00
|
|
|
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);
|
2016-12-26 19:44:39 +00:00
|
|
|
freeMatrix(m2);
|
2016-12-24 15:07:50 +00:00
|
|
|
|
2016-12-10 01:28:10 +00:00
|
|
|
return 0;
|
2016-12-10 20:11:46 +00:00
|
|
|
|
2016-12-10 01:28:10 +00:00
|
|
|
}
|