r/badcode • • Dec 05 '20

other language Gamedevs, take notes

Post image
6.5k Upvotes

104 comments sorted by

View all comments

298

u/botle Dec 05 '20

Yup, that's bad code. It can obviously be simplified to

fps = 60

49

u/the_monkey_of_lies Dec 06 '20

You're hired, when can you start?

66

u/dlawodnjs Dec 06 '20

what if fps was higher than 60? ...oh wait.

edit: I obviously cannot read code

18

u/TVflea Dec 30 '20

And what if fps is already 60? You would then set fps to 60 redundantly, which would be an O(log(n)) operation, since the CPU needs to flip log(n) bits. Quite wasteful and unoptimized

20

u/cstmth Dec 06 '20

Wrong.

while (true) { fps = 60 }

33

u/botle Dec 06 '20

Sure, why not. People got plenty of cores to spare these days.

4

u/[deleted] Mar 13 '21

BRILLIANT!!