Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macro_rules! create_input_tracker {
- ($name: ident, $( $element: ident: $ty: ty ; $text: tt ) , +) => {
- /// A simple combination of input trackers.
- ///
- /// You can use this as your [`Game::Input`] directly!
- ///
- /// [`Game::Input`]: ../trait.Game.html#associatedtype.Input
- pub struct $name {
- $ (
- $element: $ty,
- ) +
- }
- impl $name {
- $ (
- #[doc = "Returns the "]
- #[doc = $text]
- #[doc = " input tracker."]
- pub fn $element(&self) -> &$ty {
- &self.$element
- }
- ) +
- }
- impl Input for $name {
- fn new() -> $name {
- $name {
- $ (
- $element: <$ty as Input>::new(),
- ) +
- }
- }
- fn update(&mut self, event: Event) {
- $ (
- <$ty as Input>::update(&mut self.$element, event);
- ) +
- }
- fn clear(&mut self) {
- $ (
- <$ty as Input>::clear(&mut self.$element);
- ) +
- }
- }
- };
- }
- create_input_tracker!(KeyboardAndMouse, mouse: Mouse; "mouse", keyboard: Keyboard; "keyboard");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement