News for hackers. Stuff that matters.
Re:Many games are held together by duct tape by seanalltogether on Wednesday January 15, 2020 @11:22AM (#22055552)
Wow a 3440 line switch statement for processing game state!

https://github.com/TerryCavanagh/VVVVVV/blob/master/desktop_...

Re:Many games are held together by duct tape by AstralStorm on Wednesday January 15, 2020 @01:23PM (#22056842)
Explicit state machine is better than an implicit one. And every program is one of these.

4 KLOC for big chunk of game logic is rather frugal.

The main problems that are plain is not enough names (for states, flags and triggers) and not having split off text to some central repository. (Making translation easier.)

Orthodox version of the state machine would have code execute while you're changing states rather than in any given state.

The big switch statement is a good design with mediocre implementation. (Compare with Sierra's AGI LOGIC code: https://wiki.scummvm.org/index.php?title=AGI/Specifications/... )

Re:Many games are held together by duct tape by criddell on Wednesday January 15, 2020 @12:07PM (#22055962)
The giant switch statement doesn't bother me that much. It's essentially just a big table at that point.

What would drive me nuts are the lack of symbols for each case. At least there's a comment for many of them.

Re:Many games are held together by duct tape by _the_inflator on Wednesday January 15, 2020 @12:30PM (#22056186)
And it works! I learned a lot about preventing magic with this here: https://gameprogrammingpatterns.com/state.html

For me - and I mostly do frontend apps now - I always advise to go for state pattern instead of complex if/thens. Thanks to the aforementioned article.

Re:Many games are held together by duct tape by lzralbu on Wednesday January 15, 2020 @12:59PM (#22056537)
Does Redux help with things like this?
Re:Many games are held together by duct tape by davidkpiano on Wednesday January 15, 2020 @01:48PM (#22057113)
If you have enough discipline, sure. Finite state machine tools like XState are more strict about this.
Re:Many games are held together by duct tape by Humdeee on Wednesday January 15, 2020 @12:22PM (#22056107)
I'm not at all accustomed to game design or game code. How is game state normally called upon and saved?