Skip to content
Snippets Groups Projects
Commit 06f087a3 authored by Arnaud Albiez's avatar Arnaud Albiez
Browse files

teste d'implementation du sdl2

parent 3bdbaaa8
No related merge requests found
...@@ -9,4 +9,9 @@ void new_display() ...@@ -9,4 +9,9 @@ void new_display()
void quit_display() void quit_display()
{ {
sdl2_quit(); sdl2_quit();
}
int pixel_zise()
{
} }
\ No newline at end of file
#include "grid.h" #include "grid.h"
#include "sdl2.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
...@@ -36,9 +37,12 @@ enum Event next_event() ...@@ -36,9 +37,12 @@ enum Event next_event()
int main(void) int main(void)
{ {
struct Grid *grid = init_level("./level1.txt"); struct Grid *grid = init_level("./level1.txt");
sdl_init();
bool run = true; bool run = true;
while (run) while (run)
{ {
printf("%d \n", size_block(grid));
void draw();
Affichage_grid(grid); Affichage_grid(grid);
if (win_condition(grid) == 1) if (win_condition(grid) == 1)
{ {
......
...@@ -29,3 +29,28 @@ void sdl_quit() { ...@@ -29,3 +29,28 @@ void sdl_quit() {
context.renderer = NULL; context.renderer = NULL;
SDL_Quit(); SDL_Quit();
} }
int size_block(struct Grid * grid)
{
return context.width / grid->column_number;
}
void draw()
{
for(int x = 0; x< context.width; x+=49)
{
for(int y = 0; y < context.height; y +=49)
{
SDL_Rect rect = { .x = x,
.y = y,
.w = 49,
.h = 49
};
SDL_SetRenderDrawColor(context.renderer, 255, y, x, 255);
SDL_RenderFillRect(context.renderer, &rect);
}
}
SDL_RenderPresent(context.renderer);
}
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "grid.h"
typedef struct SDLContext { typedef struct SDLContext {
SDL_Window *window; SDL_Window *window;
...@@ -25,3 +26,14 @@ void sdl_init(); ...@@ -25,3 +26,14 @@ void sdl_init();
* nettoie la variable global context * nettoie la variable global context
*/ */
void sdl_quit(); void sdl_quit();
/**
* Calcule la taille d'un block par rapport a la taille de la fenetrre
*/
int size_block(struct Grid * grid);
/**
* gestion de l'affichage du tableau
*/
void draw();
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment