No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

36 líneas
639 B

  1. use glc::vector::Vector2f;
  2. use serde::{Deserialize, Serialize};
  3. use specs::{Component, VecStorage};
  4. #[derive(Clone, Debug, Default, Serialize, Deserialize)]
  5. pub struct Velocity {
  6. dir: Vector2f,
  7. speed: f32,
  8. }
  9. /* Velocity */
  10. impl Velocity {
  11. pub fn dir(&self) -> &Vector2f {
  12. &self.dir
  13. }
  14. pub fn speed(&self) -> f32 {
  15. self.speed
  16. }
  17. }
  18. impl Velocity {
  19. pub(crate) fn new(dir: Vector2f, speed: f32) -> Self {
  20. Self { dir, speed }
  21. }
  22. pub(crate) fn dir_mut(&mut self) -> &mut Vector2f {
  23. &mut self.dir
  24. }
  25. }
  26. impl Component for Velocity {
  27. type Storage = VecStorage<Self>;
  28. }