-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tanks 0.5.0 - Added Crusades, the shop, the hotbar, and 3 new tanks (…
…Cyan, Blue, Maroon), and made other various improvements
- Loading branch information
Showing
90 changed files
with
2,003 additions
and
602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package tanks; | ||
|
||
public abstract class AreaEffect extends Movable | ||
{ | ||
public double duration = 500; | ||
public boolean constantlyImbue = true; | ||
public double age = 0; | ||
public double maxAge = 1000; | ||
|
||
public AreaEffect(double x, double y) | ||
{ | ||
super(x, y); | ||
this.drawAbove = true; | ||
} | ||
|
||
@Override | ||
public void checkCollision() | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public void update() | ||
{ | ||
this.age += Panel.frameFrequency; | ||
|
||
if (constantlyImbue) | ||
{ | ||
this.imbueEffects(); | ||
} | ||
|
||
if (this.age > this.maxAge) | ||
Game.removeMovables.add(this); | ||
} | ||
|
||
public abstract void imbueEffects(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package tanks; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
import tanks.AttributeModifier.Operation; | ||
|
||
public class AreaEffectFreeze extends AreaEffect | ||
{ | ||
double size = 300; | ||
public AreaEffectFreeze(double x, double y) | ||
{ | ||
super(x, y); | ||
this.constantlyImbue = false; | ||
this.imbueEffects(); | ||
this.maxAge = 600; | ||
} | ||
|
||
@Override | ||
public void imbueEffects() | ||
{ | ||
if (Game.fancyGraphics) | ||
{ | ||
for (int i = 0; i < 200; i++) | ||
{ | ||
Effect e = Effect.createNewEffect(this.posX, this.posY, Effect.EffectType.piece); | ||
int var = 50; | ||
e.col = new Color((int) Math.min(255, Math.max(0, 255 + Math.random() * var - var / 2)), (int) Math.min(255, Math.max(0, 255 + Math.random() * var - var / 2)), (int) Math.min(255, Math.max(0, 255 + Math.random() * var - var / 2))); | ||
e.setPolarMotion(Math.random() * 2 * Math.PI, Math.random() * this.size / 200.0); | ||
e.maxAge *= 4; | ||
Game.effects.add(e); | ||
} | ||
} | ||
|
||
for (int i = 0; i < Game.movables.size(); i++) | ||
{ | ||
Movable m = Game.movables.get(i); | ||
|
||
if (Movable.distanceBetween(this, m) <= this.size / 2) | ||
{ | ||
AttributeModifier a = new AttributeModifier("freeze", "velocity", Operation.multiply, -1); | ||
a.duration = 600; | ||
a.warmupAge = 50; | ||
a.deteriorationAge = 500; | ||
m.attributes.add(a); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void draw(Graphics g) | ||
{ | ||
double size = Math.min(this.size + Game.tank_size / 2, this.age * 8); | ||
for (int i = (int) Math.max(0, size - ((int) (50 * Math.min(100, 600 - this.age) / 100.0))); i < size; i += 2) | ||
{ | ||
g.setColor(new Color(200, 255, 255, 10)); | ||
Drawing.window.fillOval(g, this.posX, this.posY, i, i); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package tanks; | ||
|
||
import java.util.UUID; | ||
|
||
public class AttributeModifier | ||
{ | ||
enum Operation {add, multiply} | ||
|
||
/**An unique name for the modifier, to prevent double effects*/ | ||
public String name = UUID.randomUUID().toString(); | ||
|
||
/**Duration of the Attribute Modifier, leave at 0 for indefinite duration*/ | ||
public double duration = 0; | ||
|
||
/**Age at which the Attribute starts to wear off*/ | ||
public double deteriorationAge = 0; | ||
|
||
/**Age at which the Attribute is at full strength*/ | ||
public double warmupAge = 0; | ||
|
||
public double value; | ||
|
||
public Operation effect; | ||
|
||
protected double age; | ||
|
||
public boolean expired = false; | ||
|
||
public String type; | ||
|
||
public AttributeModifier(String type, Operation op, double amount) | ||
{ | ||
this.type = type; | ||
this.effect = op; | ||
this.value = amount; | ||
} | ||
|
||
public AttributeModifier(String name, String type, Operation op, double amount) | ||
{ | ||
this(type, op, amount); | ||
this.name = name; | ||
} | ||
|
||
public void update() | ||
{ | ||
this.age += Panel.frameFrequency; | ||
|
||
if (this.age > this.duration) | ||
this.expired = true; | ||
} | ||
|
||
public double getValue(double in) | ||
{ | ||
double val = 0; | ||
|
||
if (this.expired) | ||
return in; | ||
else if (this.age < this.warmupAge) | ||
val = this.value * this.age / this.warmupAge; | ||
else if (this.age < this.deteriorationAge || this.deteriorationAge <= 0) | ||
val = this.value; | ||
else | ||
val = this.value * (this.duration - this.age) / (this.duration - this.deteriorationAge); | ||
|
||
if (this.effect == Operation.add) | ||
return in + val; | ||
else if (this.effect == Operation.multiply) | ||
return in * (val + 1); | ||
else | ||
return in; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.