macroquad-virtual-joystick

Crates.iomacroquad-virtual-joystick
lib.rsmacroquad-virtual-joystick
version0.2.0
sourcesrc
created_at2021-05-01 15:31:54.831296
updated_at2021-05-12 08:34:52.780504
descriptionsimple joystick for macroquad games
homepagehttps://github.com/Akida31/macroquad-virtual-joystick
repositoryhttps://github.com/Akida31/macroquad-virtual-joystick
max_upload_size
id391932
size44,707
(Akida31)

documentation

README

simple joystick for macroquad games

The joystick can be updated by touches or mouse. Feel free to contribute!

Warning

This library is currently not stable. Each version can introduce breaking changes!

Example

use macroquad::prelude::*;
use macroquad_virtual_joystick::Joystick;

#[macroquad::main("Simple Joystick")]
async fn main() {
    const SPEED: f32 = 2.5;
    let mut position = Vec2::new(screen_width() / 2.0, screen_height() / 4.0);
    let mut joystick = Joystick::new(100.0, 200.0, 50.0);
    loop {
        clear_background(WHITE);

        let joystick_event = joystick.update();
        position += joystick_event.direction.to_local() * joystick_event.intensity * SPEED;

        draw_circle(position.x, position.y, 50.0, YELLOW);

        joystick.render();
        next_frame().await
    }
}
Commit count: 6

cargo fmt