Line | |
---|
1 | function 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 | |
---|
15 | Block.prototype.freeMap = function(){ |
---|
16 | if(this.map) |
---|
17 | this.map = null; |
---|
18 | } |
---|
19 | |
---|
20 | Block.prototype.needMap = function(){ |
---|
21 | if(this.map) |
---|
22 | return; |
---|
23 | this.createMap(); |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | Block.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 | |
---|
43 | Block.prototype.destroy = function() |
---|
44 | { |
---|
45 | blocks[this.id] = 0; |
---|
46 | this.freeMap(); |
---|
47 | } |
---|
48 | |
---|
49 | Block.prototype.addElement = function(number, x, y){ |
---|
50 | |
---|
51 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.