level 8
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -355,17 +356,6 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
||||
this.setBackground(SKY);
|
||||
}
|
||||
|
||||
if (currentLevel == 8) {
|
||||
// draw black overlay over entire world
|
||||
g.setColor(new Color(0, 0, 0, 255));
|
||||
g.fillRect(cameraX, cameraY, boardWidth, boardHeight);
|
||||
// cut out a circle around the player
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
|
||||
g2.fillOval(player.x - 60, player.y - 60, 120, 120);
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
|
||||
}
|
||||
|
||||
g.translate(-cameraX, -cameraY);
|
||||
|
||||
player.draw(g);
|
||||
@@ -403,6 +393,29 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
||||
|
||||
g.translate(cameraX, cameraY);
|
||||
|
||||
if (currentLevel == 8) {
|
||||
BufferedImage darkness =
|
||||
new BufferedImage(boardWidth, boardHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = darkness.createGraphics();
|
||||
|
||||
// fill entire overlay with fully opaque black
|
||||
g2.setColor(new Color(0, 0, 0, 255));
|
||||
g2.fillRect(0, 0, boardWidth + 1000, boardHeight + 1000);
|
||||
|
||||
// player's position in screen coordinates
|
||||
int screenX = (player.x + player.width / 2) - cameraX;
|
||||
int screenY = (player.y + player.height / 2) - cameraY;
|
||||
|
||||
// cut circle centered on player
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
|
||||
g2.fillOval(screenX - 80, screenY - 100, 160, 160);
|
||||
|
||||
g2.dispose();
|
||||
|
||||
// draw overlay in screen space (after translate reset)
|
||||
g.drawImage(darkness, 0, 0, null);
|
||||
}
|
||||
|
||||
int modAmt = 2000;
|
||||
int curTime = (int) System.currentTimeMillis() % modAmt;
|
||||
curTime = Math.abs(curTime);
|
||||
|
||||
Reference in New Issue
Block a user