gameui
diff src/boolanm.h @ 2:e5b1525084f7
boolanim
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 20 Mar 2014 07:03:58 +0200 |
parents | |
children | f1014234dece |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/boolanm.h Thu Mar 20 07:03:58 2014 +0200 1.3 @@ -0,0 +1,38 @@ 1.4 +#ifndef BOOLANIM_H_ 1.5 +#define BOOLANIM_H_ 1.6 + 1.7 +class BoolAnim { 1.8 +private: 1.9 + mutable float value; 1.10 + mutable float trans_dir; // transition direction (sign) 1.11 + long trans_start; // transition start time 1.12 + long trans_dur; 1.13 + 1.14 + long (*get_msec)(); 1.15 + 1.16 + void update(long tm) const; 1.17 + 1.18 +public: 1.19 + BoolAnim(bool st = false); 1.20 + 1.21 + void set_transition_duration(long dur); 1.22 + void set_time_callback(long (*time_func)()); 1.23 + 1.24 + void change(bool st); 1.25 + void change(bool st, long trans_start); 1.26 + 1.27 + bool get_state() const; 1.28 + bool get_state(long tm) const; 1.29 + 1.30 + float get_value() const; 1.31 + float get_value(long tm) const; 1.32 + 1.33 + // transition direction (-1, 0, 1) 1.34 + float get_dir() const; 1.35 + float get_dir(long tm) const; 1.36 + 1.37 + operator bool() const; // equivalent to get_state 1.38 + operator float() const; // equivalent to get_value 1.39 +}; 1.40 + 1.41 +#endif // BOOLANIM_H_