1
1
/**
2
- * Tetris .js is based on http://mrcoles.com/tetris/
3
- * I haven't seen it on github, but it's one of the better js tetris clones out there
2
+ * BlockRain .js is based on http://mrcoles.com/tetris/
3
+ * I haven't seen it on github, but it's one of the better js Tetris clones out there
4
4
*/
5
5
6
6
$ . fn . safekeypress = function ( func , cfg ) {
@@ -40,9 +40,9 @@ $.fn.safekeypress = function(func, cfg) {
40
40
} ;
41
41
42
42
43
- $ . fn . tetris = function ( customOptions ) {
43
+ $ . fn . blockrain = function ( customOptions ) {
44
44
45
- $ . fn . tetris [ 'themes' ] = {
45
+ $ . fn . blockrain [ 'themes' ] = {
46
46
'modern' : {
47
47
primary : null ,
48
48
secondary : null ,
@@ -79,6 +79,11 @@ $.fn.tetris = function( customOptions ) {
79
79
'aerolab' : {
80
80
primary : '#ff7b00' ,
81
81
secondary : '#000000'
82
+ } ,
83
+ 'chocolate' : {
84
+ primary : '#7B3F00' ,
85
+ secondary : '#7B3F00' ,
86
+ stroke : '#291811'
82
87
}
83
88
} ;
84
89
@@ -87,7 +92,7 @@ $.fn.tetris = function( customOptions ) {
87
92
var options = {
88
93
autoplay : false ,
89
94
showFieldOnStart : true ,
90
- theme : $ . fn . tetris . themes [ 'retro' ] ,
95
+ theme : $ . fn . blockrain . themes [ 'retro' ] ,
91
96
blockWidth : 10 ,
92
97
autoBlockWidth : false ,
93
98
autoBlockSize : 24 ,
@@ -103,11 +108,11 @@ $.fn.tetris = function( customOptions ) {
103
108
options = $ . extend ( options , customOptions ) ;
104
109
105
110
if ( typeof options . theme === 'string' ) {
106
- options . theme = $ . fn . tetris . themes [ options . theme ] ;
111
+ options . theme = $ . fn . blockrain . themes [ options . theme ] ;
107
112
}
108
113
109
114
var $game = $ ( this ) ;
110
- var $gameholder = $ ( '<div class="tetris -game-holder"></div>' ) ;
115
+ var $gameholder = $ ( '<div class="blockrain -game-holder"></div>' ) ;
111
116
$game . html ( '' ) . append ( $gameholder ) ;
112
117
113
118
$gameholder . css ( 'position' , 'relative' ) . css ( 'width' , '100%' ) . css ( 'height' , '100%' ) ;
@@ -123,25 +128,25 @@ $.fn.tetris = function( customOptions ) {
123
128
124
129
// Score
125
130
var $score = $ (
126
- '<div class="tetris -score-holder" style="position:absolute; top:0; right:0; ">' +
127
- '<div class="tetris -score">' +
128
- '<div class="tetris -score-msg">Score</div>' +
129
- '<div class="tetris -score-num">0</div>' +
131
+ '<div class="blockrain -score-holder" style="position:absolute; top:0; right:0; ">' +
132
+ '<div class="blockrain -score">' +
133
+ '<div class="blockrain -score-msg">Score</div>' +
134
+ '<div class="blockrain -score-num">0</div>' +
130
135
'</div>' +
131
136
'</div>' ) ;
132
- var $scoreText = $score . find ( '.tetris -score-num' ) ;
137
+ var $scoreText = $score . find ( '.blockrain -score-num' ) ;
133
138
$gameholder . append ( $score ) ;
134
139
135
140
// Create the start menu
136
141
var $start = $ (
137
- '<div class="tetris -start-holder" style="position:absolute; top:0; left:0; right:0; bottom:0;">' +
138
- '<div class="tetris -start">' +
139
- '<button class="tetris -start-btn btn ">Play Tetris </button>' +
142
+ '<div class="blockrain -start-holder" style="position:absolute; top:0; left:0; right:0; bottom:0;">' +
143
+ '<div class="blockrain -start">' +
144
+ '<button class="blockrain -start-btn">Play blockrain </button>' +
140
145
'</div>' +
141
146
'</div>' ) ;
142
147
$gameholder . append ( $start ) ;
143
148
144
- $start . find ( '.tetris -start-btn' ) . click ( function ( event ) {
149
+ $start . find ( '.blockrain -start-btn' ) . click ( function ( event ) {
145
150
event . preventDefault ( ) ;
146
151
$start . fadeOut ( 200 ) ;
147
152
$gameover . fadeOut ( 200 ) ;
@@ -151,13 +156,13 @@ $.fn.tetris = function( customOptions ) {
151
156
152
157
// Create the game over menu
153
158
var $gameover = $ (
154
- '<div class="tetris -game-over-holder" style="position:absolute; top:0; left:0; right:0; bottom:0; display:none;">' +
155
- '<div class="tetris -game-over">' +
156
- '<div class="tetris -game-over-msg">Game Over</div>' +
157
- '<button class="tetris -game-over-btn btn">Play Again</button>' +
159
+ '<div class="blockrain -game-over-holder" style="position:absolute; top:0; left:0; right:0; bottom:0; display:none;">' +
160
+ '<div class="blockrain -game-over">' +
161
+ '<div class="blockrain -game-over-msg">Game Over</div>' +
162
+ '<button class="blockrain -game-over-btn">Play Again</button>' +
158
163
'</div>' +
159
164
'</div>' ) ;
160
- $gameover . find ( '.tetris -game-over-btn' ) . click ( function ( event ) {
165
+ $gameover . find ( '.blockrain -game-over-btn' ) . click ( function ( event ) {
161
166
event . preventDefault ( ) ;
162
167
$start . fadeOut ( 200 ) ;
163
168
$gameover . fadeOut ( 200 ) ;
@@ -671,7 +676,7 @@ $.fn.tetris = function( customOptions ) {
671
676
672
677
var start = [ ] , colors = [ ] , i , ilen , j , jlen , color ;
673
678
674
- // Draw a random tetris screen
679
+ // Draw a random blockrain screen
675
680
for ( var i in shapeFactory ) {
676
681
colors . push ( getBlockColor ( i , false ) ) ;
677
682
}
@@ -766,7 +771,7 @@ $.fn.tetris = function( customOptions ) {
766
771
}
767
772
}
768
773
769
- // Draw the tetris field
774
+ // Draw the blockrain field
770
775
ctx . clearRect ( 0 , 0 , PIXEL_WIDTH , PIXEL_HEIGHT ) ;
771
776
filled . draw ( ) ;
772
777
this . cur . draw ( drop ) ;
0 commit comments