mirror of
https://gitlab.com/klmp200/LO27.git
synced 2025-07-11 15:59:22 +00:00
Swag matrice en SDL
This commit is contained in:
79
matrixmain.c
79
matrixmain.c
@ -6,57 +6,58 @@
|
||||
* Description :
|
||||
**********************************************************************************/
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <matrix.h>
|
||||
#include <pixel.h>
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int Rule = 256;
|
||||
int N = 1;
|
||||
int rules[] = {1, 2};
|
||||
Matrix matrix = CreateMatrix();
|
||||
int main(){
|
||||
Matrix m1 = CreateMatrix();
|
||||
int rules[] = {2, 32, 8, 128};
|
||||
Matrix m2;
|
||||
Matrix m3;
|
||||
Matrix m4;
|
||||
BooleanMatrix bmatrix = CreateBooleanMatrix(5, 5);
|
||||
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);
|
||||
m3 = newMatrix(bmatrix);
|
||||
m1 = newMatrix(bmatrix);
|
||||
FreeBooleanMatrix(bmatrix);
|
||||
BasicPrintMatrix(m3);
|
||||
m4 = matrixFromRules(m3, 2, rules);
|
||||
BasicPrintMatrix(m4);
|
||||
freeMatrix(m4);
|
||||
freeMatrix(m3);
|
||||
|
||||
applyRules(matrix,Rule,N);
|
||||
matrix = SetMatrixDim(matrix,3,3);
|
||||
|
||||
BasicPrintMatrix(matrix);
|
||||
|
||||
SetCellValue(matrix,0,0,true);
|
||||
SetCellValue(matrix,0,1,true);
|
||||
SetCellValue(matrix,0,2,true);
|
||||
BasicPrintMatrix(matrix);
|
||||
|
||||
SetCellValue(matrix,0,0,false);
|
||||
SetCellValue(matrix,0,1,false);
|
||||
BasicPrintMatrix(matrix);
|
||||
|
||||
m2 = colSequenceOnMatrix(matrix, OR);
|
||||
BasicPrintMatrix(m2);
|
||||
freeMatrix(m2);
|
||||
m2 = rowSequenceOnMatrix(matrix, AND);
|
||||
BasicPrintMatrix(m2);
|
||||
|
||||
/*sumMatrix(matrix,m2);*/
|
||||
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);
|
||||
|
||||
freeMatrix(matrix);
|
||||
return 0;
|
||||
|
||||
}
|
||||
/* todo
|
||||
*modifier DeleteListContent avec sli
|
||||
*/
|
||||
|
Reference in New Issue
Block a user