77import com .redomar .game .entities .trees .Spruce ;
88import com .redomar .game .event .InputHandler ;
99import com .redomar .game .event .MouseHandler ;
10+ import com .redomar .game .gfx .Colours ;
1011import com .redomar .game .gfx .Screen ;
1112import com .redomar .game .gfx .SpriteSheet ;
1213import com .redomar .game .gfx .lighting .Night ;
@@ -44,6 +45,7 @@ public class Game extends Canvas implements Runnable {
4445 private static final int HEIGHT = (2 * SCALE );
4546 private static final int SCREEN_HEIGHT = (HEIGHT * 2 ) + 30 ;
4647 private static final Screen screen = new Screen (WIDTH , HEIGHT , new SpriteSheet ("/sprite_sheet.png" ));
48+ private static final Screen screen2 = new Screen (WIDTH , HEIGHT , new SpriteSheet ("/sprite_sheet.png" ));
4749 private static final String NAME = "Game" ; // The name of the JFrame panel
4850 private static final Time time = new Time (); // Represents the calendar's time value, in hh:mm:ss
4951 private static final boolean [] alternateCols = new boolean [2 ]; // Boolean array describing shirt and face colour
@@ -70,7 +72,9 @@ public class Game extends Canvas implements Runnable {
7072 private static InputContext context ; // Provides methods to control text input facilities
7173 // Graphics
7274 private final BufferedImage image = new BufferedImage (WIDTH , HEIGHT , BufferedImage .TYPE_INT_ARGB );
75+ private final BufferedImage image3 = new BufferedImage (WIDTH , HEIGHT , BufferedImage .TYPE_INT_ARGB );
7376 private final int [] pixels = ((DataBufferInt ) image .getRaster ().getDataBuffer ()).getData (); // Array of red, green and blue values for each pixel
77+ private final int [] pixels3 = ((DataBufferInt ) image3 .getRaster ().getDataBuffer ()).getData (); // Array of red, green and blue values for each pixel
7478 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)
7579 private final BufferedImage image2 = new BufferedImage (WIDTH , HEIGHT - 30 , BufferedImage .TYPE_INT_RGB );
7680 private final Font font = new Font (); // Font object capable of displaying 2 fonts: Arial and Segoe UI
@@ -335,7 +339,9 @@ public void init() {
335339 }
336340
337341 screen .setViewPortHeight (SCREEN_HEIGHT );
342+ screen2 .setViewPortHeight (SCREEN_HEIGHT );
338343 screen .setViewPortWidth (SCREEN_WIDTH );
344+ screen2 .setViewPortWidth (SCREEN_WIDTH );
339345 input = new InputHandler (this ); // Input begins to record key presses
340346 setMouse (new MouseHandler (this )); // Mouse tracking and clicking is now recorded
341347// setWindow(new WindowHandler(this));
@@ -449,6 +455,7 @@ public void render() {
449455 level .renderTiles (screen , xOffset , yOffset );
450456 level .renderEntities (screen );
451457 level .renderProjectileEntities (screen );
458+ screen2 .renderText ("JAVAGAME " , 0 , 0 , Colours .get (000 , -1 , -1 , 500 ), 1 );
452459
453460
454461 for (int y = 0 ; y < screen .getHeight (); y ++) {
@@ -459,6 +466,24 @@ public void render() {
459466 }
460467 }
461468 }
469+ for (int y = 0 ; y < screen2 .getHeight (); y ++) {
470+ for (int x = 0 ; x < screen2 .getWidth (); x ++) {
471+ int colourCode = screen2 .getPixels ()[x + y * screen2 .getWidth ()];
472+ if (colourCode < 1 ){
473+ pixels3 [x + y * WIDTH ] = 0xff0000 ;
474+ } else if (colourCode < 255 ) {
475+ pixels3 [x + y * WIDTH ] = colours [colourCode ];
476+ }
477+
478+ if (y == 0 || y == screen2 .getHeight () - 1 ) {
479+ pixels3 [x + y * WIDTH ] = 0x55000000 ;
480+ }
481+
482+ if (x == 0 || x == screen2 .getWidth () - 1 ) {
483+ pixels3 [x + y * WIDTH ] = 0x55000000 ;
484+ }
485+ }
486+ }
462487
463488 if (isChangeLevel () && getTickCount () % 60 == 0 ) {
464489 Game .setChangeLevel (true );
@@ -522,7 +547,8 @@ public void render() {
522547 * This method renders the overlay of the game, which is a transparent layer that is drawn over the game.
523548 */
524549 private void overlayRender (Graphics2D g ) {
525- g .setColor (new Color (0f , 0f , 0f , .192f )); // Transparent color
550+ g .setColor (new Color (0f , 0f , 0f , 0f )); // Transparent color
551+ g .drawImage (image3 , 0 , 0 , getWidth ()/3 , getHeight ()/3 - 30 , null );
526552 g .fillRect (0 , 0 , getWidth (), getHeight ()-30 );
527553 }
528554
0 commit comments