Skip to content

Commit

Permalink
More fixes and the partial return of item templates
Browse files Browse the repository at this point in the history
  • Loading branch information
aehmttw committed Nov 20, 2024
1 parent 92c4a95 commit 6b8d3d3
Show file tree
Hide file tree
Showing 30 changed files with 667 additions and 585 deletions.
1 change: 1 addition & 0 deletions src/main/java/basewindow/BaseWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public abstract class BaseWindow
{
public String buildDate = "";
protected ArrayList<String> overrideLocations = new ArrayList<>();

public BaseShapeRenderer shapeRenderer;
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/main/Tanks.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Date;
import java.util.Properties;

public class Tanks
Expand Down Expand Up @@ -50,13 +51,14 @@ public static void main(String[] args)
{
try
{
File f = new File(Tanks.class.getProtectionDomain().getCodeSource().getLocation().toURI());
String path = f.getPath();

if (relaunch && Game.framework == Game.Framework.lwjgl)
{
// Attempts to relaunch from the .jar file.
try
{
String path = new File(Tanks.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath();

if (path.endsWith(".jar"))
{
String[] command = new String[]{"java", "-XstartOnFirstThread", "-jar", path, "mac"};
Expand Down Expand Up @@ -87,6 +89,11 @@ public static void main(String[] args)
Game.vsync, !Panel.showMouseTarget
);
Game.game.window.antialiasingEnabled = Game.antialiasing;

if (!path.endsWith(".jar"))
Game.game.window.buildDate = "Running from source";
else if (f.exists())
Game.game.window.buildDate = new Date(f.lastModified()).toString();
}

Game.postInitScript();
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/tanks/BiFunction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package tanks;

public interface BiFunction<T, U, R>
{
R apply(T t, U u);
}
10 changes: 5 additions & 5 deletions src/main/java/tanks/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public static void registerMinigame(Class<? extends Minigame> minigame, String n

public static void initScript()
{
version = "Tanks v" + game.readVersionFromFile();
version = "Tanks v" + Game.readVersionFromFile();
player = new Player(clientID, "");
Game.players.add(player);

Expand Down Expand Up @@ -1428,13 +1428,13 @@ public static void loadRandomLevel(int seed)
level.loadLevel();
}

public static String readVersionFromFile() {
public static String readVersionFromFile()
{
ArrayList<String> version = Game.game.fileManager.getInternalFileContents("/version.txt");
if (version == null) {
if (version == null)
return "-1.-1.-1";
} else {
else
return version.get(0);
}
}

}
8 changes: 7 additions & 1 deletion src/main/java/tanks/Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,13 @@ public void drawBar(double offset)
if (Game.framework == Game.Framework.libgdx)
boundary += 40;

Game.game.window.fontRenderer.drawString(boundary + 2, offset + (int) (Panel.windowHeight - 40 + 6), 0.4, 0.4, Game.version);
String v = Game.version;
if ("0123456789".indexOf(v.charAt(v.length() - 1)) == -1 && !(ScreenPartyLobby.isClient && !Game.connectedToOnline))
v = Game.version + " \u00A7255227186064(" + Game.game.window.buildDate + ")";

Game.game.window.fontRenderer.drawString(boundary + 2, offset + (int) (Panel.windowHeight - 40 + 6), 0.4, 0.4, v);
Drawing.drawing.setColor(255, 227, 186);

Game.game.window.fontRenderer.drawString(boundary + 2, offset + (int) (Panel.windowHeight - 40 + 22), 0.4, 0.4, "FPS: " + lastFPS);

Game.game.window.fontRenderer.drawString(boundary + 600, offset + (int) (Panel.windowHeight - 40 + 10), 0.6, 0.6, Game.screen.screenHint);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/tanks/bullet/Bullet.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ public Bullet(double x, double y, Tank t, boolean affectsMaxLiveBullets, ItemBul
idMap.put(this.networkID, this);
}

this.previousRebounds.add(this.tank);

this.drawLevel = 8;

// for (IFixedMenu m : ModAPI.menuGroup)
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/tanks/bullet/BulletInstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public void shoot()
if (this.expired)
return;

Game.eventsOut.add(new EventShootBullet(this));

if (!this.tank.isRemote)
{
this.collisionX = this.posX;
Expand Down Expand Up @@ -209,15 +207,26 @@ public void remoteShoot()
double dX = xTargets.get(i + 1) - iX;
double dY = yTargets.get(i + 1) - iY;

this.posX = iX;
this.posY = iY;
this.posX = iX + dX;
this.posY = iY + dY;

double z = Game.tile_size / 4;
if (i == 0)
z = this.iPosZ;

this.segments.add(new Laser(iX + dX, iY + dY, z, iX, iY, Game.tile_size / 4, this.size / 2, this.getAngleInDirection(iX + dX, iY + dY), this.baseColorR, this.baseColorG, this.baseColorB));
this.segments.add(new Laser(iX, iY, z, iX + dX, iY + dY, Game.tile_size / 4, this.size / 2, this.getAngleInDirection(iX, iY), this.baseColorR, this.baseColorG, this.baseColorB));
this.expired = true;

if (this.hitStun > 0)
{
this.lastX = iX;
this.lastY = iY;
this.lastZ = z;
this.collisionX = iX + dX;
this.collisionY = iY + dY;
this.posZ = Game.tile_size / 4;
this.addElectricEffect();
}
}

Game.movables.add(this);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tanks/generator/LevelGeneratorVersus.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ public static String generateLevelString(int seed)

for (String si: items)
{
Item.ItemStack<?> i = Item.ItemStack.fromString(null, si);
Item.ShopItem i = Item.ShopItem.fromString(si);

// TODO
if (i.item.name.equals("Basic bullet") || i.item.name.equals("Basic mine") || i.item.name.equals("Laser"))
if (i.itemStack.item.name.equals("Basic bullet") || i.itemStack.item.name.equals("Basic mine") || i.itemStack.item.name.equals("Laser"))
continue;

i.item.name = Translation.translate(i.item.name);
i.itemStack.item.name = Translation.translate(i.itemStack.item.name);
itemsString.append(i.toString()).append("\n");
}

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/tanks/gui/Firework.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,18 @@ else if (circle)
if (star)
{
double starRandom = Math.random();
if (starRandom < 0.2)
if (starRandom < 0.1)
starPoints = 4;
else if (starRandom < 0.8)
else if (starRandom < 0.7)
starPoints = 5;
else if (starRandom < 0.85)
else if (starRandom < 0.8)
starPoints = 6;
else if (starRandom < 0.9)
else if (starRandom < 0.85)
starPoints = 7;
else if (starRandom < 0.95)
else if (starRandom < 0.9)
starPoints = 8;
else if (starRandom < 0.95)
starPoints = 9;
else
starPoints = 10;

Expand Down
Loading

0 comments on commit 6b8d3d3

Please sign in to comment.