Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Save and load a snapshot of a Box2D scene using JSON
--# Main
-- Json Test
supportedOrientations(LANDSCAPE_LEFT)
displayMode(OVERLAY)
-- Use this function to perform your initial setup
function setup()
parameter.action("Take snapshot", function() tabSave(objects, "Test") end)
parameter.action("Load from snapshot", function() killBodies() loadBodies() end)
AddToJson() --establish metamethods for encoding vec2, vec3, vec4, matrix as json objects
meshes={mesh(),mesh()}
meshes[1].texture="Platformer Art:Coin"
meshes[2].texture="Platformer Art:Block Grass"
walls={}
local corners = {vec2(0,0), vec2(WIDTH,0), vec2(WIDTH,HEIGHT), vec2(0,HEIGHT), vec2(0,0)}
for i=1,#corners-1 do
walls[i]=physics.body(EDGE, corners[i],corners[i+1])
end
--resetBodies()
loadBodies()
end
function draw()
physics.gravity(Gravity)
for i,v in ipairs(objects) do
v:update()
end
background(0)
meshes[1]:draw()
meshes[2]:draw()
end
function resetBodies()
local rnd = math.random
objects={}
for i=1,15 do
--circular bodies
local x,y =rnd()*WIDTH*0.6+WIDTH*0.2, rnd()*HEIGHT*0.6+HEIGHT*0.2
local r = rnd(20)+20
objects[#objects+1]=Entity{
body=physics.body(CIRCLE, r),
bodyProperties={position=vec2(x,y), restitution=rnd()+0.5},
rectProperties={meshId=1, width=r * 2, color=color(rnd(255), rnd(255), rnd(255))}
}
--square bodies
local w,h = rnd(20)+20, rnd(20)+20
x,y =rnd()*WIDTH*0.6+WIDTH*0.2, rnd()*HEIGHT*0.6+HEIGHT*0.2
objects[#objects+1]=Entity{
body=physics.body(POLYGON, vec2(-w,-h), vec2(-w,h), vec2(w,h), vec2(w,-h)),
bodyProperties={position=vec2(x,y), restitution=rnd(), },
rectProperties={meshId=2, width=w*2, height =h*2, color=color(rnd(255), rnd(255), rnd(255))}
}
end
tabSave(objects, "Test") --save these objects
end
function killBodies()
meshes[1]:clear()
meshes[2]:clear()
for i,v in ipairs(objects) do
v.body:destroy()
end
end
function loadBodies()
local loadBack=tabLoad("Test")
loadBack=tabIterate(loadBack) --decode json objects back to vec2, vec3, vec4
objects={}
for i,v in ipairs(loadBack) do
local b=v.body.__rigidbody
local body
if b.radius then
body=physics.body(b.shapeType, b.radius)
else
body=physics.body(b.shapeType, table.unpack(b.points))
end
objects[i]=Entity{
body=body,
bodyProperties=v.body.__rigidbodyProperties,
rectProperties={meshId=v.meshId, width=v.width, height=v.height, color=v.color}
}
end
end
--# Json
--meta-methods
function AddToJson()
local meta = getmetatable(vec2())
meta.__tojson = function(t)
return json.encode({__vec2={x=t.x,y=t.y}})
end
meta = getmetatable(vec3())
meta.__tojson = function(t)
return json.encode({__vec3={x=t.x,y=t.y,z=t.z}})
end
meta = getmetatable(vec4())
meta.__tojson = function(t)
return json.encode({__vec4={x=t.x,y=t.y,z=t.z,w=t.w}})
end
meta = getmetatable(matrix())
meta.__tojson = function(t)
return json.encode({__mat4={t[1],t[2],t[3],t[4], t[5],t[6],t[7],t[8], t[9],t[10],t[11],t[12], t[13],t[14],t[15],t[16]}}) --a matrix.unpack function would've been handy here!
end
meta = getmetatable(color())
meta.__tojson = function(t)
return json.encode({__color={r=t.r, g=t.g, b=t.b, a=t.a}})
end
meta = getmetatable(mesh())
meta.__tojson = function(t)
return json.encode({nil}) --({__mesh=t.id})
end
local dummy = physics.body(CIRCLE, 10)
meta = getmetatable(dummy)
dummy:destroy()
meta.__tojson = function(t)
return json.encode({
__rigidbody={shapeType=t.shapeType, radius=t.radius, points=t.points},
__rigidbodyProperties={type=t.type, position=t.position, angle=t.angle, linearVelocity=t.linearVelocity, angularVelocity=t.angularVelocity, restitution=t.restitution, friction=t.friction, linearDamping=t.linearDamping, angularDamping=t.angularDamping
}})
end
--add extra categories from below according to needs
--gravityScale=t.gravityScale, info=t.info, density=t.density, sensor=t.sensor, categories=t.categories, mask=t.mask, fixedRotation=t.fixedRotation, active=t.active, awake=t.awake, sleepingAllowed=t.sleepingAllowed, interpolate=t.interpolate, joints=t.joints, bullet=t.bullet,
end
function tabSave(tab, loc)
local str=json.encode(tab, {indent = true, exception = jsonException})
saveProjectTab(loc, "--["..str.."]\n")
end
function tabLoad(loc)
local str=readProjectTab(loc)
return json.decode(string.sub(str,4,-3))
end
local underscore = {"=","~","-","."} --underscore characters indicate table depth
function tabIterate(tab, verbose, i) --set verbose to true for print out (debugging)
local new = {}
local i = i or 0
local indent = string.rep(" ", i*3) --depth of indentation
for k,v in pairs(tab) do
local report = indent..k
if type(v)=="table" then --check first whether its a pseudo-table representing a vec2, vec3, vec4, mat4
if v.__vec2 then --convert back to vec2
local vec = v.__vec2
new[k] = vec2(vec.x, vec.y)
elseif v.__vec3 then --convert back to vec3
local vec = v.__vec3
new[k] = vec3(vec.x, vec.y, vec.z)
elseif v.__vec4 then --convert back to vec4
local vec = v.__vec4
new[k] = vec4(vec.x, vec.y, vec.z, vec.w)
elseif v.__color then --convert back to vec4
local vec = v.__color
new[k] = color(vec.r, vec.g, vec.b, vec.a)
elseif v.__mat4 then --convert back to matrix
new[k] = matrix(table.unpack(v.__mat4))
else --genuine table
if verbose then
local under = string.rep(underscore[math.min(#underscore, i+1)], string.len(k))
report = report.."\n"..indent..under
print(report)
end
new[k]=tabIterate(v, verbose, i+1) --increase indent upon recursion
end
else
new[k]=v
end
if verbose and type(new[k])~="table" then
report = report..": "..tostring(new[k])
print(report)
end
end
return new
end
--# Entity
Entity = class()
function Entity:init(t)
if t.body then
self.body = t.body
self.body.interpolate = true
for k,v in pairs(t.bodyProperties) do
self.body[k]=v
end
end
if t.rectProperties then
for k,v in pairs(t.rectProperties) do
self[k]=v
end
self.mesh = meshes[self.meshId]
if not self.height then self.height=self.width end
self.r = self.mesh:addRect(0,0, self.width, self.height)
self.mesh:setRectColor(self.r, self.color)
end
end
function Entity:update()
self.mesh:setRect(self.r,self.body.x,self.body.y,self.width, self.height, math.rad(self.body.angle))
end
--# Test
--[[{
"color":{"__color":{"b":212.0,"a":255.0,"r":184.0,"g":41.0}},
"width":56,
"body":{"__rigidbody":{"radius":28.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-123.60840606689,"y":50.084274291992}},"angularVelocity":54.199081026425,"angle":-111.11995828615,"restitution":0.53865760564804,"position":{"__vec2":{"x":891.244140625,"y":65.013198852539}}}},
"r":1,
"mesh":[],
"height":56,
"meshId":1
},{
"color":{"__color":{"b":31.0,"a":255.0,"r":78.0,"g":159.0}},
"width":78,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-39.0,"y":-40.0}},{"__vec2":{"x":-39.0,"y":40.0}},{"__vec2":{"x":39.0,"y":40.0}},{"__vec2":{"x":39.0,"y":-40.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-181.04208374023,"y":60.860694885254}},"angularVelocity":-117.16934072082,"angle":-294.336975564,"restitution":0.98746371269226,"position":{"__vec2":{"x":220.08139038086,"y":236.96911621094}}}},
"r":1,
"mesh":[],
"height":80,
"meshId":2
},{
"color":{"__color":{"b":157.0,"a":255.0,"r":162.0,"g":236.0}},
"width":50,
"body":{"__rigidbody":{"radius":25.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-106.57793426514,"y":211.66331481934}},"angularVelocity":393.29024274953,"angle":753.4569640247,"restitution":1.2879832983017,"position":{"__vec2":{"x":844.59521484375,"y":595.62585449219}}}},
"r":2,
"mesh":[],
"height":50,
"meshId":1
},{
"color":{"__color":{"b":90.0,"a":255.0,"r":4.0,"g":229.0}},
"width":52,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-26.0,"y":-37.0}},{"__vec2":{"x":-26.0,"y":37.0}},{"__vec2":{"x":26.0,"y":37.0}},{"__vec2":{"x":26.0,"y":-37.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-117.25454711914,"y":-11.668020248413}},"angularVelocity":27.321036717807,"angle":-2.2482397947968,"restitution":0.073303528130054,"position":{"__vec2":{"x":950.36328125,"y":38.470054626465}}}},
"r":2,
"mesh":[],
"height":74,
"meshId":2
},{
"color":{"__color":{"b":172.0,"a":255.0,"r":156.0,"g":72.0}},
"width":44,
"body":{"__rigidbody":{"radius":22.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":119.15162658691,"y":94.731338500977}},"angularVelocity":280.14193001574,"angle":806.66550369694,"restitution":1.1051412820816,"position":{"__vec2":{"x":80.350006103516,"y":329.72036743164}}}},
"r":3,
"mesh":[],
"height":44,
"meshId":1
},{
"color":{"__color":{"b":24.0,"a":255.0,"r":244.0,"g":86.0}},
"width":68,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-34.0,"y":-21.0}},{"__vec2":{"x":-34.0,"y":21.0}},{"__vec2":{"x":34.0,"y":21.0}},{"__vec2":{"x":34.0,"y":-21.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-134.68103027344,"y":15.991744041443}},"angularVelocity":34.847403164257,"angle":31.624400819468,"restitution":0.72237491607666,"position":{"__vec2":{"x":613.81604003906,"y":94.739562988281}}}},
"r":3,
"mesh":[],
"height":42,
"meshId":2
},{
"color":{"__color":{"b":68.0,"a":255.0,"r":233.0,"g":241.0}},
"width":50,
"body":{"__rigidbody":{"radius":25.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-148.81484985352,"y":45.380233764648}},"angularVelocity":39.119990433518,"angle":391.09635866736,"restitution":0.98836261034012,"position":{"__vec2":{"x":664.71948242188,"y":125.48670959473}}}},
"r":4,
"mesh":[],
"height":50,
"meshId":1
},{
"color":{"__color":{"b":1.0,"a":255.0,"r":168.0,"g":159.0}},
"width":76,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-38.0,"y":-27.0}},{"__vec2":{"x":-38.0,"y":27.0}},{"__vec2":{"x":38.0,"y":27.0}},{"__vec2":{"x":38.0,"y":-27.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-131.43852233887,"y":46.389877319336}},"angularVelocity":54.057375091715,"angle":45.509990986996,"restitution":0.55343943834305,"position":{"__vec2":{"x":848.31091308594,"y":296.7421875}}}},
"r":4,
"mesh":[],
"height":54,
"meshId":2
},{
"color":{"__color":{"b":24.0,"a":255.0,"r":185.0,"g":249.0}},
"width":70,
"body":{"__rigidbody":{"radius":35.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-123.33557891846,"y":115.30902862549}},"angularVelocity":42.775200318796,"angle":175.87981633555,"restitution":1.0880123376846,"position":{"__vec2":{"x":429.47891235352,"y":438.11755371094}}}},
"r":5,
"mesh":[],
"height":70,
"meshId":1
},{
"color":{"__color":{"b":140.0,"a":255.0,"r":234.0,"g":110.0}},
"width":78,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-39.0,"y":-34.0}},{"__vec2":{"x":-39.0,"y":34.0}},{"__vec2":{"x":39.0,"y":34.0}},{"__vec2":{"x":39.0,"y":-34.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-130.15022277832,"y":33.844177246094}},"angularVelocity":-10.419468093006,"angle":-132.16612753423,"restitution":0.0010065180249512,"position":{"__vec2":{"x":628.59832763672,"y":180.34777832031}}}},
"r":5,
"mesh":[],
"height":68,
"meshId":2
},{
"color":{"__color":{"b":239.0,"a":255.0,"r":48.0,"g":71.0}},
"width":46,
"body":{"__rigidbody":{"radius":23.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-42.670429229736,"y":-12.567100524902}},"angularVelocity":-63.234977336056,"angle":-60559611133.099,"restitution":0.54409992694855,"position":{"__vec2":{"x":908.58728027344,"y":206.16510009766}}}},
"r":6,
"mesh":[],
"height":46,
"meshId":1
},{
"color":{"__color":{"b":124.0,"a":255.0,"r":231.0,"g":164.0}},
"width":60,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-30.0,"y":-33.0}},{"__vec2":{"x":-30.0,"y":33.0}},{"__vec2":{"x":30.0,"y":33.0}},{"__vec2":{"x":30.0,"y":-33.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-213.52442932129,"y":187.59973144531}},"angularVelocity":-132.2114253488,"angle":-98.913187635481,"restitution":0.30837768316269,"position":{"__vec2":{"x":763.95880126953,"y":492.74505615234}}}},
"r":6,
"mesh":[],
"height":66,
"meshId":2
},{
"color":{"__color":{"b":168.0,"a":255.0,"r":210.0,"g":206.0}},
"width":42,
"body":{"__rigidbody":{"radius":21.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-87.11141204834,"y":109.47672271729}},"angularVelocity":62.14135476691,"angle":72.335398442776,"restitution":0.66908568143845,"position":{"__vec2":{"x":746.08966064453,"y":266.33010864258}}}},
"r":7,
"mesh":[],
"height":42,
"meshId":1
},{
"color":{"__color":{"b":41.0,"a":255.0,"r":46.0,"g":149.0}},
"width":62,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-31.0,"y":-28.0}},{"__vec2":{"x":-31.0,"y":28.0}},{"__vec2":{"x":31.0,"y":28.0}},{"__vec2":{"x":31.0,"y":-28.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-168.92585754395,"y":51.989532470703}},"angularVelocity":77.03403583699,"angle":90.56410782803,"restitution":0.14727072417736,"position":{"__vec2":{"x":693.70233154297,"y":259.36068725586}}}},
"r":7,
"mesh":[],
"height":56,
"meshId":2
},{
"color":{"__color":{"b":152.0,"a":255.0,"r":228.0,"g":123.0}},
"width":42,
"body":{"__rigidbody":{"radius":21.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-198.02806091309,"y":5.0663948059082e-06}},"angularVelocity":20.987907734453,"angle":-188.35045768443,"restitution":0.74435615539551,"position":{"__vec2":{"x":717.40588378906,"y":21.218963623047}}}},
"r":8,
"mesh":[],
"height":42,
"meshId":1
},{
"color":{"__color":{"b":166.0,"a":255.0,"r":40.0,"g":113.0}},
"width":76,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-38.0,"y":-36.0}},{"__vec2":{"x":-38.0,"y":36.0}},{"__vec2":{"x":38.0,"y":36.0}},{"__vec2":{"x":38.0,"y":-36.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-156.5302734375,"y":31.297170639038}},"angularVelocity":-6.5132030788402,"angle":34.254156838612,"restitution":0.020476881414652,"position":{"__vec2":{"x":768.10919189453,"y":51.674556732178}}}},
"r":8,
"mesh":[],
"height":72,
"meshId":2
},{
"color":{"__color":{"b":109.0,"a":255.0,"r":235.0,"g":233.0}},
"width":76,
"body":{"__rigidbody":{"radius":38.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-51.281433105469,"y":41.140003204346}},"angularVelocity":19.939190244005,"angle":-12.222545826336,"restitution":0.63315409421921,"position":{"__vec2":{"x":762.13940429688,"y":358.1676940918}}}},
"r":9,
"mesh":[],
"height":76,
"meshId":1
},{
"color":{"__color":{"b":69.0,"a":255.0,"r":121.0,"g":167.0}},
"width":48,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-24.0,"y":-22.0}},{"__vec2":{"x":-24.0,"y":22.0}},{"__vec2":{"x":24.0,"y":22.0}},{"__vec2":{"x":24.0,"y":-22.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-11.814755439758,"y":56.638793945312}},"angularVelocity":-162.06137375775,"angle":89.901859516294,"restitution":0.64327186346054,"position":{"__vec2":{"x":41.21203994751,"y":258.74853515625}}}},
"r":9,
"mesh":[],
"height":44,
"meshId":2
},{
"color":{"__color":{"b":58.0,"a":255.0,"r":110.0,"g":107.0}},
"width":50,
"body":{"__rigidbody":{"radius":25.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-106.67462921143,"y":114.15914154053}},"angularVelocity":82.9881576233,"angle":-261.31948594632,"restitution":0.7956166267395,"position":{"__vec2":{"x":739.06384277344,"y":181.02383422852}}}},
"r":10,
"mesh":[],
"height":50,
"meshId":1
},{
"color":{"__color":{"b":148.0,"a":255.0,"r":211.0,"g":75.0}},
"width":76,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-38.0,"y":-40.0}},{"__vec2":{"x":-38.0,"y":40.0}},{"__vec2":{"x":38.0,"y":40.0}},{"__vec2":{"x":38.0,"y":-40.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":53.928527832031,"y":228.02954101562}},"angularVelocity":326.95776779468,"angle":192.71982531914,"restitution":0.92627036571503,"position":{"__vec2":{"x":51.547519683838,"y":477.72268676758}}}},
"r":10,
"mesh":[],
"height":80,
"meshId":2
},{
"color":{"__color":{"b":174.0,"a":255.0,"r":188.0,"g":14.0}},
"width":56,
"body":{"__rigidbody":{"radius":28.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-77.450538635254,"y":13.783011436462}},"angularVelocity":5.765506966154,"angle":-96.576368184555,"restitution":1.3774162530899,"position":{"__vec2":{"x":901.56304931641,"y":144.84625244141}}}},
"r":11,
"mesh":[],
"height":56,
"meshId":1
},{
"color":{"__color":{"b":202.0,"a":255.0,"r":77.0,"g":209.0}},
"width":46,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-23.0,"y":-26.0}},{"__vec2":{"x":-23.0,"y":26.0}},{"__vec2":{"x":23.0,"y":26.0}},{"__vec2":{"x":23.0,"y":-26.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-109.9588394165,"y":8.0935564041138}},"angularVelocity":116.08754803932,"angle":-42.075870910057,"restitution":0.95694053173065,"position":{"__vec2":{"x":515.96697998047,"y":163.00384521484}}}},
"r":11,
"mesh":[],
"height":52,
"meshId":2
},{
"color":{"__color":{"b":146.0,"a":255.0,"r":66.0,"g":43.0}},
"width":44,
"body":{"__rigidbody":{"radius":22.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-126.90627288818,"y":74.466835021973}},"angularVelocity":89.317277285611,"angle":339.34095540143,"restitution":1.2560099363327,"position":{"__vec2":{"x":504.88781738281,"y":252.91331481934}}}},
"r":12,
"mesh":[],
"height":44,
"meshId":1
},{
"color":{"__color":{"b":16.0,"a":255.0,"r":4.0,"g":187.0}},
"width":54,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-27.0,"y":-31.0}},{"__vec2":{"x":-27.0,"y":31.0}},{"__vec2":{"x":27.0,"y":31.0}},{"__vec2":{"x":27.0,"y":-31.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-183.88938903809,"y":105.9762878418}},"angularVelocity":482.42981217331,"angle":1135.2847559884,"restitution":0.80978238582611,"position":{"__vec2":{"x":216.58592224121,"y":530.37915039062}}}},
"r":12,
"mesh":[],
"height":62,
"meshId":2
},{
"color":{"__color":{"b":223.0,"a":255.0,"r":115.0,"g":37.0}},
"width":46,
"body":{"__rigidbody":{"radius":23.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-210.97311401367,"y":100.71027374268}},"angularVelocity":29.425971246411,"angle":16.310440511572,"restitution":0.84738206863403,"position":{"__vec2":{"x":501.17965698242,"y":301.10754394531}}}},
"r":13,
"mesh":[],
"height":46,
"meshId":1
},{
"color":{"__color":{"b":149.0,"a":255.0,"r":226.0,"g":17.0}},
"width":66,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-33.0,"y":-30.0}},{"__vec2":{"x":-33.0,"y":30.0}},{"__vec2":{"x":33.0,"y":30.0}},{"__vec2":{"x":33.0,"y":-30.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-104.76523590088,"y":-26.710601806641}},"angularVelocity":6.1163818946672,"angle":6.9085711402673,"restitution":0.048425290733576,"position":{"__vec2":{"x":544.25714111328,"y":56.191078186035}}}},
"r":13,
"mesh":[],
"height":60,
"meshId":2
},{
"color":{"__color":{"b":173.0,"a":255.0,"r":165.0,"g":18.0}},
"width":64,
"body":{"__rigidbody":{"radius":32.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-16.748950958252,"y":135.39161682129}},"angularVelocity":291.31464417702,"angle":184197.51022165,"restitution":0.69257724285126,"position":{"__vec2":{"x":70.618682861328,"y":653.47137451172}}}},
"r":14,
"mesh":[],
"height":64,
"meshId":1
},{
"color":{"__color":{"b":200.0,"a":255.0,"r":243.0,"g":191.0}},
"width":60,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-30.0,"y":-30.0}},{"__vec2":{"x":-30.0,"y":30.0}},{"__vec2":{"x":30.0,"y":30.0}},{"__vec2":{"x":30.0,"y":-30.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-93.776954650879,"y":51.36771774292}},"angularVelocity":22.614358483393,"angle":-76.880575146718,"restitution":0.15160049498081,"position":{"__vec2":{"x":619.14978027344,"y":338.03765869141}}}},
"r":14,
"mesh":[],
"height":60,
"meshId":2
},{
"color":{"__color":{"b":73.0,"a":255.0,"r":80.0,"g":201.0}},
"width":62,
"body":{"__rigidbody":{"radius":31.0,"shapeType":0.0},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-115.06912994385,"y":113.3604888916}},"angularVelocity":-125.74857741273,"angle":-498.27060546246,"restitution":0.52560311555862,"position":{"__vec2":{"x":893.85357666016,"y":368.41217041016}}}},
"r":15,
"mesh":[],
"height":62,
"meshId":1
},{
"color":{"__color":{"b":50.0,"a":255.0,"r":44.0,"g":226.0}},
"width":58,
"body":{"__rigidbody":{"shapeType":2.0,"points":[{"__vec2":{"x":-29.0,"y":-35.0}},{"__vec2":{"x":-29.0,"y":35.0}},{"__vec2":{"x":29.0,"y":35.0}},{"__vec2":{"x":29.0,"y":-35.0}}]},"__rigidbodyProperties":{"linearDamping":0.0,"angularDamping":0.0,"type":2,"friction":0.20000000298023,"linearVelocity":{"__vec2":{"x":-66.420509338379,"y":88.874740600586}},"angularVelocity":-11.38469335104,"angle":-62.772669151895,"restitution":0.91659253835678,"position":{"__vec2":{"x":965.36004638672,"y":263.97467041016}}}},
"r":15,
"mesh":[],
"height":70,
"meshId":2
}]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.