diff --git a/GameOfLife/Makefile b/GameOfLife/Makefile deleted file mode 100644 index 7a37dccc5fa59a8272d8e92a2494d76748d19625..0000000000000000000000000000000000000000 --- a/GameOfLife/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CC=gcc - -LDFLAG=$(shell sdl2-config --cflags --libs) -lm -lSDL2_ttf -D_REENTRANT -lSDL2_image -pthread -CFLAG=-Wall $(shell sdl2-config --cflags --libs) - -EXEC=run -SRC=$(wildcard src/*.c) -OBJ=$(SRC:.c=.o) - -all:$(EXEC) - -$(EXEC):$(OBJ) - $(CC) -o $@ $^ $(LDFLAG) - mv $^ bin/ - -%.o:%.c - $(CC) -o $@ -c $< $(CFLAG) - -.PHONY:clean - -clean: - rm -rf bin/*.o - rm -rf $(EXEC) diff --git a/GameOfLife/Res/Roboto-Black.ttf b/GameOfLife/Res/Roboto-Black.ttf deleted file mode 100644 index 86ec2b29ba56a3d6c45f1a8584ff3780fa70c60e..0000000000000000000000000000000000000000 Binary files a/GameOfLife/Res/Roboto-Black.ttf and /dev/null differ diff --git a/GameOfLife/run b/GameOfLife/run deleted file mode 100755 index d11da59171258d7f1c8166ccb05a40a51ea0de24..0000000000000000000000000000000000000000 Binary files a/GameOfLife/run and /dev/null differ diff --git a/GameOfLife/src/gest_event.c b/GameOfLife/src/gest_event.c deleted file mode 100644 index 9e8a6771b66da4db7a408b61ea7f09398a7578b7..0000000000000000000000000000000000000000 --- a/GameOfLife/src/gest_event.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "gest_event.h" - - -void gestMenu(){ - SDL_Event event; - while (SDL_PollEvent(&event)){ - switch(event.type) - { - case SDL_QUIT: - running = 0; - break; - - case SDL_KEYUP: - switch (event.key.keysym.sym) - { - case SDLK_x: - running = 0; - continue; - - default: - continue; - } - break; - - default: - continue; - } - } - SDL_Delay(5); -} - - -void *EventLoop(void *arg){ - while(running){ - switch(game_state){ - case MENU : gestMenu();break; - //case GAME : gestGame();break; - default:printf("game state fault");break; - } - } - return NULL; -} \ No newline at end of file diff --git a/GameOfLife/src/gest_event.h b/GameOfLife/src/gest_event.h deleted file mode 100644 index c5c76e37ddffc777052540d5c6668199b00b39c2..0000000000000000000000000000000000000000 --- a/GameOfLife/src/gest_event.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _GEST_EVENT_H_ -#define _GEST_EVENT_H_ - - -#include "main.h" -#include "utility.h" -#include "render.h" - -void *EventLoop(void *arg); - -#endif \ No newline at end of file diff --git a/GameOfLife/src/main.c b/GameOfLife/src/main.c deleted file mode 100644 index f1f6e6291f52548794adde7caebcdd06deee6bc7..0000000000000000000000000000000000000000 --- a/GameOfLife/src/main.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "main.h" - -int running; -int game_state; - - -int main(){ - running = 1; - game_state = MENU; - - MainLoop(); - -} \ No newline at end of file diff --git a/GameOfLife/src/main.h b/GameOfLife/src/main.h deleted file mode 100644 index 5c447e4c20cca1547b9e2c7724636c7b9bb9eba8..0000000000000000000000000000000000000000 --- a/GameOfLife/src/main.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _MAIN_HEADER_ -#define _MAIN_HEADER_ - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <unistd.h> - -#include <SDL2/SDL.h> -#include <SDL2/SDL_image.h> -#include <SDL2/SDL_ttf.h> - -#include <pthread.h> - -#include "render.h" -#include "utility.h" -#include "gest_event.h" - - -#define MENU 0 -#define GAME 1 - -extern int running; -extern int game_state; - - -#endif \ No newline at end of file diff --git a/GameOfLife/src/render.c b/GameOfLife/src/render.c deleted file mode 100644 index 19d0c8ef04433b3fd8f1066d9e20e4f2bc58fe76..0000000000000000000000000000000000000000 --- a/GameOfLife/src/render.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "render.h" - -SDL_Window *window; -SDL_Renderer *renderer; - -TTF_Font *RobotoFont; - -void CreateWindow(){ - SDL_DisplayMode ScreenDimension; - - if (SDL_Init(SDL_INIT_VIDEO) != 0){ - printf("Couldn't create window."); - exit(EXIT_FAILURE); - } - - SDL_GetCurrentDisplayMode(0, &ScreenDimension); - - window = SDL_CreateWindow("Game Of Life", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, ScreenDimension.w, ScreenDimension.h, SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP); - - if (window == NULL){ - printf("Couldn't create window"); - exit(EXIT_FAILURE); - } - - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE | SDL_RENDERER_PRESENTVSYNC); - - if (renderer == NULL){ - printf("Couldn't create renderer."); - exit(EXIT_FAILURE); - } - - if (TTF_Init() == -1) - { - exit(EXIT_FAILURE); - } - - RobotoFont = TTF_OpenFont("Res/Roboto-Black.ttf", 50); - -} - - -void MainLoop(){ - CreateWindow(); - - unsigned int a = SDL_GetTicks(); - unsigned int b = SDL_GetTicks(); - double delta = 0; - - pthread_t eventThread; - if (pthread_create(&eventThread, NULL, EventLoop, NULL) != 0){ - printf("Couldn't create thread."); - exit(EXIT_FAILURE); - } - - while (running){ - a = SDL_GetTicks(); - delta = (a - b) / 1000.0; - if (delta > 1/FPS_TO_GET){ - b = a; - switch (game_state){ - case MENU: - //Menu(); - break; - case GAME: - //Game(); - break; - } - } - else { - // fait dormir le thread pour garder des ressources - usleep(1000 * (1/FPS_TO_GET - delta)); - } - - } -} \ No newline at end of file diff --git a/GameOfLife/src/render.h b/GameOfLife/src/render.h deleted file mode 100644 index 4ea989392a7a206f5bf98f03fb1e8a139e0fdc3e..0000000000000000000000000000000000000000 --- a/GameOfLife/src/render.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _RENDER_H_ -#define _RENDER_H_ - -#include "main.h" -#include "utility.h" -#include "gest_event.h" - -#define FPS_TO_GET 60 - -extern SDL_Window *window; -extern SDL_Renderer *renderer; - - -void MainLoop(); - -#endif \ No newline at end of file diff --git a/GameOfLife/src/utility.c b/GameOfLife/src/utility.c deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/GameOfLife/src/utility.h b/GameOfLife/src/utility.h deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000