Corrected a bug with moveOnBoard, Added special rule for 2 players and a drawer for pieces (at this time, we can move player 0's pieces around)
parent
1801098574
commit
4e5f963eeb
@ -0,0 +1,10 @@
|
||||
#ifndef PIECES_DRAWER_INCLUDED
|
||||
#define PIECES_DRAWER_INCLUDED
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdbool.h>
|
||||
#include "model/Piece.h"
|
||||
|
||||
void drawPieces(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Piece arrPieces[], const size_t nbPieces, SDL_Texture* piece);
|
||||
|
||||
#endif //PIECES_DRAWER_INCLUDED
|
@ -0,0 +1,26 @@
|
||||
#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 drawPieces(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Piece arrPieces[], const size_t nbPieces, SDL_Texture* piece) {
|
||||
|
||||
for (size_t i = 0; i < nbPieces; ++i)
|
||||
{
|
||||
const SDL_Rect rDest = islandToRect(boardRect, arrPieces[i].island);
|
||||
SDL_RenderCopy(renderer, piece, NULL, &rDest);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue