Modified gameMenu, adapted some calls

origin/fixingSettings
marouault 4 years ago
parent dd93f9508a
commit 33191714c1

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include "engine/GeneralState.h"
#include "view/MainMenu.h"
#include "view/MenuEndGame.h"
@ -8,7 +9,7 @@
#include "engine/FontLoader.h"
#include "model/Player.h"
int main(int argc, char const *argv[]) {
int main(int argc, char *argv[]) {
GeneralState generalState;
SDL_Window* window = NULL;

@ -13,4 +13,4 @@ P_Button* drawMainMenu(SDL_Renderer* renderer,const FontHandler fontHandler, uns
int mainMenu(SDL_Renderer * renderer,SDL_Window * window, GeneralState * generalState,FontHandler fontHandler, AudioHandler audioHandler);
#endif
#endif //MAIN_MENU_INCLUDED

@ -4,10 +4,11 @@
#include <SDL2/SDL.h>
#include <stdbool.h>
#include "model/Piece.h"
#include "model/Coord.h"
void drawPiecesPlayer(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Piece arrPieces[], const size_t nbPieces, const size_t numPlayer, SDL_Texture* piece);
void drawMovePiece(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Island* startMove, const Island* endMove, SDL_Texture* pieceTexture, SDL_Texture* islandTexture);
void drawMovePiece(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Coord* startMove, const Coord* endMove, SDL_Texture* pieceTexture, SDL_Texture* islandTexture);
#endif //PIECES_DRAWER_INCLUDED

@ -0,0 +1,10 @@
#ifndef TO_RECT_INCLUDED
#define TO_RECT_INCLUDED
#include <SDL2/SDL_rect.h>
#include "model/Coord.h"
SDL_Rect coordToRect(const SDL_Rect* boardRect, const Coord* coord);
#endif //TO_RECT_INCLUDED

@ -1,18 +1,5 @@
#include "view/BoardDrawer.h"
SDL_Rect coordToRect(const SDL_Rect* boardRect, const Coord* coord) {
const int w = boardRect->w/9;
const int h = boardRect->h/9;
SDL_Rect r = {
.x = boardRect->x + w*coord->x,
.y = boardRect->y + h*coord->y,
.w = w,
.h = h
};
return r;
}
#include "view/ToRect.h"
void drawRemoveBridge(SDL_Renderer* renderer, const SDL_Rect* boardRect, SDL_Texture* water, const Coord* coordBridge) {
const SDL_Rect destRect = coordToRect(boardRect, coordBridge);

@ -59,8 +59,8 @@ void drawButtons(SDL_Renderer* renderer, FontHandler fontHandler)
SDL_Color colorLabel = {0, 255, 0, 255};
//Position label
POSITIONX_TYPE positionX = POSX_CENTER;
POSITIONY_TYPE positionY = POSY_CENTER;
PositionX_Type positionX = POSX_CENTER;
PositionY_Type positionY = POSY_CENTER;

@ -1,37 +1,23 @@
#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;
}
#include "view/ToRect.h"
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);
Coord c = islandToCoord(&arrPieces[i].island);
const SDL_Rect rDest = coordToRect(boardRect, &c);
SDL_RenderCopy(renderer, piece, NULL, &rDest);
}
}
}
void drawMovePiece(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Island* startMove, const Island* endMove, SDL_Texture* pieceTexture, SDL_Texture* islandTexture) {
void drawMovePiece(SDL_Renderer* renderer, const SDL_Rect* boardRect, const Coord* startMove, const Coord* endMove, SDL_Texture* pieceTexture, SDL_Texture* islandTexture) {
SDL_Rect rDest = islandToRect(boardRect, startMove);
SDL_Rect rDest = coordToRect(boardRect, startMove);
SDL_RenderCopy(renderer, islandTexture, NULL, &rDest);
rDest = islandToRect(boardRect, endMove);
rDest = coordToRect(boardRect, endMove);
SDL_RenderCopy(renderer, pieceTexture, NULL, &rDest);
}

@ -0,0 +1,14 @@
#include "view/ToRect.h"
SDL_Rect coordToRect(const SDL_Rect* boardRect, const Coord* coord) {
const int w = boardRect->w/9;
const int h = boardRect->h/9;
SDL_Rect r = {
.x = boardRect->x + w*coord->x,
.y = boardRect->y + h*coord->y,
.w = w,
.h = h
};
return r;
}
Loading…
Cancel
Save