44import com .redomar .game .entities .Dummy ;
55import com .redomar .game .entities .Player ;
66import com .redomar .game .entities .Vendor ;
7+ import com .redomar .game .entities .trees .Spruce ;
78import com .redomar .game .gfx .Screen ;
89import com .redomar .game .gfx .SpriteSheet ;
910import com .redomar .game .level .LevelHandler ;
1011import com .redomar .game .lib .Font ;
1112import com .redomar .game .lib .Time ;
1213import com .redomar .game .script .PrintTypes ;
1314import com .redomar .game .script .Printing ;
14- import org .apache .commons .lang3 . text .WordUtils ;
15+ import org .apache .commons .text .WordUtils ;
1516
1617import javax .swing .*;
1718import java .awt .*;
@@ -79,6 +80,7 @@ public class Game extends Canvas implements Runnable {
7980 private Player player ;
8081 private Dummy dummy ; // Dummy NPC follows the player around
8182 private Vendor vendor ; // Vendor NPC exhibits random movement and is only found on cutom_level
83+ private Spruce spruce ; // Tree -- Spruce
8284 private Font font = new Font (); // Font object capable of displaying 2 fonts: Arial and Segoe UI
8385 private String nowPlaying ;
8486 private boolean notActive = true ;
@@ -215,6 +217,8 @@ public void setMap(String Map_str) {
215217 setPlayer (new Player (level , 100 , 100 , input ,
216218 getJdata_UserName (), shirtCol , faceCol ));
217219 level .addEntity (player );
220+ spruce = new Spruce (level , 70 ,170 , 2 );
221+ level .addEntity (spruce );
218222 }
219223
220224 public static void setMap (int map ) {
@@ -361,7 +365,11 @@ public void init() {
361365 input = new InputHandler (this ); // Input begins to record key presses
362366 setMouse (new MouseHandler (this )); // Mouse tracking and clicking is now recorded
363367 setWindow (new WindowHandler (this ));
364- setMap ("/levels/custom_level.png" );
368+ try {
369+ setMap ("/levels/custom_level.png" );
370+ } catch (Exception e ){
371+ System .err .println (e );
372+ }
365373 setMap (1 ); // 1 corresponds to custom_level
366374
367375 game .setVendor (new Vendor (level , "Vendor" , 215 , 215 , 304 , 543 ));
@@ -545,7 +553,7 @@ public void render() {
545553 * whether it is running in developer mode, or if the application is closing.
546554 */
547555 private void status (Graphics g , boolean TerminalMode , boolean TerminalQuit ) {
548- if (TerminalMode == true ) { // If running in developer mode
556+ if (TerminalMode ) { // If running in developer mode
549557 g .setColor (Color .CYAN );
550558 g .drawString ("JavaGame Stats" , 0 , 10 ); // Display "JavaGame Stats" in cyan at the bottom left of the screen
551559 g .drawString ("FPS/TPS: " + fps + "/" + tps , 0 , 25 ); // Display the FPS and TPS in cyan directly above "JavaGame Stats"
@@ -563,14 +571,16 @@ private void status(Graphics g, boolean TerminalMode, boolean TerminalQuit) {
563571 g .setColor (Color .CYAN );
564572 g .fillRect (getMouse ().getX () - 12 , getMouse ().getY () - 12 , 24 , 24 );
565573 }
566- if (TerminalQuit == true ) { // If the game is shutting off
567- g .setColor (Color .BLACK );
568- g .fillRect (0 , 0 , getWidth (), getHeight ()); // Make the screen fully black
569- g .setColor (Color .RED );
570- g .drawString ("Shutting down the Game" , (getWidth () / 2 ) - 70 , // Display "Shutting down the Game" in red in the middle of the screen
571- (getHeight () / 2 ) - 8 );
572- g .dispose (); // Free up memory for graphics
574+ // If the game is shutting off
575+ if (!TerminalQuit ) {
576+ return ;
573577 }
578+ g .setColor (Color .BLACK );
579+ g .fillRect (0 , 0 , getWidth (), getHeight ()); // Make the screen fully black
580+ g .setColor (Color .RED );
581+ g .drawString ("Shutting down the Game" , (getWidth () / 2 ) - 70 , // Display "Shutting down the Game" in red in the middle of the screen
582+ (getHeight () / 2 ) - 8 );
583+ g .dispose (); // Free up memory for graphics
574584 }
575585
576586 public WindowHandler getWindow () {
0 commit comments