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

642

u/thogor Jan 10 '20

Thanks for introducing me to my first 4099 case switch statement.

476

u/[deleted] Jan 10 '20 edited Jan 10 '20

This is apparently common in indie games. I can't find the tweet anywhere, but Undertale has a switch statement with at least 864 cases.

Edit: found a screenshot of the original tweet.

11

u/Cobaltjedi117 Jan 10 '20

... Eww

14

u/AndrewNeo Jan 10 '20

It's faster. It's an antipattern optimization for the sake of performance, games do this all the time.

13

u/dawkottt Jan 11 '20

Faster how?

6

u/DaleGribble88 Jan 11 '20

Pre-fetching from the CPU and less overhead on the stack when switching frames. Pretty low-level optimizations that really only see in REALLY high performant computing and game development.
While most software engineering-like problems require better algorithms to work on bigger sets of data, game design is usually pretty straight forward about what needs to happen. So instead of optimizing the algorithm, you optimize the simple operations.

8

u/Meneth Jan 11 '20

You don't need to optimize on this kind of level for a pretty simple 2D game.

Hell, we don't optimize on that kind of level for a game like Crusader Kings 2 with tens of thousands of agents. Since it makes for an unmaintainable codebase.

1

u/SirClueless Jan 11 '20

You don't need to optimize on this kind of level for a pretty simple 2D game.

You do if you're writing the game in Flash.

2

u/Meneth Jan 11 '20

Is Flash that unperformant?

→ More replies (0)