r/badcode • • Mar 24 '21

c# I was digging through an old group chat back when I was in university, and found this absolute shitpost of a code

Post image
775 Upvotes

47 comments sorted by

166

u/reddit-be-cool Mar 25 '21

... Why? I fail to conceive of any possible application for this. Unless your goal is to cause pain and suffering for the players?

51

u/Alberiman Mar 25 '21

Maybe they had a horror game? This would make the player feel super helpless i bet

42

u/ZedTT Mar 25 '21

I doubt it but that could actually be an interesting effect if you tweaked the numbers a bit and it only happened I'm certain situations.

8

u/fshpsmgc Mar 25 '21

I think, it might be a funny way to do a time limit, while increasing the tension. Start at your native refresh rate, and then decrease the target every N seconds, until you hit 20 FPS or something.
It's, obviously, a super niche thing that would work if you're already doing some 4th wall breaks. Well, if it even works reliably on a technical level, that is

16

u/beclops Mar 25 '21

Yeah, I can't imagine actual framerate issues being scary, unless they're simulated frame rate issues with corresponding animations and stuff so the user at least knows it's on purpose, lol.

81

u/Goontt Mar 25 '21

Yeah also curious what happens when it rolls 0...?

38

u/reddit-be-cool Mar 25 '21

Yeah... does it just halt the game?

8

u/ralphdr1 Mar 25 '21

It probably tries to divide by 0 and crashes

19

u/[deleted] Mar 25 '21

My guess, this is some unit test code to generate erratic frame rates.

11

u/_Ralix_ Mar 25 '21

I suppose it might have been a poor man's version of "let's test how it works on different machines". Still, it has no reason to be in Update.

1

u/RealLethalChicken Jun 03 '21

Congratulations, your framerate is 2fps!

185

u/chadmill3r Mar 24 '21

One out of sixty times, FPS is zero, which might be fun.

39

u/Goontt Mar 25 '21

What would actually happen in this case..?

65

u/devhashtag Mar 25 '21

The screen will show the same frame forever

31

u/Goontt Mar 25 '21

Ah fair enough. And I assume the update loop wouldn’t be called again because of that, completely halting the game/app?

3

u/devhashtag Mar 25 '21

According to the comment, yes

7

u/mukaschultze Mar 25 '21

It simply removes the framerate limit

8

u/Inopmin Mar 25 '21

So give it an actual minute lol

6

u/cordev Mar 25 '21

Less, since this is called once per frame. It should only take a couple seconds on average.

2

u/Inopmin Mar 25 '21

Ah, you’re right LOL

75

u/[deleted] Mar 24 '21

Image Transcription: Code


// Update is called once per frame
void Update () {
    Application.targetFrameRate = Random.Range(0,60);

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

18

u/[deleted] Mar 25 '21

Good Human, thank you!

41

u/teabolaisacool Mar 25 '21

Nice way of making a release stating “Vastly improved stability and load times” once you remove it

20

u/db2 Mar 25 '21

Framerate has been increased 0-60x!

7

u/Ahajha1177 Mar 25 '21

Well, if we include the case that one out of ever 60 seconds has an FPS of 0, then that would increase it infinity-x. Even if we average it out, that's (infinity + something)/60, still infinity-x.

3

u/db2 Mar 25 '21

I saw that, but considered even a marketing critter wouldn't be able to sell infinity.

43

u/[deleted] Mar 24 '21

I need to port this into my PyGame projects! 😍🙃

33

u/falseprophecy8 Mar 25 '21

This is absolutely brilliant

26

u/IamYodaBot Mar 25 '21

absolutely brilliant, this is.

-falseprophecy8


Commands: 'opt out', 'delete'

14

u/0xF013 Mar 25 '21 edited Mar 25 '21

Reminds me of my java adventures with parallel code. I used to randomize some parameters and see which is faster. I should have patented it as ML

9

u/joujoubox Mar 25 '21

Leaked Cybeepunk code

11

u/t0shki Mar 25 '21

I thought moving targets in a videogame is a good thing. Would be boring otherwise.

6

u/DrSandwichMan Mar 25 '21

Why are people downvoting an obvious joke?

1

u/t0shki Mar 25 '21

Lol, didn't even check the numbers until now. Well.. it is seemingly 'controversial' for some reason when it was just a silly wordplay on my part.

2

u/KaiserMazoku Mar 26 '21

Hello Yandere Dev

2

u/jaysuchak33 ifelseifelseifelseifelseifelseifelseifelseifelseifelseifelse Mar 26 '21

I hope you used Time.deltaTime for physics and user input lol

1

u/nuclear_bomb404 Sep 12 '21

FixedUpdate()?

2

u/luturol Mar 24 '21

Ahhhh unity....

1

u/Kazumara Mar 25 '21

That's unity isn't it?

1

u/ilikedankmemes3 Mar 25 '21

Ok that’s kinda funny. Although it should be from 1-60 otherwise it’ll either stop completely or roll off to the max FPS possible.

1

u/[deleted] Mar 25 '21

This is some satan-tier thing i see.

Thank for the idea

2

u/[deleted] Mar 25 '21

[removed] — view removed comment

4

u/fshpsmgc Mar 25 '21

I think, it was a part of some joke game or something, and definitely not a part of any serious effort. This, even at the time of writing, didn't have any practical application and was meant as a shitpost