1use macroquad::prelude::*;
2use macroquad_virtual_joystick::Joystick;
3
4#[macroquad::main("Simple Joystick")]
5async fn main() {
6 const SPEED: f32 = 2.5;
7 let mut position = Vec2::new(screen_width() / 2.0, screen_height() / 4.0);
8 let mut joystick = Joystick::new(100.0, 200.0, 50.0);
9 loop {
10 clear_background(WHITE);
11
12 let joystick_event = joystick.update();
13 position += joystick_event.direction.to_local() * joystick_event.intensity * SPEED;
14
15 draw_circle(position.x, position.y, 50.0, YELLOW);
16
17 joystick.render();
19 next_frame().await
20 }
21}