Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/src/js/jgame.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 109 by tsugehara, Sat Jul 27 09:50:09 2013 UTC revision 110 by tsugehara, Sat Jul 27 15:23:20 2013 UTC
# Line 2148  var jg; Line 2148  var jg;
2148              this.chipCount = cnt2;              this.chipCount = cnt2;
2149          };          };
2150    
2151          Tile.prototype.generate = function (data, width, height) {          Tile.prototype._clear = function (width, height) {
             this.data = data;  
             if (!width)  
                 width = this.data.length;  
             if (!height)  
                 height = this.data[0].length;  
2152              this.size = {              this.size = {
2153                  width: width,                  width: width,
2154                  height: height                  height: height
2155              };              };
2156              this.width = this.tileWidth * width;              this.width = this.tileWidth * width;
2157              this.height = this.tileHeight * height;              this.height = this.tileHeight * height;
2158            };
2159    
2160            Tile.prototype.clear = function (width, height) {
2161                if (!width)
2162                    width = this.size.width;
2163                if (!height)
2164                    height = this.size.height;
2165                this._clear(width, height);
2166                this.data = [];
2167                for (var x = 0; x < width; x++) {
2168                    this.data[x] = [];
2169                    for (var y = 0; y < height; y++)
2170                        this.data[x][y] = 0;
2171                }
2172                this.refresh();
2173            };
2174    
2175            Tile.prototype.generate = function (data, width, height) {
2176                this.data = data;
2177                if (!width)
2178                    width = this.data.length;
2179                if (!height)
2180                    height = this.data[0].length;
2181                this._clear(width, height);
2182              this.refresh();              this.refresh();
2183          };          };
2184    
# Line 2167  var jg; Line 2186  var jg;
2186              this.canvas = window.createCanvas(this.width, this.height);              this.canvas = window.createCanvas(this.width, this.height);
2187              var c = this.canvas.getContext("2d");              var c = this.canvas.getContext("2d");
2188    
2189              for (var x = 0; x < this.size.width; x++) {              for (var x = 0; x < this.size.width; x++)
2190                  for (var y = 0; y < this.size.height; y++) {                  for (var y = 0; y < this.size.height; y++)
2191                      if (this.data[x][y] < 0)                      this.drawChip(x, y, false, c);
2192                          continue;  
2193                      var cs = this.chipMap[this.data[x][y]];              this.updated();
2194                      cs.draw(c, x, y, this.data[x][y] - cs.chipOffset);          };
2195                  }  
2196              }          Tile.prototype.drawChip = function (x, y, clear, context) {
2197                if (context === undefined)
2198                    context = this.canvas.getContext("2d");
2199    
2200                if (clear)
2201                    context.clearRect(x * this.tileWidth, y * this.tileHeight, this.tileWidth, this.tileHeight);
2202    
2203                if (this.data[x][y] < 0)
2204                    return;
2205                var cs = this.chipMap[this.data[x][y]];
2206                cs.draw(context, x, y, this.data[x][y] - cs.chipOffset);
2207          };          };
2208    
2209          Tile.prototype.draw = function (context) {          Tile.prototype.draw = function (context) {
2210                if (!this.canvas)
2211                    return;
2212              var parent = this.parent ? this.parent : this;              var parent = this.parent ? this.parent : this;
2213              var scroll = parent.scroll ? parent.scroll : { x: 0, y: 0 };              var scroll = parent.scroll ? parent.scroll : { x: 0, y: 0 };
2214              var src = {              var src = {

Legend:
Removed from v.109  
changed lines
  Added in v.110

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26