diff --git a/src/main/java/dev/dvorakmortonxd/Game.java b/src/main/java/dev/dvorakmortonxd/Game.java index ebce1c5..3589536 100644 --- a/src/main/java/dev/dvorakmortonxd/Game.java +++ b/src/main/java/dev/dvorakmortonxd/Game.java @@ -134,13 +134,13 @@ public class Game extends JPanel implements ActionListener, KeyListener { hoveringOverQuitButton = quitButtonCollision.contains(mouseX, mouseY); if (hoverDirection == "up") { hoverYOffset++; - opacityAnimation += 0.01; + if (opacityAnimation < 1.00f) { opacityAnimation += 0.01f; } if (hoverYOffset > 90) { hoverDirection = "down"; } } else { hoverYOffset--; - opacityAnimation -= 0.01; + if (opacityAnimation > 0.01f) { opacityAnimation -= 0.01f; } if (hoverYOffset <= 0) { hoverDirection = "up"; } @@ -234,12 +234,28 @@ public class Game extends JPanel implements ActionListener, KeyListener { } else { if (detachTimer < 1200) { + opacityAnimation = 0.01f; + Graphics2D g2 = (Graphics2D) g; + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation)); + g2.drawImage(sun, 600, -80, 384, 384, this); + g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent + g.drawImage(rocketTop, windowWidth / 2 - 73, 300, 147, 84, this); g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this); } else if (1400 > detachTimer && detachTimer >= 1200) { + Graphics2D g2 = (Graphics2D) g; + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation)); + g2.drawImage(sun, 600, -80, 384, 384, this); + g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent + g.drawImage(rocketLanding0, windowWidth / 2 - 73, 300, 147, 111, this); g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this); } else if (1400 <= detachTimer && detachTimer < 1700) {; + Graphics2D g2 = (Graphics2D) g; + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation)); + g2.drawImage(sun, 600, -80, 384, 384, this); + g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent + g.drawImage(parachute, windowWidth / 2 - 73, 258+(detachTimer-1400)/3*2, 147, 90, this); g.drawImage(rocketLanding1, windowWidth / 2 - 73, 300, 147, 111, this); } else {