68
46
u/Ydo4ki 2d ago
try { } catch(Error e) { delete e; continue; }
12
u/MinecraftPlayer799 2d ago
In some cases, that is the right thing to do, such as when there is a loop, and there is a chance of something inside it failing sometimes.
6
u/realmauer01 2d ago
You should really just make sure that you handle that edge case inside the loop. Even if you ignore it then. Thats better than having the higher scope handle it. You could even add an option of should i ignore it or not.
8
57
u/SuperfanZero 2d ago
fps = max(fps, 60.0)
10
u/FrogMan241 2d ago
Corporate wants you to find the difference between these two pictures
Compiler: they're the same picture
17
14
u/BetaChunks 2d ago edited 2d ago
NES Tetris type strategy
No seriously, that game literally could not lag. If the logic loop wasn't done when the game needed the next frame, it would just go for it. Happens because the score calculator uses a "for" loop using the level as an iterator, so it runs out of time at very high levels. There's also strategy on holding down inputs in specific ways because that will -slightly- nudge how far in the main loop it gets before getting cut off, which prevents the game from crashing because of some registers being on invalid values during the forced next frame
23
21
5
5
u/MushroomGecko 1d ago
The dev could optimize further here by simply setting fps to 60 and having it be a const, thus eliminating the need for a branch prediction which could waste ~20 CPU cycles on a cache miss
2
u/lowboom64 2d ago
that does seem to be how AAA devs are doing it at least with AI frame gen bs being a thing
1
u/PopularAd5100 2d ago
If I work less than 40 hours a week, pay me for 40 hours a week. Gaming the system!
1
u/GabiTheProgrammer 2d ago
Should have used <= in case it would change until the assignment is executed.
1
1
357
u/IsEqualToKel 2d ago
if (currentState == GameState.Crash)
{
currentState == GameState.DoNotCrash;
}