diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index 9eb54ee..aab3c45 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -17,9 +17,9 @@ BoardCanvas::BoardCanvas(wxFrame *parent) valid_drag = false; valid_arrow = false; // Init animation data - adata.duration=200; - adata.duration_fast=80; - adata.fps=30; + adata.duration=100; + adata.duration_fast=100; + adata.fps=60; adata.buffer=new wxBitmap(500,500,32); adata.animate=false; // Init game state @@ -186,8 +186,8 @@ void BoardCanvas::Animate(const GameState &new_gs, const std::string &src, const for(int i=adata.frames;i>0;i--){ Refresh(); Update(); - int delay=sw.Time()-frame_duration; - if(delay>5){ // 5ms tolerance + int delay=frame_duration-sw.Time(); + if(delay>1){ // 1ms tolerance (max drift of fps each second that is fps*tolerance) wxMilliSleep(delay); } sw.Start(0); diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 0576f1d..24c469c 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -103,13 +103,18 @@ public: BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen); ~BoardCanvas(); void ApplyPreferences(); + /// @brief Draw current state of the board (GameState) on the given wxDC void DrawBoard(wxDC &dc); void OnPaint(wxPaintEvent &event); void MouseEvent(wxMouseEvent &event); + /// @brief Zomm in/out on the canvas void Zoom(std::int32_t zoom); + /// @brief Change between black side and white side void Swap(); - void OnResize(wxSizeEvent &e); + /// @brief Display a position on the canvas void SetupBoard(const GameState &new_gs); + /// @brief Animate a piece front src to dst from current position void Animate(const GameState &new_gs, const std::string &src, const std::string &dst,bool faster); + /// @brief Setup clock on displayed on the canvas void SetClockTime(short hours, short min, short sec, bool IsBlack); };