diff options
author | Tom Barrett <tombarrett@siu.edu> | 2017-11-24 01:31:41 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-11-24 01:31:41 -0600 |
commit | a853a837b8cb991d8c55496401bef02275139c4e (patch) | |
tree | 0b436b49c15ead9cb572fcb6796bed49cafa8a68 /src/list.rs | |
parent | fb20a0f84419dab4c8949d9a9ca30d3b75f9665c (diff) |
-added giving a grid placement order
Diffstat (limited to 'src/list.rs')
-rw-r--r-- | src/list.rs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/list.rs b/src/list.rs index 6c07c01..2340385 100644 --- a/src/list.rs +++ b/src/list.rs @@ -12,7 +12,7 @@ pub struct List{ impl List { pub fn new(impassable_locations : Vec<Location>) -> List { let mut men = Vec::new(); - for i in 0..3 { + for i in 0..10 { men.push(Character::new('@', Colors::BlueUnit as u8, Location(150,150+i))); } List { @@ -42,6 +42,42 @@ impl List { } } + pub fn give_grid(&mut self, first_location : Location, second_location : Location) { + let mut index = 0; + for i in first_location.0..second_location.0 + 1 { + for j in first_location.1..second_location.1 + 1 { + if index < self.men.len() { + self.men[index].give_destination(Location(i,j)); + index += 1; + } + } + } + for i in second_location.0..first_location.0 { + for j in second_location.1..first_location.1 { + if index < self.men.len() { + self.men[index].give_destination(Location(i,j)); + index += 1; + } + } + } + for i in first_location.0..second_location.0 + 1 { + for j in second_location.1..first_location.1 { + if index < self.men.len() { + self.men[index].give_destination(Location(i,j)); + index += 1; + } + } + } + for i in second_location.0..first_location.0 { + for j in first_location.1..second_location.1 + 1 { + if index < self.men.len() { + self.men[index].give_destination(Location(i,j)); + index += 1; + } + } + } + } + fn get_free_locations(&mut self, location : Location) -> Vec<(Location, usize)> { let mut potential_locations = location.neighbours(Vec::new()); |