diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index f39014d3c147567ca277b174d30fd0fc01bb84ce..0000000000000000000000000000000000000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**", - "${workspaceFolder}/src/include" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe", - "cStandard": "c17", - "cppStandard": "gnu++17", - "intelliSenseMode": "windows-gcc-x64", - "configurationProvider": "ms-vscode.makefile-tools" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/Makefile.zip b/Makefile.zip deleted file mode 100644 index dd60c91cab9fc7ca040453b5ce9fa5e64e207af5..0000000000000000000000000000000000000000 Binary files a/Makefile.zip and /dev/null differ diff --git a/Makefile_win b/Makefile_win new file mode 100644 index 0000000000000000000000000000000000000000..c2ac6e817e054e351e0783370908247800d5edcc --- /dev/null +++ b/Makefile_win @@ -0,0 +1,24 @@ +CFLAGS = -O3 -Dmain=SDL_main +LDFLAGS = -lm -lmingw32 -lSDL2main -lSDL2 +SDL2_INCLUDE_DIR = C:\SDL2-2.0.12\x86_64-w64-mingw32\include +SDL2_LIBRARIES_DIR = C:\SDL2-2.0.12\x86_64-w64-mingw32\lib + +INC = sdl2-light.h +SRC = main.c sdl2-light.c +OBJ = $(SRC:%.c=%.o) + +PROG = spacecorridor.exe + +%.o: %.c $(INC) + gcc $(CFLAGS) -c $< -I $(SDL2_INCLUDE_DIR) + +$(PROG): $(OBJ) + gcc $(CFLAGS) $(OBJ) $(LDFLAGS) -o $@ -L $(SDL2_LIBRARIES_DIR) + +doc: $(PROG) + doxygen $(PROG) + +.PHONY: clean +clean: + del /f /q *.o *~ $(PROG) + rd /s /q latex html diff --git a/main.c b/main.c index 7ca0f0226b17cf9e47e167dff7a4252908400948..cfacfc06f90656c020e93f1d99771a6e5566db2d 100644 --- a/main.c +++ b/main.c @@ -1,38 +1,62 @@ /** * \file main.c - * \brief Programme principal initial du niveau 0 + * \brief Programme principal initial du niveau 1 * \author Mathieu Constant * \version 1.0 - * \date 18 mars 2020 + * \date 18 mars 2021 */ #include "sdl2-light.h" +#include <stdio.h> +/** + * \brief Largeur de l'écran de jeu + */ +#define SCREEN_WIDTH 300 /** - * \brief Largeur de l'écran -*/ + * \brief Hauteur de l'écran de jeu + */ +#define SCREEN_HEIGHT 480 + + +/** + * \brief Taille d'un vaisseau + */ +#define SHIP_SIZE 32 -#define SCREEN_WIDTH 320 /** - * \brief Hauteur de l'écran + * \brief Taille d'un météorite */ -#define SCREEN_HEIGHT 240 +#define METEORITE_SIZE 32 + /** - * \brief Taille du sprite + * \brief Hauteur de la ligne d'arrivée + */ + + +#define FINISH_LINE_HEIGHT 10 + + +/** + * \brief Pas de déplacement horizontal du vaisseau */ -#define SPRITE_SIZE 32 +#define MOVING_STEP 10 + /** - * \brief Pas de déplacement du sprite + * \brief Vitesse initiale de déplacement vertical des éléments du jeu */ -#define MOVING_STEP 5 +#define INITIAL_SPEED 2 + + + /** * \brief Représentation pour stocker les textures nécessaires à l'affichage graphique @@ -164,13 +188,13 @@ void clean_textures(textures_t *textures){ /** - * \brief La fonction initialise les texures + * \brief La fonction initialise les textures nécessaires à l'affichage graphique du jeu * \param screen la surface correspondant à l'écran de jeu * \param textures les textures du jeu */ void init_textures(SDL_Renderer *renderer, textures_t *textures){ - textures->background = load_image( "ressources/background.bmp",renderer); + textures->background = load_image( "ressources/space-background.bmp",renderer); /* A COMPLETER */ @@ -181,12 +205,12 @@ void init_textures(SDL_Renderer *renderer, textures_t *textures){ /** * \brief La fonction applique la texture du fond sur le renderer lié à l'écran de jeu * \param renderer le renderer - * \param textures les textures du jeu + * \param texture la texture liée au fond */ -void apply_background(SDL_Renderer *renderer, textures_t *textures){ - if(textures->background != NULL){ - apply_texture(textures->background, renderer, 0, 0); +void apply_background(SDL_Renderer *renderer, SDL_Texture *texture){ + if(texture != NULL){ + apply_texture(texture, renderer, 0, 0); } } @@ -196,9 +220,9 @@ void apply_background(SDL_Renderer *renderer, textures_t *textures){ /** * \brief La fonction rafraichit l'écran en fonction de l'état des données du monde - * \param renderer le renderer + * \param renderer le renderer lié à l'écran de jeu * \param world les données du monde - * \param textures les textures du jeu + * \param textures les textures */ void refresh_graphics(SDL_Renderer *renderer, world_t *world,textures_t *textures){ @@ -207,7 +231,7 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,textures_t *texture clear_renderer(renderer); //application des textures dans le renderer - apply_background(renderer, textures); + apply_background(renderer, textures->background); /* A COMPLETER */ // on met à jour l'écran @@ -237,7 +261,7 @@ void clean(SDL_Window *window, SDL_Renderer * renderer, textures_t *textures, wo * \param window la fenêtre du jeu * \param renderer le renderer * \param textures les textures - * \param wordl le monde + * \param world le monde */ void init(SDL_Window **window, SDL_Renderer ** renderer, textures_t *textures, world_t * world){ diff --git a/main.o b/main.o index b5a3037b0cae020acbd73e78ce47620533e4d6ea..a6bca19f72af0d3ab05df821d1d07020ecfe99dc 100644 Binary files a/main.o and b/main.o differ diff --git a/ressources/finish_line.bmp b/ressources/finish_line.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9839ca9f374da18969b950ece79ff416b0734c68 Binary files /dev/null and b/ressources/finish_line.bmp differ diff --git a/ressources/meteorite.bmp b/ressources/meteorite.bmp new file mode 100644 index 0000000000000000000000000000000000000000..89f4a806e712490846b9fe2f411d10548773a3b4 Binary files /dev/null and b/ressources/meteorite.bmp differ diff --git a/ressources/missile.bmp b/ressources/missile.bmp new file mode 100644 index 0000000000000000000000000000000000000000..41727a4cbdc2fd2b879a2b0136f90740d896a38c Binary files /dev/null and b/ressources/missile.bmp differ diff --git a/ressources/space-background.bmp b/ressources/space-background.bmp new file mode 100644 index 0000000000000000000000000000000000000000..27a3f61735288d8ba2e4d4d9140b9c27fe6bbcd6 Binary files /dev/null and b/ressources/space-background.bmp differ diff --git a/ressources/spaceship.bmp b/ressources/spaceship.bmp new file mode 100644 index 0000000000000000000000000000000000000000..58f95bbc43074f6be3054d5880b6ce6b0f8491b5 Binary files /dev/null and b/ressources/spaceship.bmp differ diff --git a/ressources/sprite.bmp b/ressources/sprite.bmp deleted file mode 100644 index 42b3f86dd60ccac9a0513d878d5b7ce88fae7e73..0000000000000000000000000000000000000000 Binary files a/ressources/sprite.bmp and /dev/null differ diff --git a/spacecorridor.exe b/spacecorridor.exe index a81d9010671d398e09b0e3045983bb79c978c9b7..52db8182627078bb3ddd314a108645e983018942 100644 Binary files a/spacecorridor.exe and b/spacecorridor.exe differ