Skip to content
Snippets Groups Projects
Commit 1456d624 authored by SmallIshMink's avatar SmallIshMink
Browse files

Ajout de la partie 3 Oublié

parent 9cb777f7
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ struct textures_s{
SDL_Texture* background; /*!< Texture liée à l'image du fond de l'écran. */
SDL_Texture* ship; /*!< Texture liée à l'image du vaisseau. */
SDL_Texture* meteorite; /*!< Texture liée à l'image du météorite. */
SDL_Texture* finishLine; /*!< Texture liée à l'image de la ligne d'arrivée. */
/* A COMPLETER */
};
......@@ -97,6 +98,7 @@ typedef struct sprite_s sprite_t;
struct world_s{
sprite_t *vaisseau ; /*!< Représentation du vaisseau */
sprite_t *mur; /*!< Représentation du météorite */
sprite_t *ligneArriver;
int gameover; /*!< Champ indiquant si l'on est à la fin du jeu */
int speed_h; /*!< Vitesse de déplacement horizontal des éléments du jeu */
......@@ -127,11 +129,13 @@ void print_sprite(sprite_t *sprite){
* \param w
* \param h
*/
void init_sprite(sprite_t *sprite, int x, int y, int w, int h){
sprite_t *init_sprite(sprite_t *sprite, int x, int y, int w, int h){
sprite = malloc(sizeof(sprite_t));
sprite->x = x;
sprite->y = y;
sprite->w = w;
sprite->h = h;
return sprite;
}
/**
......@@ -147,10 +151,11 @@ void init_data(world_t * world){
world->speed_h = 0;
// Initialisation du vaisseau
world->vaisseau = malloc(sizeof(sprite_t));
world->mur = malloc(sizeof(sprite_t));
init_sprite(world->vaisseau, SCREEN_WIDTH/2 - SHIP_SIZE/2, SCREEN_HEIGHT - SHIP_SIZE, SHIP_SIZE, SHIP_SIZE);
init_sprite(world->mur, 0, 0, 3*METEORITE_SIZE, 7*METEORITE_SIZE);
world->vaisseau = init_sprite(world->vaisseau, SCREEN_WIDTH/2 - SHIP_SIZE/2, SCREEN_HEIGHT - SHIP_SIZE, SHIP_SIZE, SHIP_SIZE);
world->mur = init_sprite(world->mur, 0, 0, 3*METEORITE_SIZE, 7*METEORITE_SIZE);
world->ligneArriver = init_sprite(world->ligneArriver, 0, -40, SCREEN_WIDTH, FINISH_LINE_HEIGHT);
print_sprite(world->vaisseau);
}
......@@ -189,7 +194,7 @@ int is_game_over(world_t *world){
*/
void update_data(world_t *world){
printf("%d\n", world->speed_h);
world->ligneArriver->y += INITIAL_SPEED - world->speed_h;
world->mur->y += INITIAL_SPEED - world->speed_h;
}
......@@ -255,6 +260,9 @@ void handle_events(SDL_Event *event,world_t *world){
void clean_textures(textures_t *textures){
clean_texture(textures->background);
clean_texture(textures->ship);
clean_texture(textures->meteorite);
clean_texture(textures->finishLine);
/* A COMPLETER */
}
......@@ -270,6 +278,7 @@ void init_textures(SDL_Renderer *renderer, textures_t *textures){
textures->background = load_image( "ressources/space-background.bmp",renderer);
textures->ship = load_image( "ressources/spaceship.bmp",renderer);
textures->meteorite = load_image( "ressources/meteorite.bmp",renderer);
textures->finishLine = load_image( "ressources/finish_line.bmp",renderer);
/* A COMPLETER */
......@@ -329,6 +338,8 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,textures_t *texture
/* A COMPLETER */
apply_sprite(renderer, textures->ship, world->vaisseau);
apply_sprite(renderer, textures->finishLine, world->ligneArriver);
for (int i = 0; i < world->mur->w/METEORITE_SIZE ; i++){
for (int i2 = 0; i2 < world->mur->h/METEORITE_SIZE ; i2++){
apply_wall(renderer, textures->meteorite, world->mur->x+i*METEORITE_SIZE, world->mur->y+i2*METEORITE_SIZE);
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment