@@ -31,7 +31,7 @@ public class BaseFunctionalityTest
3131 public static final int DEFAULT_GRID_WIDTH = 16 ;
3232 public static final int DEFAULT_GRID_HEIGHT = 16 ;
3333 public static final int DEFAULT_CELL_SIZE = 32 ;
34- public static final String GRID_SAVE_PATH = System .getProperty ("user.dir" )+ "\\ SavedData\\ grid1.ser" ;
34+ public static final String GRID_SAVE_PATH = System .getProperty ("user.dir" ) + "\\ SavedData\\ grid1.ser" ;
3535
3636 public static GameObject soundObject ;
3737
@@ -40,29 +40,31 @@ public static void main(String[] args)
4040 GameInstance game1 = new GameInstance ("Game1" );
4141 FrameRenderer frameRenderer = new FrameRenderer (
4242 new GameFrame (
43- DEFAULT_GRID_WIDTH * DEFAULT_CELL_SIZE ,
44- DEFAULT_GRID_WIDTH * DEFAULT_CELL_SIZE ,
43+ DEFAULT_GRID_WIDTH * DEFAULT_CELL_SIZE ,
44+ DEFAULT_GRID_WIDTH * DEFAULT_CELL_SIZE ,
4545 game1 .getGameInstanceName ()),
46- DEFAULT_GRID_WIDTH ,
47- DEFAULT_GRID_HEIGHT ,
48- DEFAULT_CELL_SIZE );
46+ DEFAULT_GRID_WIDTH ,
47+ DEFAULT_GRID_HEIGHT ,
48+ DEFAULT_CELL_SIZE );
4949 game1 .setFrameRenderer (frameRenderer );
5050 game1 .addRendererTimer (100 );
51- game1 .loadTextureAssets (System .getProperty ("user.dir" )+ "\\ Assets\\ Images" );
51+ game1 .loadTextureAssets (System .getProperty ("user.dir" ) + "\\ Assets\\ Images" );
5252 game1 .setUpdateTimer (100 );
5353
5454 /*********/
5555 boolean loadingSave ;
5656 int reply = JOptionPane .showConfirmDialog (null , "Do you want to load saved grid?" , "Load Save" , JOptionPane .YES_NO_OPTION );
57- if (reply == JOptionPane .YES_OPTION ) {
57+ if (reply == JOptionPane .YES_OPTION )
58+ {
5859 JOptionPane .showMessageDialog (null , "Loading saved grid" );
5960 loadingSave = true ;
60- } else {
61+ } else
62+ {
6163 JOptionPane .showMessageDialog (null , "Creating new Grid" );
6264 loadingSave = false ;
6365 }
6466 /*********/
65- if (loadingSave )
67+ if (loadingSave )
6668 {
6769 try
6870 {
@@ -72,11 +74,10 @@ public static void main(String[] args)
7274 System .err .println (e );
7375 createTestInstance (game1 );
7476 }
75- }
76- else
77+ } else
7778 {
7879 createTestInstance (game1 );
79- saveGameWithDelay (5000 ,game1 );
80+ saveGameWithDelay (5000 , game1 );
8081 }
8182
8283
@@ -87,33 +88,34 @@ public static void main(String[] args)
8788
8889 game1 .start ();
8990 game1 .refreshSpritesInRenderer ();
90- ((AudioComponent )soundObject .getComponent (AudioComponent .class )).play (0 );
91+ ((AudioComponent ) soundObject .getComponent (AudioComponent .class )).play (0 );
9192 }
9293
9394
9495 public static void createTestInstance (GameInstance game1 )
9596 {
9697 game1 .setUserInputManager (new UserInputManager (game1 ));
9798 game1 .setMainGrid (new Grid (DEFAULT_GRID_WIDTH , DEFAULT_GRID_HEIGHT ));
98- WallPrefab wallPrefab = new WallPrefab (game1 .getTexture ("wall" ), "wall" ,100 );
99- MovingSquare movingSquare = new MovingSquare ( game1 .getTexture ("blank" ), "blank" , 120 ,500 );
99+ WallPrefab wallPrefab = new WallPrefab (game1 .getTexture ("wall" ), "wall" , 100 );
100+ MovingSquare movingSquare = new MovingSquare (game1 .getTexture ("blank" ), "blank" , 120 , 500 );
100101
101102 for (int i = 5 ; i < 14 ; i ++)
102- game1 .addGameObject (wallPrefab .getInstance (game1 .getMainGrid (),i , i ), i , i );
103+ game1 .addGameObject (wallPrefab .getInstance (game1 .getMainGrid (), i , i ), i , i );
103104
104- game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (),1 , 1 ), 1 , 1 );
105+ game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (), 1 , 1 ), 1 , 1 );
105106 movingSquare .setDeltaTime (400 );
106- game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (),2 , 2 ), 2 , 2 );
107+ game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (), 2 , 2 ), 2 , 2 );
107108 movingSquare .setDeltaTime (300 );
108- game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (),3 , 3 ), 3 , 3 );
109- TestPlayerPrefab playerPrefab = new TestPlayerPrefab (game1 .getTexture ("player" ), "player" , 150 ,game1 .getUserInputManager ());
110- game1 .addGameObject (playerPrefab .getInstance (game1 .getMainGrid (),15 , 15 ), 15 , 15 );
111- soundObject = new GameObject (game1 .getMainGrid (),false ,13 ,13 );
109+ game1 .addGameObject (movingSquare .getInstance (game1 .getMainGrid (), 3 , 3 ), 3 , 3 );
110+ TestPlayerPrefab playerPrefab = new TestPlayerPrefab (game1 .getTexture ("player" ), "player" , 150 , game1 .getUserInputManager ());
111+ game1 .addGameObject (playerPrefab .getInstance (game1 .getMainGrid (), 15 , 15 ), 15 , 15 );
112+ soundObject = new GameObject (game1 .getMainGrid (), false , 13 , 13 );
112113 game1 .getFrameRenderer ().setAudioListener (new AudioListener ());
113- File [] audioFiles = new File [1 ];
114+ File [] audioFiles = new File [1 ];
114115 audioFiles [0 ] = new File (System .getProperty ("user.dir" ) + "/Assets/Music/MOOSIK.wav" );
115- soundObject .addComponent (new AudioComponent (soundObject ,game1 .getFrameRenderer ().getAudioListener (),audioFiles ));
116+ soundObject .addComponent (new AudioComponent (soundObject , game1 .getFrameRenderer ().getAudioListener (), audioFiles ));
116117 }
118+
117119 public static void saveGameWithDelay (int delay , GameInstance game1 )
118120 {
119121 TimerTask timerTask = new TimerTask ()
@@ -135,7 +137,7 @@ public void run()
135137 };
136138
137139 Timer timer = new Timer ();
138- timer .schedule (timerTask ,delay );
140+ timer .schedule (timerTask , delay );
139141 }
140142
141143}
0 commit comments