
require 'chipmunk'
require 'gosu'
class Ammo
  attr_accessor :x,:y, :angle, :ammo_body, :ammo_shape

  def initialize(window,ammoimage)
    #create a new image on the arrow
   
    
    
    @ammoimage = ammoimage
    @angle = 0.0 
    
  
    @x = @y  = @angle = 0.0
    
    
    #chipmunk properties
    
      thevertices = [
      CP::Vec2.new(0,0), #x1 first corner
      CP::Vec2.new(0,20), #x2 second corner
      CP::Vec2.new(20,20), #x3 third corner
      CP::Vec2.new(20,0) #x4 fourth corner
    ]
    
    
    @ammo_body = CP::Body.new((1.0/0.0),(1.0/0.0))
    @ammo_body.m =1

   
   
    #create a square with the vertices as defined above
    @ammo_shape = CP::Shape::Poly.new(@ammo_body,thevertices,CP::Vec2.new(0.0,0.0))
 
    @ammo_shape.collision_type = :ammo
 
    @ammo_shape.body.p.x =800
    @ammo_shape.body.p.y = rand(400)+100
    
    @ammo_shape.body.v =CP::Vec2.new(-25,0)
  
    @ammo_shape.body.a = 0.degrees_to_radians
    
    
  end
  

 
  def draw

  
   @ammoimage.draw_rot( @ammo_shape.body.p.x+10, @ammo_shape.body.p.y+10, 1, @ammo_shape.body.a.radians_to_degrees,center_x = 0.5, center_y = 0.5, factor_x = 1, factor_y = 1, color = 0xffffffff, mode = :default)
    #@crateimage.draw(@crate_shape.body.p.x,@crate_shape.body.p.y,1,factor_x=1, factor_y=1, color = 0xffffffff, mode = :default)
  end
  
end