@@ -16,6 +16,7 @@ public class EventHandler {
1616 public int tempMap ;
1717 public int tempCol ;
1818 public int tempRow ;
19+ private boolean inForest = false ; // Flag to track the player location
1920
2021 public EventHandler (GameManager gameManager ) {
2122 this .gameManager = gameManager ;
@@ -79,6 +80,16 @@ else if (interact(0, 35, 84, "any")) {
7980 changeLocation (2 , 47 , 71 , GameManager .INDOOR );
8081 gameManager .playSE (28 );
8182 }
83+
84+ //Enter the forest
85+ if (interact (0 , 15 , 24 , "any" ) && inForest ) {
86+ changeLocation (0 , 15 , 24 , GameManager .OUTSIDE );
87+ inForest = false ; // restore the flag after the exit of forest
88+ } else if (interact (0 , 15 , 23 , "any" ) && !inForest ) {
89+ changeLocation (0 , 15 , 23 , GameManager .FOREST , GameManager .TRANSITION_STATE );
90+ inForest = true ; // install the flag that we're in forest
91+ }
92+
8293 }
8394 case 1 -> { // Dungeon
8495 //back to main map from Dungeon
@@ -226,7 +237,11 @@ private void speak(Entity entity) {
226237 }
227238
228239 private void changeLocation (int map , int col , int row , int area ) {
229- gameManager .gameState = GameManager .TRANSITION_STATE ;
240+ changeLocation (map , col , row , area , GameManager .TRANSITION_STATE );
241+ }
242+
243+ private void changeLocation (int map , int col , int row , int area , int gameState ) {
244+ gameManager .gameState = gameState ;
230245 gameManager .nextArea = area ;
231246 tempMap = map ;
232247 tempCol = col ;
0 commit comments