show fps counter

This commit is contained in:
Felix Ableitner 2021-10-06 19:18:48 +02:00
parent 61a88f44aa
commit 8def3c005d

View file

@ -6,13 +6,13 @@ mod constants;
use crate::ant::Ant; use crate::ant::Ant;
use constants::*; use constants::*;
use macroquad::color::*; use macroquad::color::*;
use macroquad::input::{ use macroquad::input::{is_key_down, is_quit_requested, KeyCode};
is_key_down, is_mouse_button_down, is_quit_requested, mouse_position, KeyCode, MouseButton,
};
use macroquad::miniquad::conf::Conf; use macroquad::miniquad::conf::Conf;
use macroquad::prelude::{ use macroquad::prelude::{
clear_background, draw_texture, get_frame_time, next_frame, Image, Texture2D, clear_background, draw_texture, get_frame_time, next_frame, Image, Texture2D,
}; };
use macroquad::text::draw_text;
use macroquad::time::get_fps;
fn window_conf() -> Conf { fn window_conf() -> Conf {
Conf { Conf {
@ -47,16 +47,12 @@ async fn main() {
if is_key_down(KeyCode::Escape) || is_quit_requested() { if is_key_down(KeyCode::Escape) || is_quit_requested() {
return; return;
} }
if is_mouse_button_down(MouseButton::Left) {
let mouse = mouse_position();
dbg!(&mouse);
//food.push(Food::new(Vec2::new(mouse.0, mouse.1)));
}
// render // render
clear_background(BLACK); clear_background(BLACK);
let texture = Texture2D::from_image(&trail_map); let texture = Texture2D::from_image(&trail_map);
draw_texture(texture, 0., 0., WHITE); draw_texture(texture, 0., 0., WHITE);
draw_text(&get_fps().to_string(), 0., 20., 20., WHITE);
next_frame().await next_frame().await
} }