@@ -44,6 +44,7 @@ public class Game extends Canvas implements Runnable {
4444 private static final int HEIGHT = (2 * SCALE );
4545 private static final int SCREEN_HEIGHT = (HEIGHT * 2 ) + 30 ;
4646 private static final Screen screen = new Screen (WIDTH , HEIGHT , new SpriteSheet ("/sprite_sheet.png" ));
47+ private static final Screen screen2 = new Screen (WIDTH , HEIGHT , new SpriteSheet ("/sprite_sheet.png" ));
4748 private static final String NAME = "Game" ; // The name of the JFrame panel
4849 private static final Time time = new Time (); // Represents the calendar's time value, in hh:mm:ss
4950 private static final boolean [] alternateCols = new boolean [2 ]; // Boolean array describing shirt and face colour
@@ -70,7 +71,9 @@ public class Game extends Canvas implements Runnable {
7071 private static InputContext context ; // Provides methods to control text input facilities
7172 // Graphics
7273 private final BufferedImage image = new BufferedImage (WIDTH , HEIGHT , BufferedImage .TYPE_INT_ARGB );
74+ private final BufferedImage image3 = new BufferedImage (WIDTH , HEIGHT , BufferedImage .TYPE_INT_ARGB );
7375 private final int [] pixels = ((DataBufferInt ) image .getRaster ().getDataBuffer ()).getData (); // Array of red, green and blue values for each pixel
76+ private final int [] pixels3 = ((DataBufferInt ) image3 .getRaster ().getDataBuffer ()).getData (); // Array of red, green and blue values for each pixel
7477 private final int [] colours = new int [6 * 6 * 6 ]; // Array of 216 unique colours (6 shades of red, 6 of green, and 6 of blue)
7578 private final BufferedImage image2 = new BufferedImage (WIDTH , HEIGHT - 30 , BufferedImage .TYPE_INT_RGB );
7679 private final Font font = new Font (); // Font object capable of displaying 2 fonts: Arial and Segoe UI
@@ -335,7 +338,9 @@ public void init() {
335338 }
336339
337340 screen .setViewPortHeight (SCREEN_HEIGHT );
341+ screen2 .setViewPortHeight (SCREEN_HEIGHT );
338342 screen .setViewPortWidth (SCREEN_WIDTH );
343+ screen2 .setViewPortWidth (SCREEN_WIDTH );
339344 input = new InputHandler (this ); // Input begins to record key presses
340345 setMouse (new MouseHandler (this )); // Mouse tracking and clicking is now recorded
341346// setWindow(new WindowHandler(this));
@@ -450,7 +455,6 @@ public void render() {
450455 level .renderEntities (screen );
451456 level .renderProjectileEntities (screen );
452457
453-
454458 for (int y = 0 ; y < screen .getHeight (); y ++) {
455459 for (int x = 0 ; x < screen .getWidth (); x ++) {
456460 int colourCode = screen .getPixels ()[x + y * screen .getWidth ()];
@@ -459,6 +463,16 @@ public void render() {
459463 }
460464 }
461465 }
466+ for (int y = 0 ; y < screen2 .getHeight (); y ++) {
467+ for (int x = 0 ; x < screen2 .getWidth (); x ++) {
468+ int colourCode = screen2 .getPixels ()[x + y * screen2 .getWidth ()];
469+ if (colourCode < 1 ){
470+ pixels3 [x + y * WIDTH ] = 0xff0000 ;
471+ } else if (colourCode < 255 ) {
472+ pixels3 [x + y * WIDTH ] = colours [colourCode ];
473+ }
474+ }
475+ }
462476
463477 if (isChangeLevel () && getTickCount () % 60 == 0 ) {
464478 Game .setChangeLevel (true );
@@ -522,7 +536,7 @@ public void render() {
522536 * This method renders the overlay of the game, which is a transparent layer that is drawn over the game.
523537 */
524538 private void overlayRender (Graphics2D g ) {
525- g .setColor (new Color (0f , 0f , 0f , .192f )); // Transparent color
539+ g .setColor (new Color (0f , 0f , 0f , 0f )); // Transparent color
526540 g .fillRect (0 , 0 , getWidth (), getHeight ()-30 );
527541 }
528542
0 commit comments