82 lines
2.5 KiB
C
82 lines
2.5 KiB
C
#include "affichage.h"
|
|
|
|
|
|
void displayBackgroundSprite(sfRenderWindow *const window, const sfSprite *const sprite)
|
|
{
|
|
sfRenderWindow_clear(window, sfWhite);
|
|
sfRenderWindow_drawSprite(window, sprite, NULL);
|
|
sfRenderWindow_display(window);
|
|
}
|
|
|
|
void clearDisplayBackground(sfRenderWindow *const window, sfRenderTexture *renderTexture, sfSprite **sprite)
|
|
{
|
|
sfRenderTexture_clear(renderTexture, sfWhite);
|
|
sfRenderWindow_clear(window, sfWhite);
|
|
sfRenderWindow_display(window);
|
|
sfSprite_destroy(*sprite);
|
|
*sprite = NULL;
|
|
*sprite = loadSpriteFromRenderTexture(renderTexture);
|
|
}
|
|
|
|
|
|
void afficherPoints(sfRenderTexture *const renderTexture, sfVector2f *points, char **dates, uint32_t nbElements, sfCircleShape *tabPointeursCercle[nbElements])
|
|
{
|
|
(void)dates;
|
|
|
|
sfCircleShape *cercle = NULL;
|
|
|
|
for(uint32_t i = 0; i < nbElements; i++)
|
|
{
|
|
cercle = creerCercle((sfVector2f){points[i].x, points[i].y}, 3, sfRed);
|
|
sfRenderTexture_drawCircleShape(renderTexture, cercle, NULL);
|
|
|
|
// On sauvegarde l'adresse des cercles pour pouvoir les libérer dans le futur !
|
|
tabPointeursCercle[i] = cercle;
|
|
}
|
|
|
|
sfRenderTexture_display(renderTexture);
|
|
}
|
|
|
|
|
|
void afficherCarte(sfRenderTexture *const renderTexture, sfTexture **mapTexture, sfSprite **mapSprite, const char *const cheminFichier)
|
|
{
|
|
*mapTexture = loadTextureFromFile(cheminFichier);
|
|
*mapSprite = loadSpriteFromTexture((sfVector2f){0, 0}, *mapTexture);
|
|
|
|
sfSprite_scale(*mapSprite, (sfVector2f){WIDTH / (float)(MAPSIZE * MAPSCALE), HEIGHT / (float)(MAPSIZE * MAPSCALE)});
|
|
|
|
sfRenderTexture_clear(renderTexture, sfWhite);
|
|
sfRenderTexture_drawSprite(renderTexture, *mapSprite, NULL);
|
|
}
|
|
|
|
|
|
void scrollUpDisplay(sfRenderWindow *const window, sfSprite *const sprite)
|
|
{
|
|
sfVector2f positionTemp;
|
|
|
|
const double ratio = 5.f;
|
|
const uint16_t endLoop = sfRenderWindow_getSize(window).y / ratio;
|
|
|
|
sfRenderWindow_setFramerateLimit(window, FRAMERATELIMITPOWER);
|
|
|
|
for(uint16_t i = 0; i < endLoop; i++)
|
|
{
|
|
positionTemp = sfSprite_getPosition(sprite);
|
|
sfSprite_setPosition(sprite, (sfVector2f){positionTemp.x, positionTemp.y - ratio});
|
|
|
|
displayBackgroundSprite(window, sprite);
|
|
|
|
// Pour que l'utilisateur puisse fermer la fenêtre, même pendant le scroll' !
|
|
sfEvent event;
|
|
sfRenderWindow_pollEvent(window, &event);
|
|
if(event.type == sfEvtClosed || (event.type == sfEvtKeyPressed && event.key.code == sfKeyEscape))
|
|
{
|
|
sfRenderWindow_close(window);
|
|
sfRenderWindow_destroy(window);
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
|
|
sfRenderWindow_setFramerateLimit(window, FRAMERATELIMITSLEEP);
|
|
}
|