Method: Core::Parse.animations

Defined in:
lib/parse.rb

.animationsObject

FIXME bit hacked



565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/parse.rb', line 565

def self.animations
  p = {
    "length" => :int,
    "color" => :color,
    "x" => :float,
    "y" => :float,
    "mode" => :symbol,
  }
  anims = {}
  Dir.new("#{Core::LIBRARY_PATH}/def/animations").each { |file|
    next if file == "." or file == ".."
    frames = Parser.new("def/animations/#{file}", p, Core::Frame, true).parse
    block = false
    @graphic = @split_x = @split_y = @repeat = nil
    f = File.open("#{Core::LIBRARY_PATH}/def/animations/#{file}")
    f.each_line { |line|
      line.gsub!(" ", "")
      if line[0] == '('
        block = true
        next
      end
      if block
        if line[0] == ')'
          anims.store(file.gsub(".anim", "").to_sym, Core::Animation.new(@graphic, @split_x.to_i, @split_y.to_i, @repeat.to_b, frames))
          break
        else  
          line.gsub!("\"", "")
          line =~ /(.+)\=(.+)/
          key = $1
          val = $2
          ivs("@#{key}", val)
        end
      end
    }
    f.close
  }
  puts("INFO: Parsed #{anims.size} animations")
  return anims
end