Forums Archived

The forums are being archived. See this topic for more information.

Chipmunk callbacks crashing

Get help and support with Rubygame

Chipmunk callbacks crashing

Postby blue-wiz » Mon Jul 12, 2010 1:09 pm

I've used the chipmunk-ffi gem to make my game have accurate physics. However, I am unable to add a collision call back. I have written the following:

Code: Select all
@space.add_collision_func line.shape, @hopper.shape, :post do
  @hopper.bounce @boost if @jump
end


This is supposed to make the bouncy hopper bounce higher when it lands.

however, when I run this I get the following error:

Code: Select all
(eval):3:in `call': Value -610520008 outside int range (RangeError)
  from (eval):3:in `cpSpaceAddCollisionHandler'
  from /var/lib/gems/1.8/gems/chipmunk-ffi-1.1.0/lib/chipmunk-ffi/space.rb:235:in `setup_callbacks'
  from /var/lib/gems/1.8/gems/chipmunk-ffi-1.1.0/lib/chipmunk-ffi/space.rb:223:in `add_collision_func'
  from ./field.rb:70:in `initialize'
...


The game was working fine before I added this block.

Gwilym
blue-wiz
 
Posts: 12
Joined: Mon Jun 28, 2010 4:27 pm

Re: Chipmunk callbacks crashing

Postby jacius » Mon Jul 12, 2010 6:31 pm

Hi Gwilym, that sounds like a bug in chipmunk-ffi. I would suggest reporting it to that project:

http://github.com/shawn42/chipmunk-ffi/issues
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Re: Chipmunk callbacks crashing

Postby blue-wiz » Tue Jul 13, 2010 4:09 pm

I figures it out. I'd got it wrong. This is the working code for those who have the same problem
Code: Select all
  @hopper.shape.collision_type = :hopper

  @lines.each do |line|
    @space.add_static_shape line.shape
    line.shape.collision_type = :line
  end
      
  @space.add_collision_func :line, :hopper, :post do |a,b| 
    # stuff when they collide :)
  end
blue-wiz
 
Posts: 12
Joined: Mon Jun 28, 2010 4:27 pm

Re: Chipmunk callbacks crashing

Postby shawn42 » Wed Jul 14, 2010 1:29 am

I'm glad you were able to figure it out. I've been AWOL for a bit with family stuff. Let me know if you need any more help. :D
User avatar
shawn42
 
Posts: 109
Joined: Tue Feb 10, 2009 8:22 pm


Return to Help & Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron