Guest User

Untitled

a guest
Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.69 KB | None | 0 0
  1. // ****************************************************************
  2. // This is a simple HaxBall stadium meant to be used as an example.
  3. // ****************************************************************
  4.  
  5. // HaxBall stadiums are a JSON object composed of lists of vertexes, segments, planes, discs, goals and traits.
  6.  
  7. // A Vertex is an invisible solid 2d point which discs can't go through.
  8. // A Segment connects two vertexes with a wall. They can be visible or invisible, curved or straight. (It is recommended that the vertexes connected by a segment have the same physical properties as it, otherwise the corners of the segment will behave different than the sides.)
  9. // A Plane defines a one sided boundary, objects can only be on one side of a plane.
  10. // A Disc defines a physical disc (Same as the goal posts, the player discs or the ball).
  11. // A Goal is a segment defined by two points, when the ball passes through this line a goal will be scored.
  12. // A trait is an optional feature which lets you avoid repetition by defining properties which are common to many objects.
  13.  
  14. // Vertexes, Segments, Planes and Discs all share the following properties:
  15. // "bCoef" : <Number from 0.0 to 1.0> - Defines the bouncing coefficient.
  16. // "cMask" : <Array of collision layers, eg: ["ball", "red", "blue"]> - Stands for collision mask, it defines which layers this object can collide with.
  17. // "cGroup" : <Array of collision layers, eg: ["ball", "red", "blue"]> - Stands for collision group, it defines in which collision layers this object lives.
  18. // "trait" : <Name of a trait to inherit from> - When this property is specified the object will inherit the properties defined on the trait.
  19.  
  20. // In addition there are properties specific to each one:
  21.  
  22. // Vertexes:
  23. // "x" : <Number> - The X coordinate of the vertex.
  24. // "y" : <Number> - The Y coordinate of the vertex.
  25.  
  26. // Segments:
  27. // "v0" : <Integer number> - The index of a vertex to connect with this segment.
  28. // "v1" : <Integer number> - The index of the other vertex to connect with this segment.
  29. // "curve" : <Angle in degrees from -350.0 to 350.0> - How much this segment curves.
  30. // "vis" : <true or false> - Wether this segment is visible or not.
  31. // "color" : <Color> - Defines the color of the segment.
  32.  
  33. // Plane:
  34. // "normal" : <[Number, Number]> - The normal(direction vector) of the plane.
  35. // "dist" : <Number> - The distance to <0,0>.
  36.  
  37. // Disc:
  38. // "radius" : <Number> - The radius of the disc.
  39. // "invMass" : <Number >= 0 > - The inverse of the mass, the closer to 0 the heavier this object is. (Discs with 0 invMass can't move and act as static objects)
  40. // "color" : <Color> - The fill color of the disc.
  41.  
  42. // Goal:
  43. // "p0" : <[Number, Number]> - First point of the goal.
  44. // "p1" : <[Number, Number]> - Second point of the goal.
  45. // "team" : <Either "red" or "blue"> - The team whose this goal belongs to.
  46.  
  47.  
  48. // ***********************
  49. // Some other useful info:
  50. // ***********************
  51.  
  52. // Collision layers are defined as arrays of the following strings:
  53. // "ball" - The collision group of the ball.
  54. // "red" - The collision group for red players.
  55. // "blue" - The collision group for blue players.
  56. // "wall" - The default collision group for all stadium objects.
  57. // "redKO" - A collision group players will only collide with during the red kickoff. (Useful for kickoff barriers)
  58. // "blueKO" - A collision group players will only collide with during the blue kickoff. (Useful for kickoff barriers)
  59.  
  60. // Colors can be defined in two ways (always RGB):
  61. // * As a hexa string, eg "F7A2DD"
  62. // * As an array of numbers from 0 to 255, eg: [255, 128, 0].
  63.  
  64.  
  65. // ****************************************
  66. // Here's the annotated stadium definition:
  67. // ****************************************
  68.  
  69. {
  70. "name" : "600Arena", // Set the name of the stadium
  71. "width" : 670, // width and height only constrain the camera scrolling.
  72. "height" : 370,
  73.  
  74. "spawnDistance" : 420, // Set how far from the ball the teams will spawn
  75.  
  76. "bg" : { "type" : "grass", "width" : 600, "height" : 300, "kickOffRadius" : 60, "cornerRadius" : 0}, // Set the background. This is only visual, it doesnt' affect the physics at all.
  77.  
  78. // The list of vertexes:
  79. "vertexes" : [
  80. // Left side of the ball area:
  81. { "x" : -600, "y" : 300, "trait" : "ballArea" }, // Index 0 - Bottom corner.
  82. { "x" : -600, "y" : 75, "trait" : "ballArea" }, // Index 1 - Bottom goal post.
  83. { "x" : -600, "y" : -75, "trait" : "ballArea" }, // Index 2 - Top goal post.
  84. { "x" : -600, "y" : -300, "trait" : "ballArea" }, // Index 3 - Top corner.
  85.  
  86. // Right side of the ball area:
  87. { "x" : 600, "y" : 300, "trait" : "ballArea" }, // Index 4 - Bottom corner.
  88. { "x" : 600, "y" : 75, "trait" : "ballArea" }, // Index 5 - Bottom goal post.
  89. { "x" : 600, "y" : -75, "trait" : "ballArea" }, // Index 6 - Top goal post.
  90. { "x" : 600, "y" : -300, "trait" : "ballArea" }, // Index 7 - Top corner.
  91.  
  92. // Vertexes involved on the kickoff barrier:
  93. { "x" : 0, "y" : 370, "trait" : "kickOffBarrier" }, // Index 8 - Bottom center.
  94. { "x" : 0, "y" : 60, "trait" : "kickOffBarrier" }, // Index 9 - Bottom of the kickoff circle.
  95. { "x" : 0, "y" : -60, "trait" : "kickOffBarrier" }, // Index 10 - Top of the kickoff circle.
  96. { "x" : 0, "y" : -370, "trait" : "kickOffBarrier" }, // Index 11 - Top center.
  97.  
  98. { "x" : -640, "y" : 75, "trait" : "ballArea" }, // 12
  99. { "x" : -640, "y" : -75, "trait" : "ballArea" }, // 13
  100. { "x" : 640, "y" : 75, "trait" : "ballArea" }, // 14
  101. { "x" : 640, "y" : -75, "trait" : "ballArea" }, // 15
  102.  
  103. { "x" : -600, "y" : 265, "trait" : "rogBlue" }, //16
  104. { "x" : -565, "y" : 300, "trait" : "rogBlue" }, //17
  105. { "x" : -600, "y" : -265, "trait" : "rogBlue" }, //18
  106. { "x" : -565, "y" : -300, "trait" : "rogBlue" }, //19
  107.  
  108. { "x" : 600, "y" : 265, "trait" : "rogRed" }, //20
  109. { "x" : 565, "y" : 300, "trait" : "rogRed" }, //21
  110. { "x" : 600, "y" : -265, "trait" : "rogRed" }, //22
  111. { "x" : 565, "y" : -300, "trait" : "rogRed" }, //23
  112.  
  113. // LINIE BOCZNE I SRODKOWE (POGRUBIENIE):
  114. { "x" : -600, "y" : -300, "trait" : "linia" }, //24
  115. { "x" : 600, "y" : -300, "trait" : "linia" }, //25
  116. { "x" : -600, "y" : 300, "trait" : "linia" }, //26
  117. { "x" : 600, "y" : 300, "trait" : "linia" }, //27
  118. { "x" : 0, "y" : 300, "trait" : "linia" }, //28
  119. { "x" : 0, "y" : -300, "trait" : "linia" }, //29
  120.  
  121.  
  122. // POLE PODBRAMKOWE - CZERWONE:
  123. { "x" : -600, "y" : 80, "trait" : "linia" }, //30
  124. { "x" : -600, "y" : -80, "trait" : "linia" }, //31
  125. { "x" : -545, "y" : 80, "trait" : "linia" }, //32
  126. { "x" : -545, "y" : -80, "trait" : "linia" }, //33
  127.  
  128. //POLE KARNE - CZERWONE:
  129. { "x" : -600, "y" : 138, "trait" : "karne_red" }, //34
  130. { "x" : -600, "y" : -138, "trait" : "karne_red" }, //35
  131. { "x" : -480, "y" : 138, "trait" : "karne_red" }, //36
  132. { "x" : -480, "y" : -138, "trait" : "karne_red" }, //37
  133.  
  134. // POLE PODBRAMKOWE - NIEBIESKIE:
  135. { "x" : 600, "y" : 80, "trait" : "linia" }, //38
  136. { "x" : 600, "y" : -80, "trait" : "linia" }, //39
  137. { "x" : 545, "y" : 80, "trait" : "linia" }, //40
  138. { "x" : 545, "y" : -80, "trait" : "linia" }, //41
  139.  
  140. //POLE KARNE - NIEBIESKIE:
  141. { "x" : 600, "y" : 138, "trait" : "karne_blue" }, //42
  142. { "x" : 600, "y" : -138, "trait" : "karne_blue" }, //43
  143. { "x" : 480, "y" : 138, "trait" : "karne_blue" }, //44
  144. { "x" : 480, "y" : -138, "trait" : "karne_blue" }, //45
  145.  
  146. //SRODEK PUNKT:
  147. { "x" : -3, "y" : 0, "trait" : "linia" }, //46
  148. { "x" : 3, "y" : 0, "trait" : "linia" }, //47
  149.  
  150. //LEWY GORNY ROG - STREFA:
  151. { "x" : -670, "y" : -265, "trait" : "roglineBlue" }, //48
  152. { "x" : -565, "y" : -340, "trait" : "roglineBlue" }, //49
  153.  
  154. //LEWY DOLNY ROG - STREFA:
  155. { "x" : -670, "y" : 265, "trait" : "roglineBlue" }, //50
  156. { "x" : -565, "y" : 340, "trait" : "roglineBlue" }, //51
  157.  
  158. //LEWY GORNY ROG - STREFA:
  159. { "x" : 670, "y" : -265, "trait" : "roglineRed" }, //52
  160. { "x" : 565, "y" : -340, "trait" : "roglineRed" }, //53
  161.  
  162. //LEWY DOLNY ROG - STREFA:
  163. { "x" : 670, "y" : 265, "trait" : "roglineRed" }, //54
  164. { "x" : 565, "y" : 340, "trait" : "roglineRed" }, //55
  165.  
  166. //DOLNY - SRODEK - LEWA:
  167. { "x" : -240, "y" : 340, "trait" : "roglineRed" }, //56
  168. //DOLNY - SRODEK - PRAWA:
  169. { "x" : 240, "y" : 340, "trait" : "roglineRed" }, //57
  170. //GORNY - SRODEK - LEWA:
  171. { "x" : -240, "y" : -340, "trait" : "roglineRed" }, //58
  172. //GORNY - SRODEK - PRAWA:
  173. { "x" : 240, "y" : -340, "trait" : "roglineRed" } //59
  174. ],
  175.  
  176. // The list of segments:
  177. "segments" : [
  178. // Left side ball area walls:
  179. { "v0" : 0, "v1" : 1, "trait" : "ballArea" }, // Connects bottom corner to bottom goal post.
  180. { "v0" : 2, "v1" : 3, "trait" : "ballArea" }, // Connects top corner to top goal post.
  181.  
  182. // Right side ball area walls:
  183. { "v0" : 4, "v1" : 5, "trait" : "ballArea" }, // Connects bottom corner to bottom goal post.
  184. { "v0" : 6, "v1" : 7, "trait" : "ballArea" }, // Connects top corner to top goal post.
  185.  
  186. // Goal nets:
  187. { "v0" : 1, "v1" : 12, "trait" : "goalNetRed" },
  188. { "v0" : 12, "v1" : 13, "trait" : "goalNetRed" },
  189. { "v0" : 13, "v1" : 2, "trait" : "goalNetRed" },
  190.  
  191. { "v0" : 6, "v1" : 15, "trait" : "goalNetBlue" },
  192. { "v0" : 15, "v1" : 14, "trait" : "goalNetBlue" },
  193. { "v0" : 14, "v1" : 5, "trait" : "goalNetBlue" },
  194.  
  195. // Kickoff barriers:
  196. { "v0" : 8, "v1" : 9, "trait" : "kickOffBarrier" }, // Connects bottom center to kickoff circle bottom.
  197. { "v0" : 9, "v1" : 10, "trait" : "kickOffBarrier", "curve" : 180, "cGroup" : ["blueKO"] }, // Connects Kickoff circle top and bottom, curve = 180 makes half a circle.
  198. { "v0" : 9, "v1" : 10, "trait" : "kickOffBarrier", "curve" : -180, "cGroup" : ["redKO"] }, // Connects Kickoff circle top and bottom again, curve = -180 makes the other half.
  199. { "v0" : 10, "v1" : 11, "trait" : "kickOffBarrier" }, // Connects kickoff circle top to top center.
  200.  
  201. { "v0" : 16, "v1" : 17, "trait" : "rogBlue" },
  202. { "v0" : 19, "v1" : 18, "trait" : "rogBlue" },
  203.  
  204. { "v0" : 21, "v1" : 20, "trait" : "rogRed" },
  205. { "v0" : 22, "v1" : 23, "trait" : "rogRed" },
  206.  
  207. { "v0" : 24, "v1" : 25, "trait" : "linia" },
  208. { "v0" : 25, "v1" : 27, "trait" : "linia" },
  209. { "v0" : 26, "v1" : 27, "trait" : "linia" },
  210. { "v0" : 24, "v1" : 26, "trait" : "linia" },
  211.  
  212. { "v0" : 28, "v1" : 29, "trait" : "linia" },
  213.  
  214. { "v0" : 9, "v1" : 10, "trait" : "linia", "curve" : 180},
  215. { "v0" : 9, "v1" : 10, "trait" : "linia", "curve" : -180},
  216.  
  217. //PODBRAMKOWE - CZERWONE:
  218. { "v0" : 30, "v1" : 32, "trait" : "linia" },
  219. { "v0" : 32, "v1" : 33, "trait" : "linia" },
  220. { "v0" : 31, "v1" : 33, "trait" : "linia" },
  221.  
  222. //KARNE - CZERWONE:
  223. { "v0" : 35, "v1" : 37, "trait" : "karne_red" },
  224. { "v0" : 34, "v1" : 36, "trait" : "karne_red" },
  225. { "v0" : 36, "v1" : 37, "trait" : "karne_red" },
  226. { "v0" : 34, "v1" : 35, "trait" : "karne_red" },
  227.  
  228. //PODBRAMKOWE - NIEBIESKIE:
  229. { "v0" : 38, "v1" : 40, "trait" : "linia" },
  230. { "v0" : 40, "v1" : 41, "trait" : "linia" },
  231. { "v0" : 39, "v1" : 41, "trait" : "linia" },
  232.  
  233. //KARNE - NIEBIESKIE:
  234. { "v0" : 43, "v1" : 45, "trait" : "karne_blue" },
  235. { "v0" : 42, "v1" : 44, "trait" : "karne_blue" },
  236. { "v0" : 44, "v1" : 45, "trait" : "karne_blue" },
  237. { "v0" : 42, "v1" : 43, "trait" : "karne_blue" },
  238.  
  239. //SRODEK - PUNKT:
  240. { "v0" : 46, "v1" : 47, "trait" : "linia" },
  241.  
  242. //LEWY GORNY ROG - STREFA:
  243. { "v0" : 18, "v1" : 48, "trait" : "roglineBlue" },
  244. { "v0" : 19, "v1" : 49, "trait" : "roglineBlue" },
  245.  
  246. //LEWY DOLNY ROG - STREFA:
  247. { "v0" : 16, "v1" : 50, "trait" : "roglineBlue" },
  248. { "v0" : 17, "v1" : 51, "trait" : "roglineBlue" },
  249.  
  250. //PRAWY GORNY ROG - STREFA:
  251. { "v0" : 22, "v1" : 52, "trait" : "roglineRed" },
  252. { "v0" : 23, "v1" : 53, "trait" : "roglineRed" },
  253.  
  254. //PRAWY DOLNY ROG - STREFA:
  255. { "v0" : 20, "v1" : 54, "trait" : "roglineRed" },
  256. { "v0" : 21, "v1" : 55, "trait" : "roglineRed" },
  257.  
  258. //LEWY DOLNY - SRODEK:
  259. { "v0" : 51, "v1" : 56, "trait" : "roglineBlue" },
  260.  
  261. //PRAWY DOLNY - SRODEK:
  262. { "v0" : 55, "v1" : 57, "trait" : "roglineRed" },
  263.  
  264. //LEWY GORNY - SRODEK:
  265. { "v0" : 49, "v1" : 58, "trait" : "roglineBlue" },
  266.  
  267. //PRAWY GORNY - SRODEK:
  268. { "v0" : 53, "v1" : 59, "trait" : "roglineRed" }
  269. ],
  270.  
  271. // List of goals:
  272. "goals" : [
  273. { "p0" : [-600, 75], "p1" : [-600,-75], "team" : "red" },
  274. { "p0" : [600, 75], "p1" : [600,-75], "team" : "blue" }
  275. ],
  276.  
  277. // List of discs:
  278. "discs" : [
  279. // Left posts:
  280. { "pos" : [-600, 75], "trait" : "goalPostRed" },
  281. { "pos" : [-600, -75], "trait" : "goalPostRed" },
  282.  
  283. // Right posts:
  284. { "pos" : [ 600, 75], "trait" : "goalPostBlue" },
  285. { "pos" : [ 600, -75], "trait" : "goalPostBlue" },
  286.  
  287. // PACHOLKI DO STREF - LEWE DOLNE:
  288. { "pos" : [ -240, 338], "trait" : "goalPostBlue" },
  289. { "pos" : [ -270, 338], "trait" : "goalPostBlue" },
  290. { "pos" : [ -300, 338], "trait" : "goalPostBlue" },
  291. { "pos" : [ -330, 338], "trait" : "goalPostBlue" },
  292. { "pos" : [ -360, 338], "trait" : "goalPostBlue" },
  293. { "pos" : [ -390, 338], "trait" : "goalPostBlue" },
  294. { "pos" : [ -420, 338], "trait" : "goalPostBlue" },
  295. { "pos" : [ -450, 338], "trait" : "goalPostBlue" },
  296. { "pos" : [ -480, 338], "trait" : "goalPostBlue" },
  297. { "pos" : [ -510, 338], "trait" : "goalPostBlue" },
  298. { "pos" : [ -540, 338], "trait" : "goalPostBlue" },
  299.  
  300. // PACHOLKI DO STREF - PRAWE DOLNE:
  301. { "pos" : [ 240, 338], "trait" : "goalPostRed" },
  302. { "pos" : [ 270, 338], "trait" : "goalPostRed" },
  303. { "pos" : [ 300, 338], "trait" : "goalPostRed" },
  304. { "pos" : [ 330, 338], "trait" : "goalPostRed" },
  305. { "pos" : [ 360, 338], "trait" : "goalPostRed" },
  306. { "pos" : [ 390, 338], "trait" : "goalPostRed" },
  307. { "pos" : [ 420, 338], "trait" : "goalPostRed" },
  308. { "pos" : [ 450, 338], "trait" : "goalPostRed" },
  309. { "pos" : [ 480, 338], "trait" : "goalPostRed" },
  310. { "pos" : [ 510, 338], "trait" : "goalPostRed" },
  311. { "pos" : [ 540, 338], "trait" : "goalPostRed" },
  312.  
  313. // PACHOLKI DO STREF - LEWE GORNE:
  314. { "pos" : [ -240, -338], "trait" : "goalPostBlue" },
  315. { "pos" : [ -270, -338], "trait" : "goalPostBlue" },
  316. { "pos" : [ -300, -338], "trait" : "goalPostBlue" },
  317. { "pos" : [ -330, -338], "trait" : "goalPostBlue" },
  318. { "pos" : [ -360, -338], "trait" : "goalPostBlue" },
  319. { "pos" : [ -390, -338], "trait" : "goalPostBlue" },
  320. { "pos" : [ -420, -338], "trait" : "goalPostBlue" },
  321. { "pos" : [ -450, -338], "trait" : "goalPostBlue" },
  322. { "pos" : [ -480, -338], "trait" : "goalPostBlue" },
  323. { "pos" : [ -510, -338], "trait" : "goalPostBlue" },
  324. { "pos" : [ -540, -338], "trait" : "goalPostBlue" },
  325.  
  326. // PACHOLKI DO STREF - PRAWE DOLNE:
  327. { "pos" : [ 240, -338], "trait" : "goalPostRed" },
  328. { "pos" : [ 270, -338], "trait" : "goalPostRed" },
  329. { "pos" : [ 300, -338], "trait" : "goalPostRed" },
  330. { "pos" : [ 330, -338], "trait" : "goalPostRed" },
  331. { "pos" : [ 360, -338], "trait" : "goalPostRed" },
  332. { "pos" : [ 390, -338], "trait" : "goalPostRed" },
  333. { "pos" : [ 420, -338], "trait" : "goalPostRed" },
  334. { "pos" : [ 450, -338], "trait" : "goalPostRed" },
  335. { "pos" : [ 480, -338], "trait" : "goalPostRed" },
  336. { "pos" : [ 510, -338], "trait" : "goalPostRed" },
  337. { "pos" : [ 540, -338], "trait" : "goalPostRed" }
  338.  
  339. ],
  340.  
  341. // List of planes:
  342. "planes" : [
  343. { "normal" : [0, 1], "dist" : -300, "trait" : "ballArea" }, // Top ball area wall.
  344. { "normal" : [0,-1], "dist" : -300, "trait" : "ballArea" }, // Bottom ball area wall.
  345.  
  346. // Player bounds:
  347. { "normal" : [ 0, 1], "dist" : -370, "bCoef" : 0.1 }, // Top wall.
  348. { "normal" : [ 0,-1], "dist" : -370, "bCoef" : 0.1 }, // Bottom wall.
  349. { "normal" : [ 1, 0], "dist" : -670, "bCoef" : 0.1 }, // Left wall.
  350. { "normal" : [-1, 0], "dist" : -670, "bCoef" : 0.1 } // Right wall.
  351. ],
  352.  
  353. // List of traits:
  354. "traits" : {
  355. "ballArea" : { "vis" : false, "bCoef" : 1, "cMask" : ["ball"]},
  356. "goalPostRed" : { "radius" : 4, "invMass" : 0, "bCoef" : 0.5, "color" : "e56e56" },
  357. "goalPostBlue" : { "radius" : 4, "invMass" : 0, "bCoef" : 0.5, "color" : "5689e5" },
  358. "goalNetRed" : { "vis" : true, "bCoef" : 0.1, "cMask" : ["ball"], "curve" : 15, "color" : "ffecec" },
  359. "goalNetBlue" : { "vis" : true, "bCoef" : 0.1, "cMask" : ["ball"], "curve" : 15, "color" : "dbe0ff" },
  360. "kickOffBarrier" : { "vis" : false, "bCoef" : 0.1, "cGroup" : ["redKO", "blueKO"], "cMask" : ["red", "blue"]},
  361. "rogBlue" : { "vis" : true, "curve" : 90, "color" : "dbe0ff", "cMask" : ["red"]},
  362. "rogRed" : { "vis" : true, "curve" : 90, "color" : "ffecec", "cMask" : ["blue"]},
  363. "roglineBlue" : { "vis" : true, "color" : "dbe0ff", "cMask" : ["red"]},
  364. "roglineRed" : { "vis" : true, "color" : "ffecec", "cMask" : ["blue"]},
  365. "linia" : { "vis" : true, "color" : "F6F6EF", "cMask" : ["none"]},
  366. "karne_red" : { "vis" : true, "color" : "F6F6EF", "cMask" : ["blue"]},
  367. "karne_blue" : { "vis" : true, "color" : "F6F6EF", "cMask" : ["red"]}
  368. }
  369. }
Add Comment
Please, Sign In to add comment