JohnathonNow / Bending

A 2D, multiplayer online action game.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Magic numbers abound

JohnathonNow opened this issue · comments

It would be nice if a lot of the magic numbers were moved to constants, especially ones reused (like the size of the screen, the framerate, etc).

Hey! I would like to give this a shot!

Sounds good, thanks!

I see that height, width, fps are already included in the Constants.java file. Is there anything else you would like me o add in there?

So there are just numbers sprinkled throughout the code, as many as can be moved out the better. Some examples:

looks to be some kind of walk cycle,
g.drawString(username, ((x - (username.length())) - viewX) * 3, (y - 40 - viewY) * 3);
is some amount over the player to draw their health meter,
playerHitbox = new Rectangle(x, y, 20, 40);
is the player's size, which should definitely be a constant somewhere, and
// 0 is the down speed
// 1 is the horizontal speed
// 2 is the color
// 3 is deprecated
liquidStats[aList[WATER]][0] = 20;// 5
liquidStats[aList[WATER]][1] = 20;// 9
liquidStats[aList[WATER]][2] = waterColor.getRGB();
liquidStats[aList[WATER]][3] = 30;
liquidStats[aList[ETHER]][0] = 20;// 5
liquidStats[aList[ETHER]][1] = 20;// 9
liquidStats[aList[ETHER]][2] = waterColor.getRGB();
liquidStats[aList[ETHER]][3] = 30;
liquidStats[aList[LAVA]][0] = 14;// 3
liquidStats[aList[LAVA]][1] = 8;// 6
liquidStats[aList[LAVA]][2] = Color.red.getRGB();
liquidStats[aList[LAVA]][3] = 60;
liquidStats[aList[OIL]][0] = 5;// 5
liquidStats[aList[OIL]][1] = 6;// 6
liquidStats[aList[OIL]][2] = oilColor.getRGB();
liquidStats[aList[OIL]][3] = 10;
liquidStats[aList[SAND]][0] = 8;// 1
liquidStats[aList[SAND]][1] = 1;// 1
liquidStats[aList[SAND]][2] = 0;
liquidStats[aList[SAND]][3] = 50;
has some fluid constants with a helpful comment.