統計
| ブランチ: | リビジョン:

pictcode / app / webroot / js / pictcode / block_data.js @ 0b1b8047

履歴 | 表示 | アノテート | ダウンロード (14.211 KB)

1
define(function(){
2

    
3
  var categories =[
4
  {
5
    name:"function",
6
    iconImageKey:"ctgry_blk_002",
7
  },
8
  {
9
    name:"movement",
10
    iconImageKey:"ctgry_blk_001",
11
  },
12
  {
13
    name:"branch",
14
    iconImageKey:"ctgry_blk_004",
15
  },
16
  {
17
    name:"data",
18
    iconImageKey:"ctgry_blk_005",
19
  },
20
  {
21
    name:"time_control",
22
    iconImageKey:"ctgry_blk_008",
23
  },
24
  {
25
    name:"app_control",
26
    iconImageKey:"ctgry_blk_006",
27
  },
28
  {
29
    name:"sound",
30
    iconImageKey:"ctgry_blk_007",
31
  },
32
  {
33
    name:"sprite_control",
34
    iconImageKey:"ctgry_blk_003",
35
  },
36
  ];
37

    
38
  var VALUETYPE = {
39
    SCALAR: 0,
40
    VECTOR: 1,
41
    CHECK: 2,
42
    FUNC_SELECTOR: 3,
43
    FUNCTION: 4,
44
    SOUND_SELECTOR: 5,
45
    VARIABLE: 6,
46
    TAG_SELECTOR: 7,
47
  }
48

    
49
  //各ブロックのベース
50
  var baseBlock = {
51
    position: {x:0.0, y:0.0},
52
    size: {width:4.26, height:1.0},
53

    
54
    topLink: {id:null, position:{x:1.314, y:0.0}},
55
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}],
56

    
57
    value1: {
58
      available: true,
59
      iconImageKey: "icon_blk_001",
60
      iconSize: 0.35,
61
      iconAngle: 0,
62
      iconPosition: {x:2.029, y:0.5},
63
      valueType: VALUETYPE.SCALAR,
64
      value: 0,
65
      valueSize: 0.629,
66
      valuePosition: {x:2.514, y:0.386},
67
      canInput: true,
68
      isVariable: false,
69
      canBeVariable: false,
70
    },
71

    
72
    value2: {
73
      available: true,
74
      iconImageKey: "icon_blk_001",
75
      iconSize: 0.35,
76
      iconAngle: 0,
77
      iconPosition: {x:3.257, y:0.5},
78
      valueType: VALUETYPE.SCALAR,
79
      value: 0,
80
      valueSize: 0.629,
81
      valuePosition: {x:3.743, y:0.386},
82
      canInput: true,
83
      isVariable:false,
84
      canBeVariable:false,
85
    },
86
  }
87

    
88
  //各ブロックの初期データ
89
  var blocks = [
90
  //関数
91
  {
92
    size: {width:3.057, height:1.0},
93
    topLink: null,
94
    category: "function",
95
    name: "start_function",
96
    imageKey: "blk_function_001",
97
    value1:{
98
      valueType: VALUETYPE.FUNCTION,
99
    },
100
    value2:{
101
      available: false,
102
    }
103
  },
104

    
105
  {
106
    size: {width:3.057, height:0.771},
107
    bottomLinks: null,
108
    category: "function",
109
    name: "return_function",
110
    imageKey: "blk_function_002",
111
    value1:{
112
      iconImageKey: "icon_blk_003",
113
      valueType: VALUETYPE.FUNC_SELECTOR,
114
      value: 0,
115
    },
116
    value2:{
117
      available: false,
118
    }
119
  },
120

    
121
  {
122
    size: {width:8.814, height:1.0},
123
    bottomLinks: null,
124
    category: "function",
125
    name: "fork",
126
    imageKey: "blk_function_003",
127
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
128
    value1:{
129
      available: false,
130
    },
131
    value2:{
132
      available: false,
133
    }
134
  },
135

    
136
  //動きの制御
137
  {
138
    category: "movement",
139
    name: "move",
140
    imageKey: "blk_motion_001",
141
    value1:{
142
      iconImageKey: "icon_blk_002",
143
      value: 1.2, //秒
144
      canBeVariable: true,
145
    },
146
    value2:{
147
      iconImageKey: "icon_blk_001",
148
      valueType: VALUETYPE.VECTOR,
149
      value: {x: 0, y: 210},
150
    },
151
  },
152

    
153
  {
154
    category: "movement",
155
    name: "rotate_right",
156
    imageKey: "blk_motion_002",
157
    value1:{
158
      iconImageKey: "icon_blk_002",
159
      value:1.2, //秒
160
      canBeVariable: true,
161
    },
162
    value2:{
163
      iconImageKey: "icon_blk_008",
164
      value:90,
165
      canBeVariable:true,
166
    },
167
  },
168

    
169
  {
170
    category: "movement",
171
    name: "rotate_left",
172
    imageKey: "blk_motion_003",
173
    value1:{
174
      iconImageKey: "icon_blk_002",
175
      value:1.2, //秒
176
      canBeVariable: true,
177
    },
178
    value2:{
179
      iconImageKey: "icon_blk_009",
180
      value:90,
181
      canBeVariable:true,
182
    },
183
  },
184

    
185
  {
186
    category: "movement",
187
    name: "zoom",
188
    imageKey: "blk_motion_005",
189
    value1:{
190
      iconImageKey: "icon_blk_002",
191
      value:1.2, //秒
192
      canBeVariable: true,
193
    },
194
    value2:{
195
      iconImageKey: "icon_blk_010",
196
      value:2.0,
197
      canBeVariable:true,
198
    },
199
  },
200

    
201
  {
202
    category: "movement",
203
    name: "opacity",
204
    imageKey: "blk_motion_004",
205
    value1:{
206
      iconImageKey: "icon_blk_002",
207
      value:1.2, //秒
208
      canBeVariable: true,
209
    },
210
    value2:{
211
      iconImageKey: "icon_blk_011",
212
      value:0.5,
213
      canBeVariable:true,
214
    },
215
  },
216

    
217
  {
218
    category: "movement",
219
    name: "self_duplicate",
220
    imageKey: "blk_motion_006",
221
    size: {width:3.057, height:1.0},
222
    value1:{
223
      iconImageKey: "icon_blk_020",
224
      valueType: VALUETYPE.FUNC_SELECTOR,
225
    },
226
    value2:{
227
      available:false,
228
    },
229
  },
230

    
231
  {
232
    category: "movement",
233
    name: "self_kill",
234
    imageKey: "blk_motion_007",
235
    size: {width:3.057, height:0.771},
236
    bottomLinks: null,
237
    value1:{
238
      available:false,
239
    },
240
    value2:{
241
      available:false,
242
    },
243
  },
244

    
245
  {
246
    category: "movement",
247
    name: "mirror",
248
    imageKey: "blk_motion_008",
249
    size: {width:3.057, height:1.0},
250
    value1:{
251
      available:false,
252
    },
253
    value2:{
254
      available:false,
255
    },
256
  },
257

    
258
  //分岐
259
  {
260
    category: "branch",
261
    name: "branch_equal",
262
    imageKey: "blk_branch_001",
263
    size: {width:8.814, height:1.0},
264
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
265

    
266
    value1:{
267
      iconImageKey: "icon_blk_014",
268
      valueType: VALUETYPE.SCALAR,
269
      value:0,
270
      valuePosition: {x:3.19, y:0.386},
271
      canBeVariable: true,
272
    },
273
    value2:{
274
      iconImageKey: "icon_blk_015",
275
      valueType: VALUETYPE.SCALAR,
276
      value:0,
277
      valuePosition: {x:5.62, y:0.386},
278
      canBeVariable: true,
279
    }
280
  },
281

    
282
  {
283
    category: "branch",
284
    name: "branch_larger",
285
    imageKey: "blk_branch_005",
286
    size: {width:8.814, height:1.0},
287
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
288

    
289
    value1:{
290
      iconImageKey: "icon_blk_014",
291
      valueType: VALUETYPE.SCALAR,
292
      value:0,
293
      valuePosition: {x:3.19, y:0.386},
294
      canBeVariable: true,
295
    },
296
    value2:{
297
      iconImageKey: "icon_blk_015",
298
      valueType: VALUETYPE.SCALAR,
299
      value:0,
300
      valuePosition: {x:5.62, y:0.386},
301
      canBeVariable: true,
302
    }
303
  },
304

    
305
  {
306
    category: "branch",
307
    name: "branch_smaller",
308
    imageKey: "blk_branch_003",
309
    size: {width:8.814, height:1.0},
310
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
311

    
312
    value1:{
313
      iconImageKey: "icon_blk_014",
314
      valueType: VALUETYPE.SCALAR,
315
      value:0,
316
      valuePosition: {x:3.19, y:0.386},
317
      canBeVariable: true,
318
    },
319
    value2:{
320
      iconImageKey: "icon_blk_015",
321
      valueType: VALUETYPE.SCALAR,
322
      value:0,
323
      valuePosition: {x:5.62, y:0.386},
324
      canBeVariable: true,
325
    }
326
  },
327

    
328
  {
329
    category: "branch",
330
    name: "branch_eqlarger",
331
    imageKey: "blk_branch_004",
332
    size: {width:8.814, height:1.0},
333
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
334

    
335
    value1:{
336
      iconImageKey: "icon_blk_014",
337
      valueType: VALUETYPE.SCALAR,
338
      value:0,
339
      valuePosition: {x:3.19, y:0.386},
340
      canBeVariable: true,
341
    },
342
    value2:{
343
      iconImageKey: "icon_blk_015",
344
      valueType: VALUETYPE.SCALAR,
345
      value:0,
346
      valuePosition: {x:5.62, y:0.386},
347
      canBeVariable: true,
348
    }
349
  },
350

    
351
  {
352
    category: "branch",
353
    name: "branch_eqsmaller",
354
    imageKey: "blk_branch_002",
355
    size: {width:8.814, height:1.0},
356
    bottomLinks: [{id:null, position:{x:1.314, y:0.757}}, {id:null, position:{x:7.114, y:0.757}}],
357

    
358
    value1:{
359
      iconImageKey: "icon_blk_014",
360
      valueType: VALUETYPE.SCALAR,
361
      value:0,
362
      valuePosition: {x:3.19, y:0.386},
363
      canBeVariable: true,
364
    },
365
    value2:{
366
      iconImageKey: "icon_blk_015",
367
      valueType: VALUETYPE.SCALAR,
368
      value:0,
369
      valuePosition: {x:5.62, y:0.386},
370
      canBeVariable: true,
371
    }
372
  },
373

    
374
  //データ
375
  {
376
    category: "data",
377
    name: "var_scalar",
378
    imageKey: "blk_data_001",
379
    size: {width:4.26, height:0.771},
380
    topLink: null,
381
    bottomLinks: null,
382

    
383
    value1:{
384
      iconImageKey: "icon_blk_018",
385
      valueType: VALUETYPE.VARIABLE,
386
      value:0,
387
    },
388
    value2:{
389
      iconImageKey: "icon_blk_019",
390
      valueType: VALUETYPE.SCALAR,
391
      value:0,
392
    }
393
  },
394

    
395
  {
396
    category: "data",
397
    name: "add_random",
398
    imageKey: "blk_data_002",
399
    value1:{
400
      iconImageKey: "icon_blk_018",
401
      valueType: VALUETYPE.SCALAR,
402
      value:0,
403
      canInput: false,
404
      canBeVariable: true,
405
      isVariable: true,
406
    },
407
    value2:{
408
      iconImageKey: "icon_blk_019",
409
      value:0.5,
410
      canBeVariable:true,
411
    },
412
  },
413

    
414
  {
415
    category: "data",
416
    name: "var_add",
417
    imageKey: "blk_data_003",
418
    value1:{
419
      iconImageKey: "icon_blk_018",
420
      valueType: VALUETYPE.SCALAR,
421
      value:0,
422
      canInput: false,
423
      canBeVariable: true,
424
      isVariable: true,
425
    },
426
    value2:{
427
      iconImageKey: "icon_blk_019",
428
      value:0.5,
429
      canBeVariable:true,
430
    },
431
  },
432

    
433
  {
434
    category: "data",
435
    name: "var_substract",
436
    imageKey: "blk_data_004",
437
    value1:{
438
      iconImageKey: "icon_blk_018",
439
      valueType: VALUETYPE.SCALAR,
440
      value:0,
441
      canInput: false,
442
      canBeVariable: true,
443
      isVariable: true,
444
    },
445
    value2:{
446
      iconImageKey: "icon_blk_019",
447
      value:0.5,
448
      canBeVariable:true,
449
    },
450
  },
451

    
452
  {
453
    category: "data",
454
    name: "var_multiplicate",
455
    imageKey: "blk_data_005",
456
    value1:{
457
      iconImageKey: "icon_blk_018",
458
      valueType: VALUETYPE.SCALAR,
459
      value:0,
460
      canInput: false,
461
      canBeVariable: true,
462
      isVariable: true,
463
    },
464
    value2:{
465
      iconImageKey: "icon_blk_019",
466
      value:0.5,
467
      canBeVariable:true,
468
    },
469
  },
470

    
471
  {
472
    category: "data",
473
    name: "var_divide",
474
    imageKey: "blk_data_006",
475
    value1:{
476
      iconImageKey: "icon_blk_018",
477
      valueType: VALUETYPE.SCALAR,
478
      value:0,
479
      canInput: false,
480
      canBeVariable: true,
481
      isVariable: true,
482
    },
483
    value2:{
484
      iconImageKey: "icon_blk_019",
485
      value:0.5,
486
      canBeVariable:true,
487
    },
488
  },
489

    
490
  {
491
    category: "data",
492
    name: "var_rest",
493
    imageKey: "blk_data_007",
494
    value1:{
495
      iconImageKey: "icon_blk_018",
496
      valueType: VALUETYPE.SCALAR,
497
      value:0,
498
      canInput: false,
499
      canBeVariable: true,
500
      isVariable: true,
501
    },
502
    value2:{
503
      iconImageKey: "icon_blk_019",
504
      value:0.5,
505
      canBeVariable:true,
506
    },
507
  },
508

    
509
  {
510
    category: "data",
511
    name: "var_substitute",
512
    imageKey: "blk_data_008",
513
    value1:{
514
      iconImageKey: "icon_blk_018",
515
      valueType: VALUETYPE.SCALAR,
516
      value:0,
517
      canInput: false,
518
      canBeVariable: true,
519
      isVariable: true,
520
    },
521
    value2:{
522
      iconImageKey: "icon_blk_019",
523
      value:0.5,
524
      canBeVariable:true,
525
    },
526
  },
527

    
528
  //時間の制御
529
  {
530
    category: "time_control",
531
    name: "set_timer",
532
    imageKey: "blk_timectrl_002",
533
    value1:{
534
      iconImageKey: "icon_blk_024",
535
      valueType: VALUETYPE.SCALAR,
536
      value: 0.5,
537
      canBeVariable: true,
538
    },
539
    value2:{
540
      iconImageKey: "icon_blk_013",
541
      valueType: VALUETYPE.FUNC_SELECTOR,
542
      value: 0,
543
    }
544
  },
545

    
546
  {
547
    size: {width:3.057, height:1.0},
548
    category: "time_control",
549
    name: "wait",
550
    imageKey: "blk_timectrl_001",
551
    value1:{
552
      iconImageKey: "icon_blk_024",
553
      valueType: VALUETYPE.SCALAR,
554
      value: 0.5,
555
      canBeVariable: true,
556
    },
557
    value2:{
558
      available: false,
559
    }
560
  },
561

    
562
  //サウンド
563
  {
564
    category: "sound",
565
    name: "play_sound",
566
    imageKey: "blk_sound_002",
567
    size: {width:6.43, height:1.0},
568

    
569
    value1:{
570
      iconImageKey: "icon_blk_004",
571
      valueType: VALUETYPE.CHECK,
572
      value: false,
573
    },
574
    value2:{
575
      iconImageKey: "icon_blk_005",
576
      valueType: VALUETYPE.SOUND_SELECTOR,
577
      value: 0,
578
      valuePosition: {x:4.829, y:0.386},
579
    },
580
  },
581

    
582
  //アプリの制御
583
  {
584
    category: "app_control",
585
    name: "start_app",
586
    imageKey: "blk_gmctrl_001",
587
    size: {width:3.057, height:1.0},
588
    topLink: null,
589
    value1:{
590
      available: false,
591
    },
592
    value2:{
593
      available: false,
594
    }
595
  },
596

    
597
  {
598
    category: "app_control",
599
    name: "finish_app",
600
    imageKey: "blk_gmctrl_002",
601
    size: {width:3.057, height:0.771},
602
    bottomLinks: null,
603
    value1:{
604
      available: false,
605
    },
606
    value2:{
607
      available: false,
608
    }
609
  },
610

    
611
  {
612
    category: "app_control",
613
    name: "tap_enable",
614
    imageKey: "blk_gmctrl_003",
615
    size: {width:3.057, height:1.0},
616

    
617
    value1:{
618
      iconImageKey: "icon_blk_006",
619
      valueType: VALUETYPE.CHECK,
620
      value: true,
621
    },
622
    value2:{
623
      available: false,
624
    },
625
  },
626

    
627
  {
628
    category: "app_control",
629
    name: "swipe_enable",
630
    imageKey: "blk_gmctrl_004",
631
    size: {width:3.057, height:1.0},
632

    
633
    value1:{
634
      iconImageKey: "icon_blk_006",
635
      valueType: VALUETYPE.CHECK,
636
      value: true,
637
    },
638
    value2:{
639
      available: false,
640
    },
641
  },
642
  
643
  //スプライトの制御
644
  {
645
    category: "sprite_control",
646
    name: "func_on_tag",
647
    imageKey: "blk_sprctrl_001",
648
    value1:{
649
      iconImageKey: "icon_blk_023",
650
      valueType: VALUETYPE.TAG_SELECTOR,
651
      value: 0,
652
    },
653
    value2:{
654
      iconImageKey: "icon_blk_013",
655
      valueType: VALUETYPE.FUNC_SELECTOR,
656
      value: 0,
657
    }
658
  },
659

    
660
  {
661
    category: "sprite_control",
662
    name: "duplicate",
663
    imageKey: "blk_sprctrl_002",
664
    value1:{
665
      iconImageKey: "icon_blk_023",
666
      valueType: VALUETYPE.TAG_SELECTOR,
667
      value: 0,
668
    },
669
    value2:{
670
      iconImageKey: "icon_blk_013",
671
      valueType: VALUETYPE.FUNC_SELECTOR,
672
      value: 0,
673
    }
674
  },
675

    
676
  {
677
    category: "sprite_control",
678
    name: "display",
679
    imageKey: "blk_sprctrl_003",
680
    value1:{
681
      iconImageKey: "icon_blk_023",
682
      valueType: VALUETYPE.TAG_SELECTOR,
683
      value: 0,
684
    },
685
    value2:{
686
      iconImageKey: "icon_blk_025",
687
      valueType: VALUETYPE.SCALAR,
688
      value: 0,
689
      canBeVariable: true,
690
    }
691
  },
692
  ];
693

    
694
  //ベースブロックを継承
695
  _.each( blocks, function(block, i){
696
    var extended = $.extend(true, {}, baseBlock, block);
697
    blocks[i] = extended;
698
  });
699

    
700
  function getBlock(name){
701
    var targetBlock = _.find(blocks, function(block){
702
      return block.name === name;
703
    });
704
    return targetBlock;
705
  }
706

    
707
  function getCategorizedBlocks(ctgry){
708
    var categorizedBlocks = _.filter(blocks, function(block){
709
      return block.category === ctgry;
710
    });
711
    return categorizedBlocks;
712
  }
713

    
714
  return {
715
    categories:categories,
716
    VALUETYPE:VALUETYPE,
717
    getBlock:getBlock,
718
    getCategorizedBlocks:getCategorizedBlocks,
719
  };
720
});