@@ -24,29 +24,32 @@ var COLORS = randomColor({
24
24
var PILE = 1 ;
25
25
var HOUSE = 2 ;
26
26
var WALL = 3 ;
27
+ var CYLINDER = 4 ;
27
28
var current_mode = PILE ;
28
29
29
30
var formation_builders = { } ;
30
31
formation_builders [ PILE ] = pile_positions ;
31
32
formation_builders [ HOUSE ] = centered_house_positions ;
32
33
formation_builders [ WALL ] = wall_positions ;
34
+ formation_builders [ CYLINDER ] = cylinder_positions ;
33
35
34
36
function create_card ( container , index ) {
35
37
var card = document . createElement ( 'div' ) ;
36
38
card . className = 'card' ;
37
39
card . style . height = CARD_HEIGHT + 'px' ;
38
40
card . style . width = CARD_WIDTH + 'px' ;
41
+ card . style . background = COLORS [ index % COLORS . length ] ;
39
42
40
- var front = document . createElement ( 'div' ) ;
41
- front . className = 'front' ;
42
- front . style . background = COLORS [ index % COLORS . length ] ;
43
+ // var front = document.createElement('div');
44
+ // front.className = 'front';
45
+ // front.style.background = COLORS[index % COLORS.length];
43
46
44
- var back = document . createElement ( 'div' ) ;
45
- back . className = 'back' ;
46
- back . style . background = COLORS [ index % COLORS . length ] ;
47
+ // var back = document.createElement('div');
48
+ // back.className = 'back';
49
+ // back.style.background = COLORS[index % COLORS.length];
47
50
48
- card . appendChild ( front ) ;
49
- card . appendChild ( back ) ;
51
+ // card.appendChild(front);
52
+ // card.appendChild(back);
50
53
container . appendChild ( card ) ;
51
54
return card ;
52
55
}
@@ -198,6 +201,24 @@ function wall_positions() {
198
201
return positions ;
199
202
}
200
203
204
+ function cylinder_positions ( ) {
205
+ var positions = [ ] ;
206
+ var start_x = WIDTH / 2 ;
207
+ var start_y = 100 ;
208
+ var radius = 100 ;
209
+ for ( var i = 0 ; i < CARD_COUNT ; ++ i ) {
210
+ var angle = ( ( i % 10 ) / 10 ) * 2 * Math . PI ;
211
+ var x = Math . cos ( angle ) * radius + start_x ;
212
+ var z = Math . sin ( angle ) * radius ;
213
+ var y = Math . floor ( i / 10 ) * 1.2 * CARD_HEIGHT + start_y ;
214
+ positions . push ( {
215
+ position : [ x , y , z ] ,
216
+ rotation : [ 0 , Math . PI / 2 + angle , 0 ] ,
217
+ } ) ;
218
+ }
219
+ return positions ;
220
+ }
221
+
201
222
function build_wall ( ) {
202
223
set_mode ( WALL ) ;
203
224
}
@@ -210,6 +231,7 @@ function build_pile() {
210
231
set_mode ( PILE ) ;
211
232
}
212
233
234
+
213
235
function centered_house_positions ( ) {
214
236
// TODO: Actually center
215
237
return house_positions ( 5 , 200 , BOTTOM , - 300 ) ;
@@ -224,13 +246,15 @@ function init() {
224
246
var buttons = {
225
247
"pile_button" : PILE ,
226
248
"house_button" : HOUSE ,
227
- "wall_button" : WALL
249
+ "wall_button" : WALL ,
250
+ "cylinder_button" : CYLINDER
228
251
} ;
229
252
230
253
var click_handler = function ( key ) {
231
254
document . getElementById ( 'pile_button' ) . className = '' ;
232
255
document . getElementById ( 'house_button' ) . className = '' ;
233
256
document . getElementById ( 'wall_button' ) . className = '' ;
257
+ document . getElementById ( 'cylinder_button' ) . className = '' ;
234
258
document . getElementById ( key ) . className = 'button-primary' ;
235
259
set_mode ( buttons [ key ] ) ;
236
260
} ;
0 commit comments