JohnathonNow / Bending

A 2D, multiplayer online action game.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Circle functions operate on diameter instead of radius

JohnathonNow opened this issue · comments

All of the circle functions for modifying terrain in World.java have a parameter r or R that act as a diameter and not radius. For example:

/**
* Clears a circle using the standard square method
*
* @param X - X coordinate of the circle's center
* @param Y - Y coordinate of the circle's center
* @param R - Radius of the circle
*/
public void ClearCircle(int X, int Y, int R) {
// long time = System.nanoTime();
for (int i1 = Math.max(X - (R + 1), 0); i1 < Math.min(X + (R + 1), w); i1++) {
for (int i2 = Math.max(Y - (R + 1), 0); i2 < Math.min(Y + (R + 1), h); i2++) {
if (Math.pow(i1 - X, 2) + Math.pow(i2 - Y, 2) < Math.pow((R / 2), 2)) {
if (cellData[i1][i2] == OIL) {
if (random.nextInt(10) == 2) {
cellData[i1][i2] = AIR;
// oilExplode(i1, i2);
entityList.add(new ExplosionEntity(i1, i2, 8, 1));
ClearCircle(i1, i2, 10);
}
} // if (cellData[i1][i2]!=STONE)
if (cellData[i1][i2] != CRYSTAL && cellData[i1][i2] != ETHER) {
cellData[i1][i2] = AIR;
}
}
}
}

R here is treated as a diameter. These functions should carefully be changed to actually treat R/r as a radius, as well as have their calls changed accordingly.