-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gen2.Wuss.js
109 lines (90 loc) · 2.53 KB
/
Gen2.Wuss.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Just tries to stay alive
// Runs from any snake _point_ closer than 500 units
// TODO: Balls up when threatened
var my_xm = 0;
var my_ym = 0;
var scores = {};
setInterval(function() {
var closest_snake = null;
var closest_distance = 5000;
for (var ii = 0;ii<snakes.length;ii++) {
var targetSnake = snakes[ii];
if (targetSnake.id != snake.id) {
for (var aaa = 0;aaa<targetSnake.pts.length;aaa++) {
var targetPoint = targetSnake.pts[aaa];
var distance_x = Math.round(targetPoint.xx - snake.xx);
var distance_y = Math.round(targetPoint.yy - snake.yy);
var distance = Math.abs(distance_x)+Math.abs(distance_y);
if (distance < closest_distance) {
closest_distance = distance;
closest_snake = targetSnake;
}
}
}
}
if (closest_distance < 500) {
set_direction(Math.round(closest_snake.xx - snake.xx)*-1,Math.round(closest_snake.yy - snake.yy)*-1);
}
update_high_scores();
},200);
setInterval(function () {
// Respawn on death
want_play || play_btn.disabled || (want_play = !0, play_btn_click_mtm = Date.now(), play_btn.setEnabled(!1), spinner_shown = nick.disabled = !0, ldmc.style.display = "inline", play_count++, 3 <= play_count && !is_mobile && adsController && (shoa = !0, adsController.initialize(), adsController.requestAds("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/136317422/slither-io-game-over&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=http%3A%2F%2Fslither.io&correlator=[timestamp]")))
},5000);
var rollyPollyMode = false;
var rollyPollySpeed = 3000;
function se() {
set_direction(100,100);
}
function sw() {
set_direction(-100,100);
}
function nw() {
set_direction(-100,-100);
}
function ne() {
set_direction(100,-100);
}
se();
setInterval(function(){
if (rollyPollyMode) {
se();
}
},rollyPollySpeed);
setTimeout(function () {
sw();
setInterval(function(){
if (rollyPollyMode) {
sw();
}
},rollyPollySpeed);
},rollyPollySpeed*.25);
setTimeout(function () {
nw();
setInterval(function(){
if (rollyPollyMode) {
nw();
}
},rollyPollySpeed);
},rollyPollySpeed*.5);
setTimeout(function () {
ne();
setInterval(function(){
if (rollyPollyMode) {
ne();
}
},rollyPollySpeed);
},rollyPollySpeed*.75);
function update_high_scores() {
if (!snake) {
return false;
}
var score = Math.floor(15 * (fpsls[snake.sct] + snake.fam / fmlts[snake.sct] - 1) - 5) / 1;
if (!scores[snake.id] || score > scores[snake.id]) {
scores[snake.id] = score;
}
}
function set_direction(my_xm,my_ym) {
xm = my_xm;
ym = my_ym;
}