util.rb 675 B

12345678910111213141516171819202122232425262728
  1. # Convenience function that loads a lisp file from disk and checks for a
  2. # root symbol
  3. def load_lisp(filename, root_symbol)
  4. tree = sexpr_read_from_file(filename)
  5. if tree == nil then
  6. raise "Error: Couldn't load '#{filename}'"
  7. end
  8. if tree[0] != root_symbol then
  9. raise "Error: '#{filename}' is not a '#{root_symbol}' file"
  10. end
  11. return tree
  12. end
  13. def load_cl_sprite(filename)
  14. if filename[-4..-1] == ".png"
  15. sprite = make_sprite(filename)
  16. elsif filename[-7..-1] == ".sprite"
  17. supertux_sprite = Sprite.new(filename)
  18. sprite = supertux_sprite.get_cl_sprite()
  19. else
  20. raise "Unsupported sprite format '#{spritefile}'"
  21. end
  22. return sprite
  23. end