Commit 0396bc92 authored by Coralie Pierre's avatar Coralie Pierre
Browse files

Petite animation, des carrés apparaissent en diagonale, leur couleur s'éclaircie à chaque fois

parent 5ae13a6a
#CC : le compilateur à utiliser
CC=gcc
#CFLAGS : les options de compilation
CFLAGS=$(shell sdl2-config --cflags) -Wall -Wextra -g -DVERBOSE
# les librairies à utiliser
LIBS=$(shell sdl2-config --libs)
#LDFLAGS : les options d'édition de lien
LDFLAGS=
#lieu où se trouve les sources :
SRC=./src/
#les fichiers objets
OBJ=$(SRC)main.o\
$(SRC)windowMaker.o
out : $(OBJ)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(SRC)%.o: $(SRC)%.c $(SRC)%.h
$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@
clean:
rm -rf $(SRC)*.o out
#CC : le compilateur à utiliser
CC=gcc
#CFLAGS : les options de compilation
CFLAGS=$(shell sdl2-config --cflags) -Wall -Wextra -g -DVERBOSE
# les librairies à utiliser
LIBS=$(shell sdl2-config --libs) -lSDL2_image
#LDFLAGS : les options d'édition de lien
LDFLAGS=
#lieu où se trouve les sources :
SRC=./src/
#les fichiers objets
OBJ=$(SRC)main.o\
$(SRC)image.o\
$(SRC)windowMaker.o
out : $(OBJ)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(SRC)%.o: $(SRC)%.c $(SRC)%.h
$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@
clean:
rm -rf $(SRC)*.o out
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <SDL2/SDL.h>
#include "windowMaker.h"
int main () {
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
if (0 == init(&window, &renderer, 1024, 780)) {
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.h = 1024;
rect.w = 780;
int i = 0;
Uint8 a = 255;
Uint8 r = 0;
Uint8 g = 0;
Uint8 b = 0;
SDL_RenderFillRect(renderer, &rect);
SDL_RenderPresent(renderer);
while (i < 5) {
rect.x = 250 + 100 * i;
rect.y = 150 + 100 * i;
rect.h = 200 - 20 * i;
rect.w = 200 - 20 * i;
b += 50;
SDL_SetRenderDrawColor(renderer, r, g, b, a);
SDL_RenderFillRect(renderer, &rect);
SDL_RenderPresent(renderer);
sleep(1);
i++;
}
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "windowMaker.h"
#include "image.h"
int main () {
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
if (0 == init(&window, &renderer, 1024, 780)) {
SDL_Texture *img = loadPicture("textures/bleu.jpg", renderer);
printPicture(renderer, img, -1, -1);
sleep(3);
SDL_DestroyTexture(img);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int init(SDL_Window **window, SDL_Renderer **renderer, int w, int h) {
/* Fonction qui initialise la fenetre */
// init video
if (0 != SDL_Init(SDL_INIT_VIDEO)) {
fprintf(stderr, "Error SDL_Init : %s", SDL_GetError());
return -1;
}
// init fenetre
*window = SDL_CreateWindow("Titre fenetre", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_SHOWN);
if (NULL == window) {
fprintf(stderr, "Error SDL_CreateWindow : %s", SDL_GetError());
return -1;
}
// init renderer
*renderer = SDL_CreateRenderer(*window, -1, SDL_RENDERER_ACCELERATED || SDL_RENDERER_PRESENTVSYNC);
if (NULL == renderer) {
fprintf(stderr, "Error SDL_CreateRenderer : %s", SDL_GetError());
return -1;
}
// init icon
SDL_Surface *icon = NULL;
icon = SDL_LoadBMP("textures/icone.bmp");
if (NULL == icon) {
fprintf(stderr, "Error SDL_LoadBMP : %s", SDL_GetError());
return -1;
}
SDL_SetWindowIcon(*window, icon);
return 0;
}
#ifndef WINDOWMAKER_H_
#define WINDOWMAKER_H_
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int init(SDL_Window **window, SDL_Renderer **renderer, int w, int h);
#endif
\ No newline at end of file
Supports Markdown
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