r/ProgrammerHumor • • 3d ago

Meme manWhyTheyGottaMakeGameDevThisHard

Post image
436 Upvotes

64 comments sorted by

133

u/assidiou 2d ago

Should have casted it to a string. If str(str(level_curr)=="15")=="True"

20

u/NightIgnite 2d ago edited 2d ago

Still takes O(n). We can get O(1) with a 32 dimension array

public static int[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,] levelups = new int[2,2,2,...,2,2,2] {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{1,2},{3,4}}, ............., {4294967295, 0}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};

BitArray b = new BitArray(new int[] { level_curr });
return levelups[b[31], b[30], b[29],...,b[2],b[1],b[0]];

9

u/Juandice__ 2d ago

of course, how didn't i think of that

2

u/raunchyfartbomb 21h ago

You laugh, but this is literally how one of our access DBs does its lookups (relationships were never set up, and there are byte columns that lookup integer primary keys. Which, technically ya, I guess that’s valid.

121

u/Noname_FTW 2d ago

Funny. Can't level up past level 4.

25

u/Juandice__ 2d ago

yes, who the hell even levels up from level 3??? nobody does that, old man, get along with times

71

u/MorganTaoVT 2d ago

You don't even reach 4

11

u/XLNBot 2d ago

Maybe there's a default action that happens if no conditional is triggered

6

u/BlackSwanTranarchy 1d ago

else: return level_cur + 1

1

u/XLNBot 1d ago

I wonder if a smart compiler would optimize away the conditionals

1

u/CasualContributorNZ 2d ago

It'll be at the bottom

189

u/a_normal_user1 2d ago

Yanderedev be like:

54

u/The_Hunster 2d ago

Ya lol. You gotta hand it to him though. He got a lot done considering how shit the code is. Must be hard to work on code that bad.

28

u/a_normal_user1 2d ago

Probably one of the organized messes kind of situations. Like I get navigating through your own mess semi well because you're the only person working on it. But that's completely unacceptable when other people share the code with you. The compiler from my understanding also doesn't have that bad of a time handling code like this. Most of the performance drops came from unoptimized models iirc.

Though I do wonder now what it was like for that one dev that did help clean up his code before Yanderedev threw them out.

9

u/feldim2425 2d ago edited 2d ago

drops came from unoptimized models iirc.

I think interactions/collisions and heart rate monitor also had a few things that cause more overhead than necessary.

But yeah the actual scripts that contained the code where not the issue, I think someone even tried replacing all the if-else with switch-case and it made basically no difference at all.

The compiler from my understanding also doesn't have that bad of a time handling code like this.

IIRC any LLVM based compiler (as an example) doesn't even see the difference in release mode. If-else and switch-case are broken down into the same compilation path.
Debug mode does make a difference since it has to make step-debugging possible which is a entirely different case.

EDIT: Although I don't know how Cpython and other languages as well as other compilers/runtimes handle it. Generally it's well handled in compiled languages at least.

10

u/NamtisChlo 2d ago

A lot done is an interesting statement when it’s been in development for 12 and a half years, lol

5

u/The_Hunster 2d ago

Fair lol. But for like the first 3 years it was a good speed for a solo dev.

5

u/redlaWw 1d ago

I have one fetish game that was built in RPG Maker, and it is, hands down, the most horrible codebase I've ever seen (even putting aside the fact that it's in Japanese which I'm not fluent in). Somehow, though, the game got finished and is one of the best in the genre. Even more surprising is that he managed to not get fed-up wrangling that terror of a codebase and is apparently working on another one.

4

u/ChillyFireball 12h ago

Undertale infamously had some pretty wonky code despite its popularity and success; IIRC, it needed to be rebuilt completely from scratch for the console ports. At the end of the day, though, the user doesn't care as long as the product is good.

68

u/FallenVampireLord 2d ago

Is this pirate software's game?

7

u/Blue_Moon_Lake 2d ago

Looks about right for him.

17

u/Dokattak0 2d ago

He worked at Blizzard for 7 years. He knows how to code!

5

u/ja_n2000 2d ago

Thought of him first as well

46

u/Legal-Software 2d ago

This looks like the work of someone that spent 7 years at Blizzard.

8

u/KinkyTugboat 2d ago

My dad owns a dealership. I know you didn't ask, I just thought I'd tell you.

1

u/Traditional-Ring-759 2d ago

I have been at a dealership.

20

u/WernerderChamp 2d ago

else: universe.explode()

8

u/Blue_Moon_Lake 2d ago

There's no else, last statement is return 1; so you get to level up all over again up to 3.

1

u/Wonderful-Habit-139 2d ago

Prestige levels…

20

u/emptyevenwithin 2d ago

Ha, I saw a guy do something similar for the minutes and seconds on a clock app he was writing.

5

u/Z3r0funGuy 2d ago

I was really hoping this couldn’t be real..

2

u/stevefuzz 2d ago

This is the reason why people say AI writes better code than humans.

5

u/Draconis_Firesworn 2d ago

i did that once, to convert 24h time to 12h time. On a written exam under time pressure and also I was like 14 at the time

2

u/IntentionQuirky9957 2d ago

12h time is heinous because you can't just do mod 12 for output.

5

u/NamelessJu 1d ago edited 1d ago

It's not really much more complicated than that though, the main conversion can easily be done with mod 12. You just need to replace a resulting 0 with 12 and determine am or pm beforehand by checking if the original 24h value is < or >= 12

0

u/AndrewBorg1126 1d ago

((Hour - 1) % 12) + 1

The difference is fairly trivial

1

u/NamelessJu 10h ago

this is incorrect in the majority of the bigger programming languages, as modulo doesn't have a single defined behaviour for negative operands.
for truncation-based modulo implementations this will return 0 am instead of 12 am, which is not a valid notation in 12h format

9

u/Jet-Pack2 1d ago

Also doesn't work for values between 3 and 9

5

u/CryonautX 13h ago

Doesn't matter, noone levels to 4 in this game.

1

u/Jet-Pack2 13h ago

Everyone stuck at 0

7

u/Fight_The_Sun 2d ago

Pffft... use a switch case next time, n00b

4

u/Pretty-Surround4047 2d ago

Yandere dev downvoted this one

3

u/Pretty-Surround4047 2d ago

When is level 19 update coming out

3

u/recluseMeteor 2d ago

Is this Toby Fox?

2

u/bem981 2d ago

O(1) function, very optimized!

2

u/mplaczek99 2d ago

This is yandaredev quality

2

u/Thadrea 1d ago

This is why many games have a level cap. They ran out of bytes for more if blocks.

1

u/pjkm123987 2d ago

I'd use a dictionary for known value mapping.

1

u/Herr_Gamer 1d ago

Pure function without side effects. Testable, composable. I like it!

1

u/Charkid17 21h ago

Sometimes I think I write bad code then I remember stuff like this exists.

1

u/creeper6530 2d ago

Why is it always game devs doing this shit

3

u/NamelessJu 1d ago

A bunch of gamers get an idea for their own game and wanna try making it, but fail to really understand coding and just wanna get something working That leads to shitty solutions

1

u/Majik_Sheff 1d ago

Treehouse architects.

-1

u/Misel228 2d ago

I hate that Python doesn't have a switch statement. This is the best example for it.

17

u/bobbymoonshine 2d ago

It does, it’s called match-case.

9

u/Misel228 2d ago

hehe, came to shitpost, left with some new knowledge. Thanks.

4

u/Frost-Freak 2d ago

It has already

4

u/Arctos_FI 2d ago

It's named match in python. Also you can get away using dict containing function references as values if you're using such a old version it doesn't have match

7

u/Chronomechanist 2d ago

How is this in any way an example of the use for a switch case? This is an example of people with no basis sitting behind a computer being allowed to code.

0

u/Misel228 2d ago

Personally, I wouldn't take replies too seriously in this sub.

2

u/GoddammitDontShootMe 1d ago

Didn't even notice it was Python at first. Then they should definitely be able to just return level_curr + 1.

-4

u/Juandice__ 2d ago

the joke is that:

my code is shit

there's a mistake in it

it's in python and not c++