mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Debug BoardCanvas (animations)
This commit is contained in:
parent
7fe3e6dee0
commit
c046216e10
2 changed files with 11 additions and 6 deletions
|
@ -17,9 +17,9 @@ BoardCanvas::BoardCanvas(wxFrame *parent)
|
||||||
valid_drag = false;
|
valid_drag = false;
|
||||||
valid_arrow = false;
|
valid_arrow = false;
|
||||||
// Init animation data
|
// Init animation data
|
||||||
adata.duration=200;
|
adata.duration=100;
|
||||||
adata.duration_fast=80;
|
adata.duration_fast=100;
|
||||||
adata.fps=30;
|
adata.fps=60;
|
||||||
adata.buffer=new wxBitmap(500,500,32);
|
adata.buffer=new wxBitmap(500,500,32);
|
||||||
adata.animate=false;
|
adata.animate=false;
|
||||||
// Init game state
|
// 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--){
|
for(int i=adata.frames;i>0;i--){
|
||||||
Refresh();
|
Refresh();
|
||||||
Update();
|
Update();
|
||||||
int delay=sw.Time()-frame_duration;
|
int delay=frame_duration-sw.Time();
|
||||||
if(delay>5){ // 5ms tolerance
|
if(delay>1){ // 1ms tolerance (max drift of fps each second that is fps*tolerance)
|
||||||
wxMilliSleep(delay);
|
wxMilliSleep(delay);
|
||||||
}
|
}
|
||||||
sw.Start(0);
|
sw.Start(0);
|
||||||
|
|
|
@ -103,13 +103,18 @@ public:
|
||||||
BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen);
|
BoardCanvas(wxFrame *parent,std::uint32_t square_width, bool frozen);
|
||||||
~BoardCanvas();
|
~BoardCanvas();
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
|
/// @brief Draw current state of the board (GameState) on the given wxDC
|
||||||
void DrawBoard(wxDC &dc);
|
void DrawBoard(wxDC &dc);
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void MouseEvent(wxMouseEvent &event);
|
void MouseEvent(wxMouseEvent &event);
|
||||||
|
/// @brief Zomm in/out on the canvas
|
||||||
void Zoom(std::int32_t zoom);
|
void Zoom(std::int32_t zoom);
|
||||||
|
/// @brief Change between black side and white side
|
||||||
void Swap();
|
void Swap();
|
||||||
void OnResize(wxSizeEvent &e);
|
/// @brief Display a position on the canvas
|
||||||
void SetupBoard(const GameState &new_gs);
|
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);
|
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);
|
void SetClockTime(short hours, short min, short sec, bool IsBlack);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue