I've just started trying to write a game in Ruby using Chipmunk. I've been trying to make a border around the screen, but at the moment my objects are falling through. Here's what I've got.
Code: Select all
@space = CP::Space.new
@space.gravity = CP::Vec2.new(0.0, 10.0)
boundary = CP::Body.new(100.0, 100.0)
boundary_shapes = [CP::Shape::Segment.new(boundary,
CP::Vec2.new(0.0, 0.0),
CP::Vec2.new(0.0, 480.0),
3),
CP::Shape::Segment.new(boundary,
CP::Vec2.new(0.0, 480.0),
CP::Vec2.new(640.0, 480.0),
3),
CP::Shape::Segment.new(boundary,
CP::Vec2.new(640.0, 480.0),
CP::Vec2.new(640.0, 0.0),
3)]
boundary_shapes.each do |shape|
@space.add_shape(shape)
end
boundary.p = CP::Vec2.new(0.0, 0.0)
I'm still pretty new to programming, so I could use all the help I can get.