-
Notifications
You must be signed in to change notification settings - Fork 0
/
movefunc.js
94 lines (93 loc) · 1.94 KB
/
movefunc.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*must import posfunc js using this code in <head>:
<script type="text/javascript" src='posfunc.js'></script>
*/
function moveSetX(id, far) {
var xo = leftFunNum(id);
id.style.left = rtnToStd(xo+=far)
}
function moveSetY(id, far) {
var yo = topFunNum(id);
id.style.top = rtnToStd(yo+=far)
}
function moveSetXTime(id, far, time, end) {
var id = id
var far = far
var time = time
var i=0;
var hgh;
var use;
var tgt = (far+leftFunNum(id))
hgh = (far)/time;
use = 20*hgh;
var xo;
function go(){
i++
xo = leftFunNum(id);
id.style.left = rtnToStd(Math.floor(xo+use))
if(Math.ceil(i*20)>=Math.ceil(time)){
window.clearInterval(ok)
end()
};
if(leftFunNum(id) == tgt){
window.clearInterval(ok)
end()
}
}
var ok = window.setInterval(go, 20)
}
function moveSetYTime(id, far, time, end) {
var id = id
var far = far
var time = time
var i=0
var hgh;
var use;
hgh = (far)/time;
use = 20*hgh;
var xo;
function go(){
i++
yo = topFunNum(id);
id.style.top = rtnToStd(yo+use)
if(i==(time/20)){
window.clearInterval(ok)
end()
}
}
var ok = window.setInterval(go, 20)
}//must have code (var jj;) in main
function moveDiag(thing, angle1, speed, time, end){
var thing = thing;
var angle1 = angle1;
var speed = speed;
var end = end;
var time =parseFloat(time);
var i=0;
function go(){
moveSetX(thing, (speed * Math.cos(angle1 * Math.PI / 180)));
moveSetY(thing, (speed * Math.sin(angle1 * Math.PI / 180)));
//end()
i++
if(i>(time/20)){
window.clearInterval(jj)
}
}jj = setInterval(go, 20)
}
function turn(id, degrees, time){
var id = id;
var far = degrees;
var time = time
var i=0
var hgh;
var use;
hgh = (far)/time;
use = 20*hgh;
var xo;
function go(){
i++
if(i==(time/20)){
window.clearInterval(ok)
}
}
var ok = window.setInterval(go, 20)
}//must have code (var jj;) in main