(function() {

  this.def_class('Level',__scope.Rome.Document,function(__scope,__class){

    if(!this.__ctor__){this.__ctor__= function Level(){__class.__super__.__ctor__.apply(this, arguments)}; this.__ctor__.prototype = this.prototype; }

    this.key('published', 'number');

    this.key('name', 'string');

    this.key('credits', 'string');

    this.key('grid', 'bitmap');

    this.key('width', 'number');

    this.key('timers', 'hash');

    this.prototype.i_to_rc = function(idx) {
      return [__scope.Math.floor(idx / this.width()), idx % this.width()];
    }; __method_added(this,"i_to_rc");

    this.prototype.rc_to_i = function(r, c) {
      return r * this.width() + ((c + 1000 * this.width()) % this.width());
    }; __method_added(this,"rc_to_i");

    this.prototype["include?"] = function(type) {
      return this.grid()["@array"].indexOf(__scope.Block[type]["@char"]) >= 0;
    }; __method_added(this,"include?");

    this.prototype.real_length = function() {
      var str, w;
      if (this["@real_length"]) return this["@real_length"];
      w = this.width() || 16;
      str = this.grid().raw().join("").replace(/0+$/, '');
      return this["@real_length"] = __scope.Math.ceil(str.length / w);
    }; __method_added(this,"real_length");

  });

  this.def_class('Brush',__scope.Rome.Document,function(__scope,__class){

    if(!this.__ctor__){this.__ctor__= function Brush(){__class.__super__.__ctor__.apply(this, arguments)}; this.__ctor__.prototype = this.prototype; }

    this.key('grid', 'bitmap');

    this.key('width', 'number');

    this.prototype["dirty?"] = function() {
      return false;
    }; __method_added(this,"dirty?");

    this.prototype.i_to_rc = function(idx) {
      return [__scope.Math.floor(idx / this.width()), idx % this.width()];
    }; __method_added(this,"i_to_rc");

    this.prototype.rc_to_i = function(r, c) {
      return r * this.width() + ((c + 1000 * this.width()) % this.width());
    }; __method_added(this,"rc_to_i");

    this.prototype.set_block = function(r, c, t) {
      var idx;
      idx = this.rc_to_i(r, c);
      return this.grid()['[]='](idx,t);
    }; __method_added(this,"set_block");

    this.prototype.get_block = function(r, c) {
      var idx;
      idx = this.rc_to_i(r, c);
      return this.grid()['[]'](idx);
    }; __method_added(this,"get_block");

  });

}).call($$base);

