now properly walking and running, fully fixed
This commit is contained in:
@@ -35,9 +35,11 @@ void render_loop(int speed) {
|
||||
const char *bg_file = "background_dark_inverted.txt";
|
||||
bool need_redraw = false;
|
||||
|
||||
int anim_tick_counter = 0;
|
||||
int tick_counter = 0;
|
||||
int player_speed = 5;
|
||||
int player_speed = 6;
|
||||
|
||||
player_state.set_state(PlayerState::Run);
|
||||
while (true) {
|
||||
tick_counter++;
|
||||
|
||||
@@ -61,22 +63,18 @@ void render_loop(int speed) {
|
||||
player_state.update();
|
||||
|
||||
if (animation.tick(speed)) {
|
||||
anim_tick_counter++;
|
||||
need_redraw = true;
|
||||
}
|
||||
|
||||
if (need_redraw) {
|
||||
player_state.toggle_walk_frame(player_speed, anim_tick_counter);
|
||||
draw_mask(bg_file, animation.get_shift(), uart.get_message());
|
||||
FrameSelection frame = player_state.get_frame_selection();
|
||||
|
||||
CharacterPosition draw_pos = get_aligned_frame_position(pos, frame.movement, frame.frame_index);
|
||||
draw_character(draw_pos.x, draw_pos.y, frame.movement, frame.frame_index);
|
||||
|
||||
|
||||
if (player_state.get_state() != PlayerState::Crawl) {
|
||||
player_state.set_motion_state_for_speed(player_speed, timing.get_ground_speed());
|
||||
player_state.toggle_walk_frame(player_speed, tick_counter);
|
||||
}
|
||||
|
||||
ThisThread::sleep_for(50ms);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user