class Wall
attr_reader :a, :b
def initialize(window, shape, pos)
# window needs to have a attr_accessor for :space
@window = window
@color = Gosu::Color::WHITE
@a = CP::Vec2.new(shape[0][0], shape[0][1])
@b = CP::Vec2.new(shape[1][0], shape[1][1])
@body = CP::Body.new(CP::INFINITY, CP::INFINITY)
@body.p = CP::Vec2.new(pos[0], pos[1])
@body.v = CP::Vec2.new(0,0)
@shape = CP::Shape::Segment.new(@body, @a, @b, 1)
@shape.e = 0.5
@shape.u = 1
@window.space.add_static_shape(@shape)
end
def draw
@window.draw_line(@body.p.x + a.x, @body.p.y + a.y, @color,
@body.p.x + b.x, @body.p.y + b.y, @color,
ZOrder::Wall)
end
end
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill