Hi,
I am trying to make a poly shape and apply an impulse on it using RUBY. The gravity, velocity works fine but the impulse does not work :S (Impulse only works on shapes that do not have CP::Shape::Poly)
Here's the code
@space = CP::Space.new
@thevertices = [
CP::Vec2.new(0,0), #x1 first corner
CP::Vec2.new(0,50), #x2 second corner
CP::Vec2.new(49,49), #x3 third corner
CP::Vec2.new(49,0) #x4 fourth corner
]
@b_body = CP::Body.new((1.0/0.0),(1.0/0.0))
#create a square with the vertices as defined above
@b_shape = CP::Shape::Poly.new(@b_body,@thevertices,CP::Vec2.new(0.0,0.0))
@b_shape.u = 1.0 # friction
@b_shape.e = 0.75 # bounce
@b_shape.collision_type = :floor
@b_shape.body.p = CP::Vec2.new(300.0, 100.0)
if button_down?Gosu::KbSpace then @b_shape.body.apply_impulse(CP::Vec2.new(0.0,- 200.0),CP::Vec2.new(0.0,0.0)) end
@b_image.draw_rot(@b_shape.body.p.x,@b_shape.body.p.y,1,@b_shape.body.a.radians_to_gosu)
any suggestions??
Thanks
Poly Shape with apply_impulse problem
-
- Posts: 2
- Joined: Sat Dec 10, 2011 2:20 pm
- Contact:
-
- Posts: 2
- Joined: Sat Dec 10, 2011 2:20 pm
- Contact:
Re: Poly Shape with apply_impulse problem
fixed.
one needs to give a mass to the poly
one needs to give a mass to the poly
Who is online
Users browsing this forum: Heise IT-Markt [Crawler] and 30 guests