Skip to content

Commit

Permalink
feat: hit janggu to skip result screen
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteHell committed Jun 11, 2024
1 parent 3fa4343 commit 5522693
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions game/src/game/display_result.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::Path;
use std::{path::Path, time::Instant};

use sdl2::{
event::Event,
Expand All @@ -16,9 +16,11 @@ use crate::constants::{DEFAULT_FONT_OUTLINE_SIZE, GAME_RESULT_FONT_SIZE};
use super::{
common::{event_loop_common, render_common},
game_common_context::GameCommonContext,
game_player::game_result::GameResult,
util::create_outlined_font_texture::create_font_texture,
util::render_game_assets::{render_cover_image_at, render_level_image_at},
game_player::{game_result::GameResult, janggu_state_with_tick::JangguStateWithTick},
util::{
create_outlined_font_texture::create_font_texture,
render_game_assets::{render_cover_image_at, render_level_image_at},
},
};

use bidrum_data_struct_lib::song::GameSong;
Expand Down Expand Up @@ -78,6 +80,12 @@ pub(crate) fn display_result(
.freetype_library
.new_face(FONT_PATH.to_owned() + "/coin.ttf", 0)
.unwrap();
let mut janggu_state = JangguStateWithTick::new();
let started_at = Instant::now();
janggu_state.update(
common_context.read_janggu_state(),
started_at.elapsed().as_millis() as i128,
);
loop {
for event in common_context.event_pump.poll_iter() {
if event_loop_common(&event) {
Expand All @@ -94,6 +102,14 @@ pub(crate) fn display_result(
}
}

janggu_state.update(
common_context.read_janggu_state(),
started_at.elapsed().as_millis() as i128,
);
if janggu_state.궁채.is_keydown_now || janggu_state.열채.is_keydown_now {
return;
}

let canvas = &mut common_context.canvas;
canvas.clear();
let canvas_size = canvas.viewport();
Expand Down

0 comments on commit 5522693

Please sign in to comment.