Closed immmdreza closed 5 months ago
great job
great job
Thanks, You should checkout new-structure
branch of my fork. it's getting interesting.
Thanks @immmdreza for the great contribution. I was worried that what I've written is not rust in the true sense :D
But... but how can I add color now? I merged this live and wanted to add color later but after the merge, found out that I can not use the crossterm's SetForegroundColor and such anymore. Is it possible for you to add the ANSI color control possibility? Say as a call to draw_char / draw_line?
Thanks @immmdreza for the great contribution. I was worried that what I've written is not rust in the true sense :D
But... but how can I add color now? I merged this live and wanted to add color later but after the merge, found out that I can not use the crossterm's SetForegroundColor and such anymore. Is it possible for you to add the ANSI color control possibility? Say as a call to draw_char / draw_line?
Yeah, I was able to find a quick solution for this and it seems working (#77).
@immmdreza I just checked your PR now It's very great that we have such Talented friends around us And there'll be an opportunity To learn from you guys thank you.
@immmdreza I just checked your PR now It's very great that we have such Talented friends around us And there'll be an opportunity To learn from you guys thank you.
Thank you, I am honored to help.
Changes made
Using traits
Drawable
andStdoutExt
These two traits make life easier. for instance, simply use
and things like that.
Unleash more of enums power
Rust enums can contain data, for instance we can make sure the
DeathCause
enum can only be used if thePlayerStatus
is Death.Use Iterator's method or
for item in items
Instead of looping over indexes, we can loop over objects itself.
can written as
if item are going to be removed while iterating, use
.retain
or.retain_mut
Safety in rust
Don't use
mut
ormut &
where it's forbidden or not necessary. As instance,draw
method should not be able to mutateWorld
's state! and its only duty is to draw.Finally I moved/renamed a lot of namespaces around to make things more clear (at least to myself).