private static int rotateMeATerminalLikeIts1999(int code) {
switch (code) {
case -1610612715:
return -90;
case 1610612757:
return 90;
case 21:
return 0;
case -1073741803:
return 180;
}
return 45; // never
}
Because, if you have a bug where the images (of a 'terminal') didn't rotate correctly, and you're up against it, why not map some arbitrary image related integer to a rotation angle?
No, return 45 will never get hit, but if it did, we'd hopefully just notice because the graphic would be at 45 degrees tilt and not at right angles?
Slightly better would be to replace return 45 with 'throw new RuntimeException' or even Gdx.app.exit() but then you might introduce a game-breaking bug, right? The clock is ticking...
// not '3', this is the initial offset based on half the play area
MAGIC_NUMBER = -((backdrop.getHeight()/2f)-cam.position.y);
MAGIC_NUMBERX = -((backdrop.getWidth()/2f)-cam.position.x);
// 'MAGIC NUMBER' then used to do mad stuff like this:
lights.add(new Light(2181+MAGIC_NUMBERX, 360+MAGIC_NUMBER, colors[4], true));
lights.add(new Light(2880+MAGIC_NUMBERX, 997+MAGIC_NUMBER, colors[4], true));
lights.add(new Light(1465.4338f+MAGIC_NUMBERX, 1121.5204f+MAGIC_NUMBER, Color.BLUE, true, true, true, 0));
lights.add(new Light(1438.8075f+MAGIC_NUMBERX, 1114.8617f+MAGIC_NUMBER, Color.RED, true, true, false, 0));
Carnage this one, but things eventually lined up perfectly. Mansion Hunt had multiple layers to the playing area, for the flooring, and the walls, to separate lighting occluders from the main playing area, and they had to move together.
There's so many possible failure cases for this including change in resolution, or level backdrop resize, and unbelievably stupid to maintain.
I'm happy to report this only existed in Mansion Hunt and didn't make a reappearance in Dungeon Crumble where it was done, er.. "better" :)
//This is dumb. I should change this into something that doesn't make the game take longer to load.
LinkedList<Integer> initKeys = new LinkedList<>();
for (int i = 0; i < Gdx.graphics.getWidth()*Gdx.graphics.getHeight(); i++ ) {
initKeys.add(MathUtils.round(MathUtils.random(Keys.UP, Keys.RIGHT)));
}
for (int key : initKeys) {
keys[key] = true;
updatePlayerMovement(Gdx.graphics.getDeltaTime(), true);
keys[key] = false;
}
This one's classic 3am code that doesn't look pretty in the cold light of day.
That's right, to 'randomize' the player start position this moves either UP or RIGHT lots of times. The entire screen of pixels to be exact, so if that's a 1920x1080 window we'll randomly move the player a little over TWO MILLION times.
Understandably comes with the comment that this makes the game longer to load - this is done in create before render() kicks in.
/**
* Does what it says on the tin - a fake stackTrace
* when you can't be bothered running a proper debugger
*/
public static void fakeTrace() {
try {
throw new RuntimeException("fake as hell");
} catch (RuntimeException e) {
System.err.println(e.getMessage());
e.printStackTrace(System.err);
}
}
In most IDEs for nearly as long as they have existed, the debug button tends to be next to the run button. And breakpoints are a thing.
In the .js or .coffeescript file that was the server process, it was originally edited in gedit in Linux, but here? there's no excuse for this.
It is referenced by bits of code that 'should never fire' - this would simply dump the stack trace out if hit, and not interrupt execution, but that's also bad because what's the game state in when 'should never get here' is reached?