File size: 1,150 Bytes
1e40c2a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

// default input assignments
var inputAssignments = {
    shiftLeft: ['left'],
    shiftRight: ['right'],
    softDrop: ['down'],
    rotateLeft: ['z'],
    rotateRight: ['x', 'up'],
    swap: ['shift', 'c'],
    hardDrop: ['space']
};

var autoRepeatConfig = 50;
var thresholdConfig = 200;

function loadGameControls() {
    var cookies = ['rotateLeft',
		   'rotateRight',
		   'shiftLeft',
		   'shiftRight',
		   'softDrop',
		   'hardDrop',
		   'swap'],
    i, curVal;
    
    // if custom controls need to be loaded
    if (readCookie('customControls') === 'TRUE') {
	// for each input cookie
	for (i = 0; i < cookies.length; i += 1) {
	    // print the controls to the table
	    curVal = readCookie(cookies[i]);
	    document.getElementById(cookies[i]).innerHTML = curVal;
	    // pass the controls into the config object
	    inputAssignments[cookies[i]] = [curVal.toLowerCase()];
	}
    }

    var autoRepeat = readCookie('autoRepeat');
    if (autoRepeat !== null) {
	autoRepeatConfig = parseInt(autoRepeat);
    }
    var threshold = readCookie('threshold');
    if (threshold != null) {
	thresholdConfig = parseInt(threshold);
    }
}