Skip to content

Serialization Design

joeldushouyu edited this page Apr 3, 2021 · 35 revisions

Serialization Design

The game will be save in a customize .dat file named with username, using JAVA build in library- DataInputStream and DataOutputStream. The game will load/save the file once the player envoke the correspond save/load button

The first line of file will consist of the amount of time left at the current level:

Note:

If the amount of time left is equal to 0. In another phrase the user saved at the end of a level. The file will simply save the game at the **next level ** with the exception that it is already the end of game

The second line of file will consist of a number indicate the current level

The third line of file will consist the difficulty level of the game in String, such as {easy,medium,hard}

The fourth line consist a number indicate number of player

The format for player's information comes with username; shipSkin; totalCoins; current score in the level; UpperLeftXPosition; UpperLeftPosition; deltaX; deltaY; and additional affects on the player separate by a colon. Additionally, information for additional affects will be separate by commas according to the additional affect type within the colons

The line after player's information consist the number of game Object

Note: this will only appear if the player did not save at the end of game.

The format for game object comes with object type; specific Object Type; UpperLeftXPosition; UpperLeftYposition; deltaX; delatY; and additional affects on the object, each separate by a colon. Additionally, information for additional affects will be separate by commas within the colons.

The file ends with ENDL#, indicate the end of a files

Example of saving file data

note: the following will give a basic concept of the file as in txt format. Note in .dat format.

Example 1

 * 15
 * 2
 * easy
 * 1
 * Jack;SHIP1;100;20;300;450;10;10;Faster,5,20  

Explanation: Faster is an example affect make player move faster. The player gain a increase of speed by5, and for 20 seconds

 * 3
 * EnemyObject;GHOST;100;230;4;4;Freeze,0,5

Explanation: Freeze is an powerup that change the deltax and deltay for EnemyObject to 0 for 5 seconds

 * Obstacle;Obstacle;100;250;0;0
 * PowerUp;Freeze;20;50;0;0
 * ENDL#
 * 

Example2

 * 0
 * 3
 * easy
 * 1
 * Andrew;SHIP1;100;20;300;450;10;10;Faster,5,20 
 * ENDL#

url for save/load function and test case

[Save/Load Methods] https://github.com/bjucps209/spring2021-team4/blob/main/Wave/src/model/Wave.java

[Unit Tests] https://github.com/bjucps209/spring2021-team4/blob/main/Wave/src/model/WaveTest.java

Peer Review: 2021/4/3 4:17 pm Reviewer: Conner Recommendation: Beware of change might occur later during the implementation stage, such as adding new variables.

Clone this wiki locally