-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
207 additions
and
35 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** __ | ||
** File description: | ||
** _ | ||
*/ | ||
|
||
#include "hunter.h" | ||
#include <SFML/Graphics.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
void display_ammos(hunterinfo_t *hf) | ||
{ | ||
for (int i = 0; i < AMMO_COUNT; i++) | ||
if (hf->ammos[i].sprite != NULL) | ||
sfRenderWindow_drawSprite(hf->window, hf->ammos[i].sprite, NULL); | ||
} | ||
|
||
int fill_ammos(hunterinfo_t *hf) | ||
{ | ||
hf->ammos[AMMO_COUNT - 1].sprite = NULL; | ||
for (int i = 0; i < AMMO_COUNT; i++) { | ||
hf->ammos[i].texture = sfTexture_createFromFile("assets/ammo.png", | ||
NULL); | ||
if (!hf->ammos[i].texture) | ||
return EXIT_FAILURE; | ||
hf->ammos[i].sprite = sfSprite_create(); | ||
sfSprite_setTexture(hf->ammos[i].sprite, | ||
hf->ammos[i].texture, sfTrue); | ||
sfSprite_setTextureRect(hf->ammos[i].sprite, | ||
(sfIntRect){ 0, 0, 4, 7 }); | ||
hf->ammos[i].size = sfTexture_getSize(hf->ammos[i].texture); | ||
hf->ammos[i].size.x /= 2; | ||
sfSprite_setScale(hf->ammos[i].sprite, (sfVector2f){ 5, 5 }); | ||
sfSprite_setPosition(hf->ammos[i].sprite, | ||
(sfVector2f){ 10 * (i + 1) + i * 20, 900}); | ||
hf->ammos[i].version = 0; | ||
} | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
int change_ammo_version(hunterinfo_t *hf, int i) | ||
{ | ||
if (hf->ammos[i].sprite == NULL) | ||
return EXIT_SUCCESS; | ||
if (hf->ammos[i].version == 2) | ||
hf->ammos[i].version = 0; | ||
if (i < 0) | ||
return EXIT_FAILURE; | ||
sfSprite_setTextureRect(hf->ammos[i].sprite, (sfIntRect){ 4 * | ||
hf->ammos[i].version, 0, 4, 7 }); | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** __ | ||
** File description: | ||
** _ | ||
*/ | ||
|
||
#include "hunter.h" | ||
#include "lib.h" | ||
#include <SFML/Graphics.h> | ||
|
||
int draw_pause(hunterinfo_t *hf) | ||
{ | ||
sfFont *font = sfFont_createFromFile("assets/Jersey25-Regular.ttf"); | ||
|
||
if (!font) | ||
return EXIT_FAILURE; | ||
hf->pause_text = sfText_create(); | ||
sfText_setString(hf->pause_text, "PAUSE"); | ||
sfText_setFont(hf->pause_text, font); | ||
sfText_setCharacterSize(hf->pause_text, 100); | ||
sfText_setPosition(hf->pause_text, (sfVector2f){ (float)hf->window_size.x / | ||
2, (float)hf->window_size.y / 2 }); | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters