forked from Maxluli/RustyPropagation
Use new() impl for humans
This commit is contained in:
15
src/human.rs
15
src/human.rs
@@ -15,13 +15,14 @@ pub struct Human {
|
|||||||
pub y : i32,
|
pub y : i32,
|
||||||
}
|
}
|
||||||
impl Human{
|
impl Human{
|
||||||
// pub fn new(state : State, pos_x :i32, pos_y :i32) -> Self{
|
// humans with state "Normal"
|
||||||
// Self{
|
pub fn new(pos_x :i32, pos_y :i32) -> Self{
|
||||||
// present_state : state,
|
Self{
|
||||||
// x : pos_x,
|
present_state : State::Normal,
|
||||||
// y : pos_y
|
x : pos_x,
|
||||||
// }
|
y : pos_y
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
// pub fn new_empty() -> Self{
|
// pub fn new_empty() -> Self{
|
||||||
// Self{
|
// Self{
|
||||||
// present_state:State::Normal,
|
// present_state:State::Normal,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ impl Population{
|
|||||||
let mut the_humans: Vec<Human> = Vec::with_capacity((width*height) as usize);
|
let mut the_humans: Vec<Human> = Vec::with_capacity((width*height) as usize);
|
||||||
for x in 0..width{
|
for x in 0..width{
|
||||||
for y in 0..height{
|
for y in 0..height{
|
||||||
the_humans.push(Human{present_state: State::Normal, x: x, y: y});
|
the_humans.push(Human::new(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self{
|
Self{
|
||||||
|
|||||||
Reference in New Issue
Block a user