Commit fad2f54f authored by AntoineJJ's avatar AntoineJJ
Browse files

Ajout d'une fonction reset, d'un bouton echap et correction du makefile

parent 3cdd3a87
......@@ -6,9 +6,6 @@ OBJ = build/main.o build/window.o build/score.o build/asteroid.o build/vaisseau.
prog : $(OBJ)
$(CC) $^ -o $@ $(SDLC)
build/main.o : src/main.c src/window.h src/score.h
$(CC) $(CFLAGS) -c $<
build/window.o : src/window.c src/window.h
$(CC) $(CFLAGS) -c -o $@ $<
......@@ -21,7 +18,7 @@ build/asteroid.o:src/asteroid.c
build/vaisseau.o:src/vaisseau.c
$(CC) -c -o $@ $<
build/main.o:src/main.c src/vaisseau.h src/asteroid.h
build/main.o:src/main.c src/vaisseau.h src/asteroid.h src/window.h src/score.h
$(CC) -c -o $@ $<
clean :
......
......@@ -45,7 +45,7 @@ int main(){
int deplace_gauche = 0,
deplace_droite = 0;
create_sdl(&window, &renderer, &font, "chef_d_oeuvre", "./images/SubZER0.ttf", 1, 1);
create_sdl(&window, &renderer, &font, "chef_d_oeuvre", "./images/SubZER0.ttf");
//initialisation des textures
text_vaisseau = IMG_LoadTexture(renderer, "./images/redfighter5.png");
......@@ -126,8 +126,21 @@ int main(){
case SDLK_LEFT:
deplace_gauche = 1;
break;
case SDLK_r:
vaisseau = init_vaisseau(window, text_vaisseau);
for(i=0; i<NBR_ASTEROIDS; i++){
tab_asteroids[i] = creer_asteroid((i*100)%1100, -rand()%2500);
}
over=0;
pause=0;
score=0;
break;
case SDLK_ESCAPE:
fin_programme = 1;
break;
default:
break;
break;
}
break;
......@@ -156,7 +169,7 @@ int main(){
//gestion des textures
afficher_fond(text_fond, window, renderer);
for(int i=0; i<NBR_ASTEROIDS; i++){
for(i=0; i<NBR_ASTEROIDS; i++){
if(!pause) deplacer_ast(&tab_asteroids[i], 3, 720);
afficher_ast(text_asteroid, tab_asteroids[i], renderer);
}
......
......@@ -32,7 +32,7 @@ void end_sdl(char ok, // fin nor
}
}
void create_sdl(SDL_Window** window, SDL_Renderer** renderer, TTF_Font** font, char* window_title, char* font_path, float w_size, float h_size) {
void create_sdl(SDL_Window** window, SDL_Renderer** renderer, TTF_Font** font, char* window_title, char* font_path) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) end_sdl(0, "ERROR SDL INIT", *window, *renderer);
*window = SDL_CreateWindow(window_title,
......
......@@ -2,6 +2,6 @@
#define WINDOW_H
void end_sdl(char, char const*, SDL_Window*, SDL_Renderer*);
void create_sdl(SDL_Window**, SDL_Renderer**, TTF_Font**, char*, char*, float, float);
void create_sdl(SDL_Window**, SDL_Renderer**, TTF_Font**, char*, char*);
#endif
\ No newline at end of file
Markdown is supported
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