Sha256: e8c735bb5f480f5a6cae38c8d3e0a9511064a33a9fe8db856f44a04cba679882
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require_relative 'pickup.rb' class HealthPack < Pickup attr_reader :x, :y HEALTH_BOOST = 25 def initialize(scale, x = nil, y = nil) @scale = scale @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_pack_0.png", :tileable => true) @x = x @y = y @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 = GLBackground::SCROLLING_SPEED * @scale end def draw image_rot = (Gosu.milliseconds / 50 % 26) if image_rot >= 13 image_rot = 26 - image_rot end image_rot = 12 if image_rot == 13 @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_pack_#{image_rot}.png", :tileable => true) # @image.draw(@x - get_width / 2, @y - get_height / 2, ZOrder::Pickup) super end def update width, height, mouse_x = nil, mouse_y = nil, player = nil @y += @current_speed @y < height + get_height end def collected_by_player player if player.health + HEALTH_BOOST > player.class::MAX_HEALTH player.health = player.class::MAX_HEALTH else player.health += HEALTH_BOOST end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
line-em-up-0.3.5 | line-em-up/models/health_pack.rb |