bevy_animator/
util.rs

1//==============================================================================
2// This file contains utility methods that will help you map animations to controls,
3// and control the animations in a way that is easy to use. This is a work in progress!!!
4//==============================================================================
5
6#[allow(dead_code)]
7pub mod controls {
8    use bevy::{input::{gamepad::{GamepadAxisType, GamepadButton}, keyboard::KeyCode}, math::Vec2};
9
10    pub struct Axis2d {
11        control_mode : ControlMode,
12        state : Axis2dDirection
13    }
14    
15    pub enum Axis2dDirection {
16        North,
17        NorthWest,
18        West,
19        SouthWest,
20        South,
21        SouthEast,
22        East,
23        NorthEast,
24        Middle,
25        Exact(Vec2),
26    }
27    
28    pub enum ControlMode {
29        GamepadAxis { axis : GamepadAxisType },
30        GamePadButtons {
31            north : GamepadButton, 
32            west : GamepadButton, 
33            south : GamepadButton, 
34            east : GamepadButton,
35        },
36        Keyboard {
37            north : KeyCode,
38            west : KeyCode,
39            south : KeyCode,
40            east : KeyCode,
41        }
42    }
43}