You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
projet-tut/Pontu/src/view/PiecesDrawer.c

29 lines
760 B

#include "view/PiecesDrawer.h"
#include "model/Island.h"
//Don't put this in model
SDL_Rect islandToRect(const SDL_Rect* boardRect, const Island island) {
const int w = boardRect->w/9;
const int h = boardRect->h/9;
SDL_Rect r = {
.x = boardRect->x + w*(island.x*2),
.y = boardRect->y + h*(island.y*2),
.w = w,
.h = h
};
return r;
}
void drawPiecesPlayer(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Piece arrPieces[], const size_t nbPieces, const size_t numPlayer, SDL_Texture* piece) {
for (size_t i = 0; i < nbPieces; ++i)
{
if (arrPieces[i].idJ == numPlayer) {
const SDL_Rect rDest = islandToRect(boardRect, arrPieces[i].island);
SDL_RenderCopy(renderer, piece, NULL, &rDest);
}
}
}