harofax / mt_septune

discover the town of septune in glorious stereo-color and real life ascii characters
1 stars 0 forks source link

Quick suggestion! #1

Open Zij-IT opened 3 years ago

Zij-IT commented 3 years ago

Heyyo!

Found your project thanks to r/roguelikedev, and was given it a look when I noticed that your code in main.rs reset_game_state is the exact same as the code in State::new()

That made me wonder if you could write the following instead? Hope to see more of your stuff on reddit!

fn reset_game_state(&mut self) {
    *self = State::new();
}
harofax commented 3 years ago

Heyyo!

Found your project thanks to r/roguelikedev, and was given it a look when I noticed that your code in main.rs reset_game_state is the exact same as the code in State::new()

That made me wonder if you could write the following instead? Hope to see more of your stuff on reddit!

fn reset_game_state(&mut self) {
    *self = State::new();
}

WOAH I completely missed this!!!~ Never thought anyone would actually check this. I tried it out and yeah, that absolutely works! A few other DRY instances bug me, but I'm going to flesh out the game a bit more before tackling them. Good catch, and thank you so much for stopping by!