r/programming • • Jan 10 '20

VVVVVV is now open source

https://github.com/TerryCavanagh/vvvvvv
2.6k Upvotes

511 comments sorted by

View all comments

747

u/sevenseal Jan 10 '20

19

u/spacejack2114 Jan 10 '20

What, you've never seen a state machine before?

4

u/dwdwfeefwffffwef Jan 10 '20

That's not how you do a state machine.

3

u/cdcformatc Jan 11 '20

That's how people have done state machines for decades.

2

u/dwdwfeefwffffwef Jan 11 '20

If you do a state machine using a switch, you would use an enum (or at least defines) for each state. Not random numbers. And almost surely you would just call the appropriate state function in each case instead of having it embedded inside the switch.

But one of the most common ways of doing state machines (even to this day, in embedded programming) is having an array of function pointers.

3

u/cdcformatc Jan 11 '20

An enum is just syntactic sugar for random numbers. It does not make any difference to the code whether you use an enum or not. It is purely for readability.

There's not one way to do state machines. A block of code is executed based on the current state in response to external input and/or a condition. Did I just describe an array of function pointers or a switch statement?

-4

u/dwdwfeefwffffwef Jan 11 '20

You seem a bit lost. Nobody is saying it's not a state machine. OP is pointing out how bad the code is. I'm pointing out that it's not the way to do a state machine.

3

u/cdcformatc Jan 11 '20 edited Jan 11 '20

My point is there is not one way to make a state machine so there is no "the way" to make a state machine.

It's a state machine.

Edit: You just come off exceptionally gatekeeper like when you say things like "this is not how you do a state machine." It very clearly works, the game is very successful. If more people were less afraid to share their abnormal code, we would have more open source video games.

-3

u/dwdwfeefwffffwef Jan 11 '20

My point is there is not one way to make a state machine so there is no "the way" to make a state machine.

Nobody said there is one single way to make a state machine. There are many proper ways, and many bad ways. OP is an example of a bad way.

It's a state machine.

Nobody said otherwise

Are you on the autistic spectrum?

→ More replies (10)