File size: 952 Bytes
1e40c2a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

function PreviewGroup(baseX, baseY) {
    var i;
    
    this.blocks = [];
    this.shape = null;

    // create the blocks
    for (i = 0; i < 4; i += 1) {
	this.blocks.push(new Block({
	    boardOriginX: baseX,
	    boardOriginY: baseY,
	    blockX: 0,
	    blockY: 0,
	    shape: 'i'
	}));
    }
}

/**
* Sets the shape and color of the blocks
* @param {Char} shape - the letter of the new shape
* @param {Boolean} preview - true if it should have preview colors
*/
PreviewGroup.prototype.setShape = function(shape) {
    var shapeConfig = SHAPES[shape],
    i;

    this.shape = shape;
    
    for (i = 0; i < 4; i += 1) {
	this.blocks[i].setPosition(shapeConfig.pos[i].x, shapeConfig.pos[i].y);
	this.blocks[i].setColor(shape, false);
    }
};

PreviewGroup.prototype.getShape = function () {
    return this.shape;
};

PreviewGroup.prototype.draw = function() {
    var i;
    for (i = 0; i < 4; i += 1) {
	this.blocks[i].draw();
    }
};