All levels in Gravity Defied are stored in levels.mrg file. On this page we will try to explain the MRG format.
Used byte order is Big Endian.
int= 4 bytes
short= 2 bytes
byte= 1 byte
int= 4 bytes
short= 2 bytes
byte= 1 byte
Tracks list
The file begins from description of three levels with the tracks list:
level levels[3]
level levels[3]
Every level looks like this:
level
int countcount of tracks
track_name tracks[count]tracks
List of tracks tracks in every level repeats count times:
track_name
int offsetoffset of track data relative to the beginning of file
string nametrack name
byte null=0x00null byrw
Tracks description
Data of every track are stored at the offset from track_name.
track
byte mark=0x33track data mark, always 0x33
int start_xplayer start position, X
int start_yplayer start position, Y
int finish_xfinish position, X
int finish_yfinish position, Y (usually 0)
short points_countpoints count
int point_xfirst point, X
int point_yfirst point, Y
point points[points_count-1]points
Coordinates start_x, start_y, finish_x and finish_y are stored as (int << 16) >> 3; accordingly, they must be read vice versa.
Points are repeated points_count-1 times. Coordinates are summed, ie, the value of each point is the offset from the previous one. A point in the file usually looks like:
point
byte xoffset, X
byte yoffset, Y
However if x = -1, you mustn't read the next byte (y), just reset the current coordinates sum and then read a point::
point2
int xcoordinate, X
int ycoordinate, Y
Next point you can read as usually