Skip to content

Commit

Permalink
Add draw_fps function
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohq committed Nov 15, 2024
1 parent 455f3fb commit f7cc29a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/rustaceanmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async fn main() {
);
}

draw_text(format!("FPS: {}", get_fps()).as_str(), 0., 16., 32., WHITE);
draw_fps();
draw_text(
format!("Rustaceanes: {}", rustaceanes.len()).as_str(),
0.,
Expand Down
7 changes: 6 additions & 1 deletion src/time.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! Cross platform system time access and FPS counters.
use crate::get_context;
use crate::{color::Color, get_context, text::draw_text};

Check warning on line 3 in src/time.rs

View workflow job for this annotation

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

unused import: `color::Color`

Check warning on line 3 in src/time.rs

View workflow job for this annotation

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

unused import: `color::Color`

Check warning on line 3 in src/time.rs

View workflow job for this annotation

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

unused import: `color::Color`

Check warning on line 3 in src/time.rs

View workflow job for this annotation

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

unused import: `color::Color`

Check warning on line 3 in src/time.rs

View workflow job for this annotation

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

unused import: `color::Color`

/// Draws the current FPS on the screen. For extra customization, please use `draw_text` instead.
pub fn draw_fps() {
draw_text(&format!("FPS: {}", get_fps()), 0., 16., 32., crate::WHITE);
}

/// Returns current FPS
pub fn get_fps() -> i32 {
Expand Down

0 comments on commit f7cc29a

Please sign in to comment.