Skip to content

Commit

Permalink
Tanks v1.5.2 full release
Browse files Browse the repository at this point in the history
  • Loading branch information
aehmttw committed Jul 19, 2024
1 parent 713bda6 commit 80f1fed
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/main/java/lwjglwindow/ShaderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void createDepthTexture(int size)
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, (ByteBuffer) null);
glBindTexture(GL_TEXTURE_2D, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tanks/Drawing.java
Original file line number Diff line number Diff line change
Expand Up @@ -1121,13 +1121,13 @@ public void stopMusic()

public void addSyncedMusic(String sound, float volume, boolean looped, long fadeTime)
{
if (Game.game.window.soundsEnabled && Game.musicEnabled)
if (Game.game.window.soundsEnabled && Game.musicEnabled && Game.enableLayeredMusic)
Game.game.window.soundPlayer.addSyncedMusic("/music/" + sound, volume, looped, fadeTime);
}

public void removeSyncedMusic(String sound, long fadeTime)
{
if (Game.game.window.soundsEnabled && Game.musicEnabled)
if (Game.game.window.soundsEnabled && Game.musicEnabled && Game.enableLayeredMusic)
Game.game.window.soundPlayer.removeSyncedMusic("/music/" + sound, fadeTime);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tanks/Effect.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ else if (this.type == EffectType.tutorialProgress)
}
else
{
Game.exitToCrash(new RuntimeException("Invalid effect type!"));
Game.exitToCrash(new RuntimeException("Invalid effect type: " + this.type));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/tanks/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public enum Framework {lwjgl, libgdx}

public static float soundVolume = 1f;
public static float musicVolume = 0.5f;
public static boolean enableLayeredMusic = true;

public static boolean isOnlineServer;
public static boolean connectedToOnline = false;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/tanks/Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ public void setUp()
TankPlayer.controlStick.mobile = TankPlayer.controlStickMobile;
TankPlayer.controlStick.snap = TankPlayer.controlStickSnap;

Hotbar.toggle.posX = Drawing.drawing.interfaceSizeX / 2;
Hotbar.toggle.posY = Drawing.drawing.interfaceSizeY - 20;

Game.createModels();

Game.dummyTank = new TankDummy("dummy",0, 0, 0);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/tanks/bullet/Bullet.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,12 @@ else if (this.bulletHitKnockback <= 0)
l = this;
}

if (this.playBounceSound)
Drawing.drawing.playSound("bump.ogg", (float) (bullet_size / h.size), 1f);

if (h.bulletHitKnockback > 0)
{
h.push(l);
if (this.playBounceSound)
Drawing.drawing.playSound("bump.ogg", (float) (bullet_size / h.size), 1f);
}
else if (this.destroyBullets)
l.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tanks/gui/screen/ScreenCrusadeLevels.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class ScreenLevel
protected Translation translation = new Translation(Game.game.window, 0, 0, 0);

double shadowScaleNum = 0.2;
protected ScaleAboutPoint shadowScale = new ScaleAboutPoint(Game.game.window, shadowScaleNum, shadowScaleNum, shadowScaleNum, 0.5, 0.5, 0.5);
protected ScaleAboutPoint shadowScale = new ScaleAboutPoint(Game.game.window, shadowScaleNum, shadowScaleNum, 1.0, 0.5, 0.5, 0.5);

protected ArrayList<ScreenLevel> levels = new ArrayList<>();
protected HashMap<Integer, ScreenLevel> levelsPos = new HashMap<>();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/tanks/gui/screen/ScreenGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,7 @@ else if (ScreenPartyLobby.isClient)
if (!paused && Game.game.window.touchscreen && !shopScreen)
{
pause.draw();
Drawing.drawing.setColor(255, 255, 255);
Drawing.drawing.drawInterfaceImage("icons/pause.png", pause.posX, pause.posY, 40, 40);

if (Drawing.drawing.enableMovingCamera)
Expand All @@ -2444,6 +2445,7 @@ else if (ScreenPartyLobby.isClient)
if (!Panel.autoZoom)
zoomAuto.draw();

Drawing.drawing.setColor(255, 255, 255);
if (Drawing.drawing.movingCamera)
Drawing.drawing.drawInterfaceImage("icons/zoom_out.png", zoom.posX, zoom.posY, 40, 40);
else
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/tanks/gui/screen/ScreenOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public static void saveOptions(String homedir)
f.println("sound_volume=" + Game.soundVolume);
f.println("music=" + Game.musicEnabled);
f.println("music_volume=" + Game.musicVolume);
f.println("layered_music=" + Game.enableLayeredMusic);
f.println("auto_start=" + Game.autostart);
f.println("full_stats=" + Game.fullStats);
f.println("timer=" + Game.showSpeedrunTimer);
Expand Down Expand Up @@ -341,6 +342,9 @@ public static void loadOptions(String homedir)
case "music":
Game.musicEnabled = Boolean.parseBoolean(optionLine[1]);
break;
case "layered_music":
Game.enableLayeredMusic = Boolean.parseBoolean(optionLine[1]);
break;
case "sound_volume":
Game.soundVolume = Float.parseFloat(optionLine[1]);
break;
Expand Down
36 changes: 33 additions & 3 deletions src/main/java/tanks/gui/screen/ScreenOptionsSound.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

public class ScreenOptionsSound extends Screen
{
public static final String layeredMusicText = "Layered music: ";

public ScreenOptionsSound()
{
this.music = "menu_options.ogg";
Expand All @@ -34,9 +36,14 @@ public ScreenOptionsSound()
soundVolume.r1 = 210;
soundVolume.g1 = 210;
soundVolume.b1 = 210;

if (Game.enableLayeredMusic)
layeredMusic.setText(layeredMusicText, ScreenOptions.onText);
else
layeredMusic.setText(layeredMusicText, ScreenOptions.offText);
}

TextBoxSlider musicVolume = new TextBoxSlider(this.centerX, this.centerY + this.objYSpace * 0.75, this.objWidth, this.objHeight, "Music volume", new Runnable()
TextBoxSlider musicVolume = new TextBoxSlider(this.centerX, this.centerY + this.objYSpace * 0.25, this.objWidth, this.objHeight, "Music volume", new Runnable()
{
@Override
public void run()
Expand All @@ -57,7 +64,7 @@ public void run()
, Math.round(Game.musicVolume * 100f), 0, 100, 1);


TextBoxSlider soundVolume = new TextBoxSlider(this.centerX, this.centerY - this.objYSpace * 0.75, this.objWidth, this.objHeight, "Sound volume", new Runnable()
TextBoxSlider soundVolume = new TextBoxSlider(this.centerX, this.centerY - this.objYSpace * 1.25, this.objWidth, this.objHeight, "Sound volume", new Runnable()
{
@Override
public void run()
Expand All @@ -72,6 +79,26 @@ public void run()
}
, Math.round(Game.soundVolume * 100f), 0, 100, 1);

Button layeredMusic = new Button(this.centerX, this.centerY + this.objYSpace * 1.25, this.objWidth, this.objHeight, "", new Runnable()
{
@Override
public void run()
{
Game.enableLayeredMusic = !Game.enableLayeredMusic;

if (Game.enableLayeredMusic)
layeredMusic.setText(layeredMusicText, ScreenOptions.onText);
else
layeredMusic.setText(layeredMusicText, ScreenOptions.offText);
}
},
"When layered music is enabled, different---" +
"instruments will be added to the soundtrack---" +
"based on criteria such as remaining tank---" +
"types or arcade rampage level.--- ---" +
"This may cause lag and desynchronization---" +
"of music on some devices.");


Button back = new Button(this.centerX, this.centerY + this.objYSpace * 3.5, this.objWidth, this.objHeight, "Back", () -> Game.screen = new ScreenOptions()
);
Expand All @@ -81,6 +108,7 @@ public void update()
{
soundVolume.update();
musicVolume.update();
layeredMusic.update();

back.update();
}
Expand All @@ -89,10 +117,12 @@ public void update()
public void draw()
{
this.drawDefaultBackground();
back.draw();

layeredMusic.draw();
musicVolume.draw();
soundVolume.draw();

back.draw();
Drawing.drawing.setInterfaceFontSize(this.titleSize);
Drawing.drawing.setColor(0, 0, 0);
Drawing.drawing.displayInterfaceText(this.centerX, this.centerY - this.objYSpace * 3.5, "Sound options");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tanks/gui/screen/ScreenSelectorMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public void run()
Drawing.drawing.playVibration("click");
selector.submitEffect();
selector.lastFrame = Panel.panel.ageFrames;
Game.screen = screen;

for (int i = 0; i < selector.options.length; i++)
{
if (selector.selectedOptions[i])
Drawing.drawing.removeSyncedMusic(selector.options[i], 500);
}

Game.screen = screen;
selector.function.run();
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/tanks/gui/screen/ScreenTitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,6 @@ public void drawWithoutBackground()
Drawing.drawing.setInterfaceFontSize(this.titleSize);
Drawing.drawing.displayInterfaceText(this.lCenterX, this.lCenterY - this.objYSpace * 2 / 9, "The Crusades");

for (int i = 0; i < Game.tracks.size(); i++)
{
Game.tracks.get(i).draw();
}

for (int i = Game.movables.size() - 1; i >= 0; i--)
{
Game.movables.get(i).draw();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tanks/gui/screen/ScreenTutorialGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public ScreenTutorialGame()
Game.startTime = 0;
Game.playerTank.setBufferCooldown(50);
}
public Button skip = new Button(this.centerX, this.centerY + 60, 350, 40, "Skip tutorial", () ->

public Button skip = new Button(this.centerX, this.centerY + this.objYSpace, this.objWidth, this.objHeight, "Skip tutorial", () ->
{
try
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public void setPerspective()
}

@Override
public void update()
public void update()
{
if (paused)
skip.update();
Expand All @@ -57,7 +57,7 @@ public void update()
}

@Override
public void draw()
public void draw()
{
super.draw();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tanks/hotbar/Hotbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class Hotbar

public void update()
{
Hotbar.toggle.posX = Drawing.drawing.interfaceSizeX / 2;
Hotbar.toggle.posY = (int) (Drawing.drawing.getInterfaceEdgeY(true) - 12);

if (Game.game.window.touchscreen)
{
this.verticalOffset = 20;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/tanks/tank/Crate.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public Crate(Tank tank)
@Override
public void draw()
{
this.age += Panel.frameFrequency;
if (Game.game.window.drawingShadow || !Game.shadowsEnabled)
this.age += Panel.frameFrequency;

double size = this.size * Obstacle.draw_size / Game.tile_size * Math.min(1, this.age / (Game.tile_size * 1.5));

if (Game.enable3d)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tanks/tank/Tank.java
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,7 @@ public double getAutoZoomRaw()

double xDist = Math.abs(m.posX - boundedX);
double yDist = Math.abs(m.posY - boundedY);
double dist = Math.max(xDist / (Drawing.drawing.interfaceSizeX),
yDist / (Drawing.drawing.interfaceSizeY)) * 3;
double dist = Math.max(xDist / (Drawing.drawing.interfaceSizeX), yDist / (Drawing.drawing.interfaceSizeY)) * 2.2;

if (dist < nearest)
{
Expand Down Expand Up @@ -1127,7 +1126,8 @@ public double getAutoZoomRaw()
public double getAutoZoom()
{
double dist = Math.min(4, Math.max(1, getAutoZoomRaw()));
return 1 / dist;
double targetScale = Drawing.drawing.interfaceScale / dist;
return Math.max(Math.min((targetScale - Drawing.drawing.unzoomedScale) / (Drawing.drawing.interfaceScale - Drawing.drawing.unzoomedScale), 1), 0);
}

public void setBufferCooldown(double value)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/tanks/tank/TankAIControlled.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public enum BulletAvoidBehavior
@TankProperty(category = movementAvoid, id = "bullet_avoid_behavior", name = "Bullet avoid behavior", desc = "Method the tank will use to avoid bullets \n " +
"\n Intersect: move away from where the bullet will hit the tank (less accurate) " +
"\n Back off: move away from the bullet (may back into corners) " +
"\n Dodge: move at an angle away from the bullet (more accurate)" +
"\n Dodge: move at an angle away from the bullet (more accurate) " +
"\n Aggressive dodge: move at an angle toward the bullet")
public BulletAvoidBehavior bulletAvoidBehvavior = BulletAvoidBehavior.intersect;
/** How close the tank needs to get to a mine to avoid it*/
Expand Down Expand Up @@ -109,10 +109,10 @@ public enum TargetEnemySightBehavior {approach, flee, strafe, sidewind, backwind
/** Type of behavior tank should have if its target enemy is in line of sight*/
@TankProperty(category = movementOnSight, id = "target_enemy_sight_behavior", name = "Reaction", desc = "How the tank should react upon line of sight \n " +
"Approach - move directly toward the target \n " +
"Flee - move directly away from the target \n" +
"Strafe around it - move perpendicular to the target \n" +
"Sidewind - zig-zag toward the target \n" +
"Backwind - zig-zag away from the target \n" +
"Flee - move directly away from the target \n " +
"Strafe around it - move perpendicular to the target \n " +
"Sidewind - zig-zag toward the target \n " +
"Backwind - zig-zag away from the target \n " +
"Keep distance - move to or away from the target until at a specific distance to it \n" +
" \n \n Requires 'Test sight' in 'Movement on sight' to take effect")
public TargetEnemySightBehavior targetEnemySightBehavior = TargetEnemySightBehavior.approach;
Expand Down

0 comments on commit 80f1fed

Please sign in to comment.