@@ -44,8 +44,14 @@ var skin;
44
44
BlocklyApps . CHECK_FOR_EMPTY_BLOCKS = false ;
45
45
BlocklyApps . NUM_REQUIRED_BLOCKS_TO_FLAG = 1 ;
46
46
47
- var CANVAS_HEIGHT = 400 ;
48
- var CANVAS_WIDTH = 400 ;
47
+ Voxel . APP_SHORTNAME = 'voxel' ;
48
+ Voxel . DASHBOARD_APP_SHORTNAME = 'Voxel' ;
49
+ Voxel . WIN_SOUND_KEY = 'win' ;
50
+ Voxel . START_SOUND_KEY = 'start' ;
51
+ Voxel . FAILURE_SOUND_KEY = 'failure' ;
52
+ Voxel . WHEN_RUN_BLOCK_KEY = 'when_run' ;
53
+ Voxel . WHEN_RIGHT_CLICK_BLOCK_KEY = 'voxel_whenRightClick' ;
54
+ Voxel . WHEN_LEFT_CLICK_BLOCK_KEY = 'voxel_whenLeftClick' ;
49
55
50
56
/**
51
57
* Initialize Blockly and the Voxel. Called on page load.
@@ -57,7 +63,7 @@ Voxel.init = function(config) {
57
63
level = config . level ;
58
64
59
65
config . grayOutUndeletableBlocks = true ;
60
- config . forceInsertTopBlock = 'when_run' ;
66
+ config . forceInsertTopBlock = Voxel . WHEN_RUN_BLOCK_KEY ;
61
67
config . enableShowCode = false ;
62
68
63
69
config . html = page ( {
@@ -76,9 +82,9 @@ Voxel.init = function(config) {
76
82
} ) ;
77
83
78
84
config . loadAudio = function ( ) {
79
- BlocklyApps . loadAudio ( skin . winSound , 'win' ) ;
80
- BlocklyApps . loadAudio ( skin . startSound , 'start' ) ;
81
- BlocklyApps . loadAudio ( skin . failureSound , 'failure' ) ;
85
+ BlocklyApps . loadAudio ( skin . winSound , Voxel . WIN_SOUND_KEY ) ;
86
+ BlocklyApps . loadAudio ( skin . startSound , Voxel . START_SOUND_KEY ) ;
87
+ BlocklyApps . loadAudio ( skin . failureSound , Voxel . FAILURE_SOUND_KEY ) ;
82
88
} ;
83
89
84
90
config . afterInject = function ( ) {
@@ -106,7 +112,7 @@ Voxel.init = function(config) {
106
112
107
113
window . game . plugins . get ( 'voxel-reach' ) . on ( 'use' , Voxel . generateEventBlockCodeRunner ( 'voxel_whenRightClick' ) ) ;
108
114
//window.game.plugins.get('voxel-reach').on('start mining', function(target) { Voxel.handleWhenLeftClick(target);});
109
- window . game . on ( 'fire' , Voxel . generateEventBlockCodeRunner ( 'voxel_whenRightClick ' ) ) ;
115
+ window . game . on ( 'fire' , Voxel . generateEventBlockCodeRunner ( 'voxel_whenLeftClick ' ) ) ;
110
116
} ;
111
117
112
118
BlocklyApps . init ( config ) ;
@@ -206,17 +212,17 @@ Voxel.endAttempt = function() {
206
212
}
207
213
208
214
if ( Voxel . testResults >= BlocklyApps . TestResults . FREE_PLAY ) {
209
- BlocklyApps . playAudio ( 'win' ) ;
215
+ BlocklyApps . playAudio ( Voxel . WIN_SOUND_KEY ) ;
210
216
} else {
211
- BlocklyApps . playAudio ( 'failure' ) ;
217
+ BlocklyApps . playAudio ( Voxel . FAILURE_SOUND_KEY ) ;
212
218
}
213
219
214
220
var xml = Blockly . Xml . blockSpaceToDom ( Blockly . mainBlockSpace ) ;
215
221
var textBlocks = Blockly . Xml . domToText ( xml ) ;
216
222
217
223
// Report result to server.
218
224
BlocklyApps . report ( {
219
- app : 'voxel' ,
225
+ app : Voxel . APP_SHORTNAME ,
220
226
level : level . id ,
221
227
result : Voxel . result === BlocklyApps . ResultType . SUCCESS ,
222
228
testResult : Voxel . testResults ,
@@ -231,7 +237,7 @@ Voxel.endAttempt = function() {
231
237
*/
232
238
var displayFeedback = function ( response ) {
233
239
BlocklyApps . displayFeedback ( {
234
- app : ' Voxel' ,
240
+ app : Voxel . DASHBOARD_APP_SHORTNAME ,
235
241
skin : skin . id ,
236
242
feedbackType : Voxel . testResults ,
237
243
response : response ,
@@ -246,7 +252,7 @@ var displayFeedback = function(response) {
246
252
247
253
/**
248
254
* Function to be called when the service report call is complete
249
- * @param {object } JSON response (if available)
255
+ * @param {object } response JSON response (if available)
250
256
*/
251
257
Voxel . onReportComplete = function ( response ) {
252
258
Voxel . response = response ;
0 commit comments