source: js/viewer-f0/js/Block.js @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 937 bytes
Line 
1function Block(number){
2    this.id = number;
3    this.elements = [];
4    this.w = 1;
5    this.h = 1;
6    this.minx = 0;
7    this.miny = 0;
8    this.maxx = 0;
9    this.maxy = 0;
10    blocks[this.id] = this;
11
12    this.map = [];
13}
14
15Block.prototype.freeMap = function(){
16    if(this.map)
17        this.map = null;
18}
19
20Block.prototype.needMap = function(){
21    if(this.map)
22        return;
23    this.createMap();
24
25}
26
27Block.prototype.createMap = function(){
28    this.freeMap();
29    this.w = this.maxx - this.minx + 1;
30    this.h = this.maxy - this.miny + 1;
31    for(var i = 0; i < w*h; i++)
32        this.map.push(0);
33
34    for (var i = 0; i < this.elements.size(); i++)
35    {
36        var e = this.elements[i];
37        this.map[this.w*(einfos[e].y - this.miny) + (einfos[e].x - this.minx)] = 1;
38    }
39
40
41}
42
43Block.prototype.destroy = function()
44{
45    blocks[this.id] = 0;
46    this.freeMap();
47}
48
49Block.prototype.addElement = function(number, x, y){
50
51}
Note: See TracBrowser for help on using the repository browser.