2个不稳定版本
0.2.0 | 2021年5月12日 |
---|---|
0.1.0 | 2021年5月1日 |
#1223 in 游戏开发
被用于 xonix
15KB
224 行
为macroquad游戏提供的简单摇杆
摇杆可以通过触摸或鼠标更新。欢迎贡献!
警告
该库目前不稳定。每个版本都可能引入破坏性更改!
示例
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
}
}
lib.rs
:
A simple joystick for macroquad games
摇杆可以通过触摸或鼠标更新
示例
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.);
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., YELLOW);
joystick.render();
next_frame().await
}
}
依赖项
~19MB
~233K SLoC