@@ -71,6 +71,7 @@ public class Game extends Canvas implements Runnable {
7171 BufferedImage .TYPE_INT_RGB );
7272 private Screen screen ;
7373 private static InputHandler input ;
74+ private static MouseHandler mouse ;
7475 private WindowHandler window ;
7576 private LevelHandler level ;
7677 private Player player ;
@@ -124,6 +125,7 @@ public void init() {
124125
125126 screen = new Screen (WIDTH , HEIGHT , new SpriteSheet ("/sprite_sheet.png" ));
126127 input = new InputHandler (this );
128+ setMouse (new MouseHandler (this ));
127129 setWindow (new WindowHandler (this ));
128130 setMap ("/levels/custom_level.png" );
129131 setMap (1 );
@@ -305,6 +307,7 @@ public void render() {
305307 Graphics g = bs .getDrawGraphics ();
306308 g .drawRect (0 , 0 , getWidth (), getHeight ());
307309 g .drawImage (image , 0 , 0 , getWidth (), getHeight () - 30 , null );
310+ status (g , isDevMode (), isClosing ());
308311 // Font.render("Hi", screen, 0, 0, Colours.get(-1, -1, -1, 555), 1);
309312 g .drawImage (image2 , 0 , getHeight () - 30 , getWidth (), getHeight (), null );
310313 g .setColor (Color .WHITE );
@@ -317,7 +320,6 @@ public void render() {
317320 g .drawString ("Press Q to quit" , (getWidth ()/2 )-("Press Q to quit" .length ()*3 ), getHeight () -17 );
318321 g .setColor (Color .YELLOW );
319322 g .drawString (time .getTime (), (getWidth () - 58 ), (getHeight () - 3 ));
320- status (g , isDevMode (), isClosing ());
321323 g .setColor (Color .WHITE );
322324 if (noAudioDevice == true ) {
323325 g .setColor (Color .RED );
@@ -354,14 +356,18 @@ public void render() {
354356
355357 private void status (Graphics g , boolean TerminalMode , boolean TerminalQuit ) {
356358 if (TerminalMode == true ){
357- g .setColor (Color .GREEN );
359+ g .setColor (Color .CYAN );
358360 g .drawString ("JavaGame Stats" , 0 , 10 );
359361 g .drawString ("FPS/TPS: " + fps + "/" + tps , 0 , 25 );
360362 if ((player .getNumSteps () & 15 ) == 15 ) {
361363 steps += 1 ;
362364 }
363365 g .drawString ("Foot Steps: " + steps , 0 , 40 );
364366 g .drawString ("NPC: " + WordUtils .capitalize (String .valueOf (isNpc ())) , 0 , 55 );
367+ g .drawString ("Mouse: " + getMouse ().getX () + "x |" + getMouse ().getY () + "y" , 0 , 70 );
368+ if (getMouse ().getButton () != -1 ) g .drawString ("Button: " + getMouse ().getButton (), 0 , 85 );
369+ g .setColor (Color .CYAN );
370+ g .fillRect (getMouse ().getX ()-12 , getMouse ().getY ()-12 , 24 , 24 );
365371 }
366372 if (TerminalQuit == true ){
367373 g .setColor (Color .BLACK );
@@ -556,6 +562,14 @@ public void setInput(InputHandler input) {
556562 Game .input = input ;
557563 }
558564
565+ public static MouseHandler getMouse () {
566+ return mouse ;
567+ }
568+
569+ public static void setMouse (MouseHandler mouse ) {
570+ Game .mouse = mouse ;
571+ }
572+
559573 public static boolean isDevMode () {
560574 return devMode ;
561575 }
0 commit comments