-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
49 lines (43 loc) · 1.11 KB
/
Copy pathscript.js
File metadata and controls
49 lines (43 loc) · 1.11 KB
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
47
48
49
var cs = ''; //control string
var map = [
'00000000',
'000000p0',
'00000000',
'00000000',
'00000000',
'00000000',
'0s000000',
'00000000'
];
function showMap() {
var s = '<table>';
for (var i=0; i<8; i++) { // so dong map.length
s += '<tr>';
for (var j=0; j<8; j++) { // length cua '00000000' , 8 , so cot map[i].length
if (map[i][j] === '0') s += '<td>';
if (map[i][j] === 'p') s += '<td class=planet>';
if (map[i][j] === 's') s += '<td class=spaceship>';
s += '</td>';
}
s += '</tr>';
}
s += '</table>';
document.getElementById("map").innerHTML = s;
}
showMap();
function addControl(t) { //text
cs += t;
showControl();
}
function showControl() {
var s = '';
for (var i=0; i<cs.length; i++) { //cs = 'FFCCC';
if (cs[i] === 'F') //cs[0] == 'F'
s += "<div class='small move_forward control_button'></div>";
if (cs[i] === 'C')
s += "<div class='small clockwise control_button'></div>";
if (cs[i] === 'W')
s += "<div class='small counter_clockwise control_button'></div>";
}
document.getElementById("code").innerHTML = s;
}