1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2025-07-11 16:09:24 +00:00

Ajout d'une gui et correction de l'apply rules

This commit is contained in:
2016-12-29 03:14:07 +01:00
parent b6db74e7ee
commit 8edc9fcfd1
5 changed files with 129 additions and 27 deletions

View File

@ -10,31 +10,52 @@
#include <stdio.h>
#include <stdlib.h>
#include <matrix.h>
#include <pixel.h>
#include <gui.h>
int main(){
int Rule34 = 3;
int rule;
int times;
bool useSDL;
bool cont = true;
int col;
int row;
Matrix m1;
Matrix m2;
BooleanMatrix bmatrix = CreateBooleanMatrix(5, 5);
BooleanMatrix bmatrix;
useSDL = YesOrNo("Do you want to use SDL library for matrix display ?");
printf("A random matrix will be generated\n");
printf("Enter the number of columns of this matrix\n");
col = SafeNumberInput(1, 30000);
printf("Enter the number of rows of this matrix\n");
row = SafeNumberInput(1, 30000);
bmatrix = CreateBooleanMatrix(col, row);
bmatrix = RandomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix);
FreeBooleanMatrix(bmatrix);
NewWindowFromMatrix(m1);
DisplayMatrixGUI(m1, useSDL);
m2 = applyRules(m1,Rule34,3);
while (cont){
printf("What rule do you want to apply to this matrix ?\n");
rule = SafeNumberInput(1, 481);
printf("How many times do you want the rule to be applied ?\n");
times = SafeNumberInput(1, 100000);
m2 = applyRules(m1,rule,times);
freeMatrix(m1);
NewWindowFromMatrix(m2);
DisplayMatrixGUI(m2, useSDL);
cont = YesOrNo("Do you want to apply other rules on this matrix ?");
m1 = m2;
}
freeMatrix(m1);
freeMatrix(m2);
return 0;
}