essais SDL
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
# Variable
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra
|
||||
CFLAGS = -Wall -Wextra $(shell pkg-config --cflags --libs sdl2)
|
||||
OBJ = main.o
|
||||
TARGET = sokoban
|
||||
|
||||
|
||||
52
main.c
52
main.c
@@ -1,7 +1,57 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_pixels.h>
|
||||
#include <SDL2/SDL_rect.h>
|
||||
#include <SDL2/SDL_render.h>
|
||||
#include <SDL2/SDL_surface.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("test\n");
|
||||
|
||||
SDL_Rect displayBounds;
|
||||
displayBounds.w = 800;
|
||||
displayBounds.h = 800;
|
||||
SDL_Window *window = SDL_CreateWindow("titre test",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
displayBounds.w, displayBounds.h,
|
||||
SDL_WINDOW_SHOWN);
|
||||
|
||||
int running = 1;
|
||||
SDL_Event event;
|
||||
while (running)
|
||||
{
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type ==SDL_QUIT)
|
||||
{
|
||||
running = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
|
||||
SDL_Rect rect;
|
||||
rect.x = 100;
|
||||
rect.y = 100;
|
||||
rect.h = 100;
|
||||
rect.w = 150;
|
||||
SDL_RenderDrawRect(renderer, &rect);
|
||||
rect.x = 300;
|
||||
rect.y = 300;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user