a guest Dec 30th, 2014 224 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- require 'gosu'
- require 'chipmunk'
- class Ball
- attr_reader :shape #Shape is used for position/velocity characteristics of the player.
- def initialize(parent, space)
- @body = CP::StaticBody.new
- @shape = CP::Shape::Circle.new(@body, 15, CP::Vec2.new(0.0, 0.0))
- @image = Gosu::Image.new(parent, 'media/Ball.png', false)
- @shape.body.p = CP::Vec2.new(rand(SCREEN_WIDTH), rand(SCREEN_HEIGHT)) # position
- @shape.collision_type = :ball
- #@shape.body.apply_impulse((CP::Vec2.new(30.0, 0.0) * ((SCREEN_WIDTH/2))), CP::Vec2.new(0.0, 0.0))
- #Obviously this would not work on a static body.
- def draw
- @image.draw(@shape.body.p.x - 15, @shape.body.p.y - 15, ZOrder::BALL)
RAW Paste Data