Improve game rendering loop

This commit is contained in:
Loic Guegan 2023-01-01 16:21:24 +01:00
parent 8bf9e7e7b5
commit d05093513e
2 changed files with 1 additions and 14 deletions

View file

@ -75,10 +75,6 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) {
adata.src.y + adata.frame*(adata.transVect.y/adata.frames), false);
// end drawing
adata.frame++;
if(adata.frame>=adata.frames){
adata.reuseBuffer=false;
SetupBoard(adata.final_board, adata.final_is_black_turn, adata.final_captures,white_player,black_player);
}
}
}
@ -116,10 +112,6 @@ void BoardCanvas::SetupBoard(std::string board, bool is_black_turn,
}
void BoardCanvas::Animate(const std::string &board, bool is_black_turn, std::map<char, std::uint8_t> captures, std::string src, std::string dst,bool faster){
adata.final_board=board;
adata.final_is_black_turn=is_black_turn;
adata.final_captures=captures;
std::uint8_t pfile = src[0]-'a';
std::uint8_t prank = src[1]-'1';
adata.piece_moved = this->board[pfile + 8 * (7-prank)]; // Piece to move
@ -172,6 +164,7 @@ void BoardCanvas::Animate(const std::string &board, bool is_black_turn, std::map
}
adata.duration=faster ? duration_backup : duration_backup;
adata.reuseBuffer=false;
SetupBoard(board, is_black_turn, captures,white_player,black_player);
}
void BoardCanvas::DrawBoard(wxDC &dc) {

View file

@ -50,12 +50,6 @@ typedef struct AnimState {
int duration,duration_fast;
/// @brief Animation FPS
std::uint8_t fps;
/// @brief Board to draw at the end of the animation
std::string final_board;
/// @brief Which player is to move at the end of the animation
bool final_is_black_turn;
/// @brief Final state of captured pieces at the end of the animation
std::map<char, std::uint8_t> final_captures;
/// @brief Current animated piece
char piece_moved;
/// @brief Starting point of the animated piece