Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

#gamedev

refactored hero logic into state pattern. So much better!

Code screenshot showing state pattern (left) and previous version.





Interactions

Reply from Oto Šťáva:

@h4kor Very nice! By the way, in Zig you don't need that assert at the top, the .? operator already does that exact same assertion for you.


(Original Post)

Liked by Oto Šťáva

Reply from theludovyc:

@h4kor Great, more readable ! Maybe if you want to go further, you can create a State class 😊 https://refactoring.guru/design-patterns/state


(Original Post)

Reply from fritzlolpro:

@h4kor gamedev is where patterns truly shine


(Original Post)

Liked by fritzlolpro

Liked by OtterSpace