Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.83 KB | None | 0 0
  1. struct Game {
  2.     score: u32,
  3.     stage_width: u32,
  4.     rusto_id: Vec<u32>,
  5.     rusto_pos: HashMap<u32,(u32,u32)>,
  6.     rusto_color: HashMap<u32, types::Color>,
  7.     drop_timer: f64,
  8.     blob: Option<Blob>
  9. }
  10.  
  11. impl Game {
  12.     fn rusto_blob_position(&self) -> Position {
  13.         let main_rusto = self.blob.unwrap().rustos[0];
  14.         let (main_rusto_x, main_rusto_y) = *self.rusto_pos.get(&main_rusto).unwrap();
  15.         let (side_rusto_x, side_rusto_y) = *self.rusto_pos.get(&main_rusto).unwrap();
  16.         if side_rusto_x < main_rusto_x {
  17.             Position::OnLeft
  18.         } else if side_rusto_x > main_rusto_x {
  19.             Position::OnRight
  20.         } else if side_rusto_y < main_rusto_y {
  21.             Position::OnTop
  22.         } else {
  23.             Position::OnBottom
  24.         }
  25.     }
  26. }
  27.  
  28. struct Blob {
  29.     rustos: Vec<u32>
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement