-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.as
85 lines (74 loc) · 2.46 KB
/
Board.as
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
This file is part of EseaTetris.
EseaTetris is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
EseaTetris is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EseaTetris. If not, see <http://www.gnu.org/licenses/>.
*/
package {
import flash.display.Sprite;
import flash.display.DisplayObjectContainer;
import flash.text.TextField;
public class Board extends Sprite {
private var _scoreC:Counter;
private var _levelC:Counter;
private var _linesC:Counter;
private var _score:uint = 0;
private var _level:uint = 1;
private var _lines:uint = 0;
public function reset():void {
score = 0;
level = 1;
lines = 0;
removeChild(_nextPiece);
}
public function get score():uint { return _score; }
public function set score(val:uint):void {
_score = val;
_scoreC.text = _score.toString();
}
public function get level():uint { return _level; }
public function set level(val:uint):void {
_level = val;
_levelC.text = _level.toString();
}
public function get lines():uint { return _lines; }
public function set lines(val:uint):void {
_lines = val;
level = _lines/10+1;
_linesC.text = _lines.toString();
}
private var _nextLabel:TextField;
private var _nextPiece:Block;
public function Board() {
_scoreC = new Counter("SCORE",_score.toString());
_levelC = new Counter("LEVEL",_level.toString());
_linesC = new Counter("LINES",_lines.toString());
addChild(_scoreC);
_levelC.y = _scoreC.textHeight;
addChild(_levelC);
_linesC.y = _scoreC.textHeight+_levelC.textHeight;
addChild(_linesC);
_nextLabel = new TextField();
_nextLabel.text = "NEXT";
_nextLabel.y = _scoreC.textHeight+_levelC.textHeight+_linesC.textHeight;
addChild(_nextLabel);
}
public function set nextPiece(block:Block):void {
_nextPiece = block;
_nextPiece.draw();
_nextPiece.y = _scoreC.textHeight+_levelC.textHeight+_linesC.textHeight+_nextLabel.textHeight+3;
addChild(_nextPiece);
}
public function get nextPiece():Block {
removeChild(_nextPiece);
return _nextPiece;
}
}
}