player.rb 711 Bytes
class Player < Ship

  attr_accessor :score

  def initialize game, options
    options[:type] = :fighter
    options[:a] = 180.0
    super game, options
    @score = 0
  end

  def move direction
    case direction
    when :up
      @body.p += CP::Vec2.new(0.0, -1.0 * @params[:speed] * 10)
    when :down
      @body.p += CP::Vec2.new(0.0, 1.0 * @params[:speed] * 10)
    when :left
      @body.p += CP::Vec2.new(-1.0 * @params[:speed] * 10, 0.0)
      # @body.a += 5
    when :right
      @body.p += CP::Vec2.new(1.0 * @params[:speed] * 10, 0.0)
      # @body.a -= 5
    end
  end

  def draw *a
    @body.v = CP::Vec2.new(0,0)
    super *a
  end

  def destroy
    @game.state = :lost
    super
  end

end