Advertisement
cspotcode

GG2 leveldata format

Jun 5th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* New format for GG2 leveldata.
  2.  * This JSON document fully describes a GG2 level.
  3.  * It can be embedded into a PNG with GG2DLL,
  4.  * packed up in a zip along with any BG/WM images,
  5.  * sent over the network, etc.
  6.  *
  7.  * Also this should be ready for future improvements and changes, unlike the terrible older format.
  8.  */
  9.  
  10. {
  11.   format: 1, /* a format number?
  12.               * GG2 can reject maps with newer format numbers than it supports,
  13.               * and can provide legacy loading code for older format numbers
  14.               */
  15.   mapInfo: {
  16.     name: 'TwoDeeFort-Redux',
  17.     gameMode: 'CTF', /* support multiple gamemodes in a single map?
  18.                       * cspotcode says 'no' because it would be too complicated,
  19.                       * require extra GUI in GG2 for server host to choose game mode,
  20.                       * and provide only minimal benefit
  21.                       */
  22.     description: 'Anything the author wants.  Could have contact info.  Could be displayed in a possible GG2 levelpicker GUI'
  23.     /* other stuff?  setup time, respawn wave duration, other timers? */
  24.   }
  25.   collisionMasks: [ /* list of collision images.
  26.                      * These are all black/white like a walkmask but can theoretically be used for anything.
  27.                      * They will be turned into collision sprites by GG2 and can be referenced by entities below.
  28.                      */
  29.     {
  30.       name: 'walkmask',
  31.       size: {width: 700, height: 300},
  32.       data: 'TODO WHAT FORMAT SHOULD THIS DATA BE IN?  MAYBE A BASE64 ENCODED STREAM OF BITS?'
  33.     },
  34.     {
  35.       name: 'funkyShape',  /* could be some strange, non-rectangular shape for a fragbox that the level designer wanted to paste all over the map */
  36.       size: {width: 10, height: 20},
  37.       data: 'AIENCMNUE'
  38.     }
  39.   ],
  40.  
  41.   entities: [ /* all entities on the map */
  42.     {
  43.       type: 'redspawn', /* boring old entity */
  44.       position: {x: 156, y:34}
  45.     },
  46.     {
  47.       type: 'fragBox',
  48.       position: {x:500, y:435},
  49.       size: {width: 200, height: 20}   /* a resizable entity! */
  50.     },
  51.     {
  52.       type: 'controlPoint',
  53.       position: {x: 20, y: 20},
  54.       pointNumber: 2   /* an entity parameter! */
  55.     },
  56.     {
  57.       type: 'wall',
  58.       position: {x: 0, y: 0},
  59.       collisionMask: 'walkmask' /* refers to the collisionMasks array above */
  60.     }
  61.     {
  62.       type: 'wall',
  63.       position: {x: 200, y: 250},
  64.       size: {width: 10, height: 10} /* same entity type as above, but this time we specify the collision mask as a solid rectangle.
  65.                                      * No collisionMasks reference needed */
  66.     }
  67.   ]
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement