Sha256: 1799c07750e6d1be79a66b80773a75314f587ca1c0c66fb4ab84bb9325f401fe
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
describe Joybox::Physics::ChainShape do before do @world = World.new gravity: [0, -9.8] @body = @world.new_body position: [100, 100], type: Body::Dynamic end describe "Initialization" do it "should initialize with loop" do circle_shape = ChainShape.new loop: [[0, 0], [16, 16], [32, 32]] @body.new_fixture do fixture shape: circle_shape end @body.fixtures.size.should == 1 end it "should initialize with chain" do circle_shape = ChainShape.new chain: [[0, 0], [16, 16], [32, 32]] @body.new_fixture do fixture shape: circle_shape end @body.fixtures.size.should == 1 end end it "should have a vertices count" do @body.new_fixture do chain_fixture chain: [[0, 0], [16, 16], [32, 32]] end shape = @body.fixtures[0].shape shape.vertices_count.should == 3 end it "should have vertices" do @body.new_fixture do chain_fixture chain: [[0, 0], [16, 16], [32, 32]] end shape = @body.fixtures[0].shape shape.vertices.size.should == 3 end it "should have a previous vertex" do @body.new_fixture do chain_fixture chain: [[0, 0], [16, 16], [32, 32]] end shape = @body.fixtures[0].shape shape.previous_vertex = [-1, -1] shape.has_previous_vertex?.should == true shape.previous_vertex.should == CGPointMake(-1, -1) end it "should have a next vertex" do @body.new_fixture do chain_fixture chain: [[0, 0], [16, 16], [32, 32]] end shape = @body.fixtures[0].shape shape.next_vertex = [64, 64] shape.has_next_vertex?.should == true shape.next_vertex.should == CGPointMake(64, 64) end it "should return a vertex as a Edge Shape" do @body.new_fixture do chain_fixture chain: [[0, 0], [16, 16], [32, 32]] end shape = @body.fixtures[0].shape edge_shape = shape.edge_shape_by_index(1) edge_shape.start_point.should == CGPointMake(16, 16) edge_shape.end_point.should == CGPointMake(32, 32) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
joybox-1.1.1 | spec/motion/joybox/physics/chain_shape_spec.rb |
joybox-1.1.0 | spec/motion/joybox/physics/chain_shape_spec.rb |