Skip to content

Commit

Permalink
Tanks v1.3.2 - bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aehmttw committed Mar 26, 2022
1 parent 9b23361 commit 595307d
Show file tree
Hide file tree
Showing 31 changed files with 443 additions and 217 deletions.
2 changes: 1 addition & 1 deletion src/main/java/basewindow/ModelPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public abstract static class ShapeDrawer
public abstract void drawShape(ModelPart m, Shape s, double posX, double posY, double sX, double sY, double yaw);
}

@Deprecated
//@Deprecated
public static class Quad extends Shape
{
public Quad(Point a, Point b, Point c, Point d, double brightness)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/tanks/CrusadePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@ public int getItemHits(String i)

public void addItemStat(HashMap<String, Integer> stat, IGameObject i)
{
tanks.hotbar.item.Item item;
Item item;

if (i instanceof tanks.hotbar.item.Item)
item = (tanks.hotbar.item.Item) i;
if (i instanceof Item)
item = (Item) i;
else if (i instanceof Bullet)
{
item = ((Bullet) i).item;

if (item == null)
item = TankPlayer.default_bullet;
}
else if (i instanceof Mine)
else if (i instanceof Explosion)
{
item = ((Mine) i).item;
item = ((Explosion) i).item;

if (item == null)
item = TankPlayer.default_mine;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tanks/Effect.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class Effect extends Movable implements IDrawableWithGlow
{
public enum EffectType {fire, smokeTrail, trail, ray, mineExplosion, laser, piece, obstaclePiece, obstaclePiece3d, charge, tread, darkFire, electric, healing, stun, bushBurn, glow, teleporterLight, teleporterPiece, interfacePiece, snow, shield, boostLight, exclamation}
public enum EffectType {fire, smokeTrail, trail, ray, explosion, laser, piece, obstaclePiece, obstaclePiece3d, charge, tread, darkFire, electric, healing, stun, bushBurn, glow, teleporterLight, teleporterPiece, interfacePiece, snow, shield, boostLight, exclamation}

public enum State {live, removed, recycle}

Expand Down Expand Up @@ -94,7 +94,7 @@ else if (type == EffectType.trail)
this.maxAge = 50;
else if (type == EffectType.ray)
this.maxAge = 20;
else if (type == EffectType.mineExplosion)
else if (type == EffectType.explosion)
{
this.maxAge = 20;
this.force = true;
Expand All @@ -113,7 +113,7 @@ else if (type == EffectType.obstaclePiece3d)
else if (type.equals(EffectType.charge))
{
if (Game.enable3d)
this.add3dPolarMotion(Math.random() * Math.PI * 2,-Math.random() * Math.PI / 2, Math.random() * 3 + 3);
this.add3dPolarMotion(Math.random() * Math.PI * 2, -Math.atan(Math.random()), Math.random() * 3 + 3);
else
this.addPolarMotion(Math.random() * Math.PI * 2, Math.random() * 3 + 3);

Expand Down Expand Up @@ -271,7 +271,7 @@ else if (this.type == EffectType.ray)
else
drawing.fillOval(this.posX, this.posY, size, size);
}
else if (this.type == EffectType.mineExplosion)
else if (this.type == EffectType.explosion)
{
double size = (radius * 2);
double opacity = (100 - this.age * 5);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/tanks/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public enum Framework {lwjgl, libgdx}
public static double[][] tilesDepth = new double[28][18];

//Remember to change the version in android's build.gradle and ios's robovm.properties
public static final String version = "Tanks v1.3.1";
public static final String version = "Tanks v1.3.2";
public static final int network_protocol = 39;
public static boolean debug = false;
public static boolean traceAllRays = false;
Expand Down Expand Up @@ -296,6 +296,7 @@ public static void registerEvents()
NetworkEventMap.register(EventLayMine.class);
NetworkEventMap.register(EventMineExplode.class);
NetworkEventMap.register(EventMineChangeTimer.class);
NetworkEventMap.register(EventExplosion.class);
NetworkEventMap.register(EventTankTeleport.class);
NetworkEventMap.register(EventTankUpdateVisibility.class);
NetworkEventMap.register(EventTankUpdateColor.class);
Expand Down Expand Up @@ -440,6 +441,7 @@ public static void initScript()
registerTank(TankPink.class, "pink", 1.0 / 12);
registerTank(TankMini.class, "mini", 0);
registerTank(TankLightPink.class, "lightpink", 1.0 / 10);
//registerTank(TankTest.class, "test", 1.0 / 1);
registerTank(TankBoss.class, "boss", 1.0 / 40, true);

registerBullet(Bullet.class, Bullet.bullet_name, "bullet_normal.png");
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/tanks/Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,10 @@ else if (((ScreenGame) Game.screen).spectatingTank instanceof TankPlayerRemote)
else
speed = 0.02;

this.zoomTimer = Math.max(this.zoomTimer + speed * Panel.frameFrequency, Panel.zoomTarget);
if (this.zoomTimer > Panel.zoomTarget)
this.zoomTimer = Math.max(this.zoomTimer + speed * Panel.frameFrequency, Panel.zoomTarget);
else
this.zoomTimer = Math.min(this.zoomTimer + speed * Panel.frameFrequency, Panel.zoomTarget);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/tanks/bullet/Bullet.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ public void update()
this.item.liveBullets--;
}

this.onDestroy();
if (!this.isRemote)
this.onDestroy();
}

if (this.destroyTimer <= 0 && Game.effectsEnabled && !(this instanceof BulletFlame))
Expand Down
36 changes: 26 additions & 10 deletions src/main/java/tanks/bullet/BulletArc.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,35 @@ public void update()

if (this.posZ <= Game.tile_size / 2 && !this.destroy)
{
double dif = (this.posZ - Game.tile_size / 2) / this.vZ;
this.posX -= dif * this.vX;
this.posY -= dif * this.vY;
if (this.bounces > 0)
{
this.bounces--;
this.posZ += 2 * ((Game.tile_size / 2) - this.posZ);
this.vZ = Math.abs(this.vZ) * 0.75;

if (!this.tank.isRemote)
this.checkCollision();

this.vX = 0;
this.vY = 0;
this.vZ = 0;
this.checkCollisionLocal();
}
else
{
double dif = (this.posZ - Game.tile_size / 2) / this.vZ;
this.posX -= dif * this.vX;
this.posY -= dif * this.vY;

if (!this.tank.isRemote)
this.checkCollision();
this.vX = 0;
this.vY = 0;
this.vZ = 0;

if (!this.tank.isRemote)
this.checkCollision();

this.checkCollisionLocal();

this.destroy = true;
}

this.checkCollisionLocal();
this.destroy = true;
Drawing.drawing.playSound("bullet_explode.ogg", (float) (Bullet.bullet_size / this.size));
}

Expand Down
50 changes: 50 additions & 0 deletions src/main/java/tanks/bullet/BulletElectric.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,54 @@ public void addDestroyEffect()
}
}
}

@Override
public void collided()
{
double dist = Math.sqrt(Math.pow(this.collisionX - this.lastX, 2) + Math.pow(this.collisionY - this.lastY, 2));

double r = 200;
boolean glows = false;
double size = 0.25;

if (Game.fancyBulletTrails)
{
for (int j = 0; j < 2; j++)
{
int segs = (int) ((Math.random() * 0.4 + 0.8) * dist / 50);

double lX = this.lastX;
double lY = this.lastY;
double lZ = this.lastZ;

for (int i = 0; i < segs; i++)
{
double frac = (i + 1.0) / (segs + 1);
double nX = (1 - frac) * this.lastX + frac * this.collisionX + (Math.random() - 0.5) * 50;
double nY = (1 - frac) * this.lastY + frac * this.collisionY + (Math.random() - 0.5) * 50;
double nZ = (1 - frac) * this.lastZ + frac * this.posZ + (Math.random() - 0.5) * 30;
Laser l = new Laser(lX, lY, lZ, nX, nY, nZ, this.size * size, this.getAngleInDirection(this.lastX, this.lastY), r, 255, 255);
l.glows = glows;
this.segments.add(l);
lX = nX;
lY = nY;
lZ = nZ;
}
Laser l = new Laser(lX, lY, lZ, this.collisionX, this.collisionY, this.posZ, this.size * size, this.getAngleInDirection(this.lastX, this.lastY), r, 255, 255);
l.glows = glows;
this.segments.add(l);
}
}

this.segments.add(new Laser(this.lastX, this.lastY, this.lastZ, this.collisionX, this.collisionY, this.posZ, this.size / 2, this.getAngleInDirection(this.lastX, this.lastY), this.baseColorR, this.baseColorG, this.baseColorB));
this.lastX = this.collisionX;
this.lastY = this.collisionY;
this.lastZ = this.posZ;

if (!this.isRemote)
{
this.xTargets.add(this.collisionX);
this.yTargets.add(this.collisionY);
}
}
}
7 changes: 3 additions & 4 deletions src/main/java/tanks/bullet/BulletExplosive.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tanks.Game;
import tanks.event.EventLayMine;
import tanks.hotbar.item.ItemBullet;
import tanks.tank.Explosion;
import tanks.tank.Mine;
import tanks.tank.Tank;

Expand Down Expand Up @@ -36,10 +37,8 @@ public BulletExplosive(Double x, Double y, Integer bounces, Tank t, ItemBullet i
@Override
public void onDestroy()
{
Mine m = new Mine(this.posX, this.posY, 0, this.tank);
m.item = this.item;
Game.eventsOut.add(new EventLayMine(m));
Game.movables.add(m);
Explosion e = new Explosion(this.posX, this.posY, Mine.mine_radius, this.damage, true, this.tank, this.item);
e.explode();
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/tanks/bullet/Laser.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Laser extends Movable implements IDrawableWithGlow
public boolean backCircle = true;
public boolean showOutsides = true;

public boolean glows = true;

public Tank tank1;
public Tank tank2;

Expand Down Expand Up @@ -118,6 +120,9 @@ public void draw()

public void drawGlow()
{
if (!glows)
return;

double ox = Math.cos(this.angle + Math.PI / 2);
double oy = Math.sin(this.angle + Math.PI / 2);

Expand Down
68 changes: 68 additions & 0 deletions src/main/java/tanks/event/EventExplosion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package tanks.event;

import io.netty.buffer.ByteBuf;
import tanks.Game;
import tanks.tank.Explosion;
import tanks.tank.Mine;
import tanks.tank.Tank;

public class EventExplosion extends PersonalEvent
{
public int tank;
public double posX;
public double posY;
public double radius;
public boolean destroysObstacles;

public EventExplosion()
{

}

public EventExplosion(Explosion e)
{
this.tank = e.tank.networkID;
this.posX = e.posX;
this.posY = e.posY;
this.radius = e.radius;
this.destroysObstacles = e.destroysObstacles;
}

@Override
public void execute()
{
if (clientID == null)
{
Tank t = Tank.idMap.get(tank);

if (tank == -1)
t = Game.dummyTank;

if (t == null)
return;

Explosion e = new Explosion(this.posX, this.posY, this.radius, 0, destroysObstacles, t);
e.explode();
}
}

@Override
public void write(ByteBuf b)
{
b.writeInt(this.tank);
b.writeDouble(this.posX);
b.writeDouble(this.posY);
b.writeDouble(this.radius);
b.writeBoolean(this.destroysObstacles);
}

@Override
public void read(ByteBuf b)
{
this.tank = b.readInt();
this.posX = b.readDouble();
this.posY = b.readDouble();
this.radius = b.readDouble();
this.destroysObstacles = b.readBoolean();
}
}
12 changes: 1 addition & 11 deletions src/main/java/tanks/event/EventLayMine.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ public class EventLayMine extends PersonalEvent
public double posX;
public double posY;
public double timer;
public double radius;
public double size;
public boolean destroysObstacles;


public EventLayMine()
{

Expand All @@ -29,9 +27,7 @@ public EventLayMine(Mine m)
this.posX = m.posX;
this.posY = m.posY;
this.timer = m.timer;
this.radius = m.radius;
this.size = m.size;
this.destroysObstacles = m.destroysObstacles;
}

@Override
Expand All @@ -50,8 +46,6 @@ public void execute()
Mine m = new Mine(this.posX, this.posY, this.timer, t);
m.networkID = id;
m.size = size;
m.radius = radius;
m.destroysObstacles = destroysObstacles;
Game.movables.add(m);

Mine.idMap.put(id, m);
Expand All @@ -66,9 +60,7 @@ public void write(ByteBuf b)
b.writeDouble(this.posX);
b.writeDouble(this.posY);
b.writeDouble(this.timer);
b.writeDouble(this.radius);
b.writeDouble(this.size);
b.writeBoolean(this.destroysObstacles);
}

@Override
Expand All @@ -79,8 +71,6 @@ public void read(ByteBuf b)
this.posX = b.readDouble();
this.posY = b.readDouble();
this.timer = b.readDouble();
this.radius = b.readDouble();
this.size = b.readDouble();
this.destroysObstacles = b.readBoolean();
}
}
3 changes: 2 additions & 1 deletion src/main/java/tanks/event/EventMineExplode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tanks.event;

import io.netty.buffer.ByteBuf;
import tanks.Game;
import tanks.tank.Mine;

public class EventMineExplode extends PersonalEvent
Expand Down Expand Up @@ -28,7 +29,7 @@ public void execute()
if (m == null)
return;

m.explode();
Game.removeMovables.add(m);

if (!Mine.freeIDs.contains(m.networkID))
{
Expand Down
Loading

0 comments on commit 595307d

Please sign in to comment.