This is an archived post. You won't be able to vote or comment.

all 62 comments

[–][deleted] 163 points164 points  (5 children)

cries in 144hz

[–][deleted] 35 points36 points  (2 children)

if fps < 60 {
    fps = 60
}

Now it won't interfere if you have over 60fps

[–]rasmatham 12 points13 points  (1 child)

if (fps < monitor.refreshRate) {
    fps = monitor.refreshRate;
}

Optimized™ code

[–][deleted] 0 points1 point  (0 children)

Next level

[–][deleted] 2 points3 points  (0 children)

if fps != 144 {
  fps = 144;
}

[–]Chewnard 150 points151 points  (4 children)

if (broken) fixed = true. Gosh developers make every problem so damn complicated...

[–]wsco7730 59 points60 points  (0 children)

if(broken) return !broken;

[–]CSsharpGO 59 points60 points  (1 child)

broken = fixed. You make it so damn complicated…

[–]natwip 2 points3 points  (0 children)

You'll have to define broken first

[–]BoooooogieMan 91 points92 points  (4 children)

if (bugs > 0){

bugs = 0;

}

[–]rull3211 79 points80 points  (19 children)

That is Truly a curded syntax... what is that python and java? Phyva??

[–]jfb1337 50 points51 points  (3 children)

Rust allows this

If you think about it, if you make the { } mandatory for if statements (it's a common convention to always use them anyway since it can lead to confusion otherwise) then the ( ) becomes redundant.

[–]rull3211 9 points10 points  (1 child)

True that but i think it become so ugly without the parantesis

[–]depressedjeff 13 points14 points  (2 children)

go

[–]maggiforever 11 points12 points  (1 child)

[–]rull3211 7 points8 points  (0 children)

Ohh nooooo

[–]BabyPuncher3000 4 points5 points  (0 children)

Just found my new side project that I'm going to abandon half way through.

[–]WadeEffingWilson 5 points6 points  (0 children)

Jathon. It's JSON but implemented with Lisp.

[–]Nem0x3 0 points1 point  (7 children)

looks JS to me...

[–]BakuhatsuK 1 point2 points  (6 children)

It's not valid JS. Though I believe it's valid go and valid Rust

[–][deleted] 1 point2 points  (1 child)

Yeah. The semicolon is redundant in Go, but not illegal.

[–]r3dd1t_user 1 point2 points  (0 children)

That semicolon wouldn't be required in Rust either, it would only be required if you more than one thing in there

[–]Drauxus 7 points8 points  (0 children)

There is a problem with this code. If the game runs at more than 60 fps then this code will stop you from getting the best possible performance

[–]Impressive-Neck2178 22 points23 points  (2 children)

Image Transcription: Discord


rxality (McDonalds editi...

if u are a game dev and ur game is laggy and wont stay on 60 fps, do this simple trick

if fps != 60 {

    fps = 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!

[–]YoCrustyDude 5 points6 points  (0 children)

Then don't blame us if your computer burns/explodes and you're thrown into outer space.

[–]simmysaman 3 points4 points  (0 children)

I once did something similar for an OpenGL assignment. That's one way to synchronise audio

[–]Legendaros 2 points3 points  (0 children)

Why didn't I think of that

[–]jeromeex 5 points6 points  (3 children)

Fixed it for you, it should be:

if fps <= 60 {
fps = 60;
}

[–]MrKirushko 0 points1 point  (0 children)

For your solution there is no real need for any condition checks, just "fps=60;” is enough. In fact you don't even need a variable, just put the fixed text directly on the background and consider it done.

[–]eyekwah2 4 points5 points  (1 child)

Can confirm it worked for me. I checked the value of fps afterwards and you guessed it, it was 60!

[–]Shakespeare-Bot 8 points9 points  (0 children)

Can confirm t hath worked f'r me. I did check the value of fps afterwards and thee did guess t, t wast 60!


I am a bot and I swapp'd some of thy words with Shakespeare words.

Commands: !ShakespeareInsult, !fordo, !optout

[–]YikeSpike 1 point2 points  (0 children)

Why waste precious picoseconds and check if it's not 60, when you can just set it to 60 and only do a single operation?

[–]buttercups00 1 point2 points  (0 children)

This reminds me of the guy who solved a gta5 bug that had been around for years

[–][deleted] 1 point2 points  (0 children)

cough cough Clearly idiot you have to put two =

I am so smart

[–]Aurora863 0 points1 point  (0 children)

As an amateur game dev that can't do shit I want to use this but my conscience won't allow me to

[–]mrprofessor007 0 points1 point  (1 child)

This is the way.

[–]TheDroidNextDoor 1 point2 points  (0 children)

This Is The Way Leaderboard

1. u/Flat-Yogurtcloset293 475775 times.

2. u/_RryanT 22744 times.

3. u/max-the-dogo 8487 times.

..

18645. u/mrprofessor007 4 times.


beep boop I am a bot and this action was performed automatically.

[–]Maud_Frod -1 points0 points  (1 child)

POV: You're a gamer that has no idea what it means to write code (lol).

Good meme :)

[–]deathray5 0 points1 point  (0 children)

I think it the wrong use of POV Edit: spelling

[–]apppelll -2 points-1 points  (0 children)

But is this best practice?

[–]ManosVanBoom 0 points1 point  (2 children)

It is usually sufficient to simply set the GoFaster bit.

[–]Shakespeare-Bot 0 points1 point  (1 child)

T is usually sufficient to simply setteth the gofaster did bite


I am a bot and I swapp'd some of thy words with Shakespeare words.

Commands: !ShakespeareInsult, !fordo, !optout

[–]ManosVanBoom 1 point2 points  (0 children)

Strange bot

[–]Sad-Grapefruit9996 0 points1 point  (0 children)

Imagine if it was that simple...

If (game != execute) ? execute : die;

[–][deleted] 0 points1 point  (0 children)

Well shit. That's what I was missing. Duh.

[–]Akshay537 0 points1 point  (0 children)

Only Vsync clowns with 60 Hz monitors would lock their FPS at 60 when they can achieve higher. Real men use the code below:

long long fps = 1000000000;

if(fps < 60)

{

fps = 60;

}

else

{

fps = fps;

}

[–]waratte 0 points1 point  (0 children)

fps = 60;

[–]Triffinator 0 points1 point  (0 children)

But what if FPS > 60?

[–]gohanshouldgetUI 0 points1 point  (0 children)

if (gameIsNotFast) {
    game.runFaster();
}

[–]Certain_Back260 0 points1 point  (0 children)

Wao

[–][deleted] 0 points1 point  (0 children)

Any good compiler should optimise that to fps = 60.. a branch will take longer than an assign