Sha256: e5af8c2e87172099c52b4b7652890ba97d1ceddcf059fd6bc0a7456c679fcc8c

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require_relative 'projectile.rb'

class EnemyBullet < Projectile
  DAMAGE = 5
  COOLDOWN_DELAY = 30
  MAX_SPEED      = 5

  def get_image
    Gosu::Image.new("#{MEDIA_DIRECTORY}/bullet-mini-reverse.png")
  end

  def initialize(scale, width, height, object, mouse_x = nil, mouse_y = nil, options = {})
    @scale = scale
    @time_alive = 0
    @image = get_image
    # @color = Gosu::Color.new(0xff_000000)
    # @color.red = rand(255 - 40) + 40
    # @color.green = rand(255 - 40) + 40
    # @color.blue = rand(255 - 40) + 40
    if LEFT == options[:side]
      @x = object.x - (object.get_width / 2)
      @y = object.y# - player.get_height
    elsif RIGHT == options[:side]
      @x = (object.x + object.get_width / 2) - 4
      @y = object.y# - player.get_height
    else
      @x = object.x
      @y = object.y
    end
    @image_width  = @image.width  * @scale
    @image_height = @image.height * @scale
    @image_size   = @image_width  * @image_height / 2
    @image_radius = (@image_width  + @image_height) / 4
    @current_speed = self.class.get_max_speed * @scale
  end

  def update width, height, mouse_x = nil, mouse_y = nil, player = nil
    @y += @current_speed
    # Return false when out of screen (gets deleted then)
    @y > 0 && @y < height
    # super(mouse_x, mouse_y)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
line-em-up-0.3.5 line-em-up/models/enemy_bullet.rb