31
Programming / Re: I Feel Like Sharing some Code - My Unfinished AOE Class
« on: July 30, 2011, 05:15:41 PM »
Much better, i would skip those empty lines. Your distance calculation e.g. is unecessary long:
Maybe introduce a temporary variable or two in the above two lines.
Skip the enumeration and make discrete classes for cone/circle/square area of effects which share a common class/interface.
Code: [Select]
public double distanceTo(Point otherPoint) {
return Math.sqrt(Math.pow(x - otherPoint.x, 2) + Math.pow(y - otherPoint.y, 2));
}
public double manhattenDistanceTo(Point otherPoint) {
return Math.max(Math.abs(x - otherPoint.x), Math.abs(y - otherPoint.y));
}
Maybe introduce a temporary variable or two in the above two lines.
Skip the enumeration and make discrete classes for cone/circle/square area of effects which share a common class/interface.