-
Notifications
You must be signed in to change notification settings - Fork 6
animation
YataiDON is not a frame based game. Nothing occurs at the frame level besides creating the next frame. This means that animations do not run at a specific frame rate, and this fact has shaped the current animation library. The library doesn't do anything special, it mainly run clocks and gives you a value over a period of time. It primarily exists for syntax; so that common animations are grouped together and it is easy to read what they do.
inline double get_current_ms() {
using namespace std::chrono;
auto now = high_resolution_clock::now();
auto ms = duration_cast<milliseconds>(now.time_since_epoch()).count();
return static_cast<double>(ms);
}This function is inlined to this library and is absolutely crucial for the game. This is the only correct way to get the current time at any given point in time.
There are 5 prebuilt types of animations. They are:
-
FadeAnimation(opacity changes) -
MoveAnimation(movement) -
TextureChangeAnimation(texture keyframes) -
TextStretchAnimation(stretching text as a bounce, such as the combo number) -
TextureResizeAnimation(scale)
If the animation is not inherited from the skin, then it should be stored in a std::unique_ptr. Animations should always be pointers.
Each animation inherits a base which gives it these features:
BaseAnimation(double duration, double delay = 0.0, bool loop = false, bool lock_input = false);duration is the total duration of the animation. This is required.
delay is how much time passes before the animation begins.
loop will automatically restart the animation upon completion.
lock_input will completely block any inputs until the animation is complete.
void update(double current_time_ms);Updates the animation based on the current time in milliseconds.
void restart();Restart the animation.
void start();Start the animation. This must be called in order for the animation to work.
void pause();Pause the animation.
void unpause();Unpause the animation.
void reset();Resets the animation to its initial position. This will also stop the animation.
There are also some public attributes that can be accessed:
double attribute;
double duration;
bool is_finished;
bool is_started;
bool is_reversing;The attribute is the most important to note; this is how you access the return value of an animation.
There are some other parameters that apply to a subset of animations:
ease_in & ease_out: control the easing of an animation, with these options:
quadraticcubic-
exponentialreverse_delay: the delay before the animation restarts in the opposite direction. Setting this to0will immediately reverse the animation after it is complete.
Here are the options when creating a specific type of animation:
-
FadeAnimation:-
initial_opacity: this is by1.0by default. -
final_opacity: this is0.0by default. Fades are fade out by default.
-
-
MoveAnimation:-
total_distance: the amount of pixels the animation will travel. -
start_position: this is deprecated.
-
-
TextureChangeAnimation:-
textures: contains keyframe data, as a 2D list, where each item is a tuple containing the start time, end time, and frame number of each frame.
-
-
TextureResizeAnimation:-
initial_size: this is1.0by default. -
final_size: this is0.0by default.
-
Building
libs
- animation
- audio
- config
- filesystem
- global_data
- input
- logging
- ray
- scores
- screen
- script
- song_parser
- text
- texture
- video
- webcam
libs/parsers
objects
objects/game
- player
- background
- gauge
- judgment
- combo
- branch_indicator
- ending_animations
- gogo_time
- fireworks
- song_info
- transition
- result_transition
- judge_counter
- score_counter
- score_counter_animation
- balloon_counter
- drumroll_counter
- kusudama_counter
- drum_hit_effect
- lane_hit_effect
- gauge_hit_effect
- combo_announce
- note_arc
objects/global
objects/title
objects/entry
objects/settings
objects/result
objects/song_select
- player
- navigator
- box_base
- box_song
- box_folder
- neiro
- modifier
- ura_switch
- diff_sort
- search_box
- dan_transition
- genre_bg
- score_history
- song_select_script
scenes