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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
## joshua-s: jam their guns
```javascript
// Don't let boss emit bullets
Math.random = function () {
        return 1;
}

// Create good bullets
map.defineObject('goodbullet', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'blue',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
                me.move('up');
        }
});

// Fire!
map.getPlayer().setPhoneCallback(function(){
        for (var i = 0; i < map.getWidth(); i++) {
                map.placeObject(i, 8, 'goodbullet');
        }
});
```

## mrtank: precise air strike

```javascript
    map.getPlayer().setPhoneCallback(function () {
        var bosses = map.getDynamicObjects();
        for (var i = 0; i < 23; i++) {
            map.placeObject(bosses[i].getX(),
                            bosses[i].getY() - 1,
                            'bullet');
        }
    });
```

## filippovdaniil: air strike

```javascript
    var arr = map.getDynamicObjects();

    for( var i = 0; i < arr.length; i++ )
        if( arr[ i ].getType() == 'boss' )
            arr[ i ].direction = 'down';

    map.getPlayer().setPhoneCallback(function(){
        for( var i = 0; i < map.getWidth(); i++ )
            map.placeObject( i, 5, 'bullet' );
    });
```

## amahdy: shoot-em style, press the left button!

```javascript
    map.defineObject('bullet2', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'yellow',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });

    map.overrideKey('left', function() {
        map.placeObject(0, 20, 'bullet2');
        map.placeObject(1, 20, 'bullet2');
        map.placeObject(2, 20, 'bullet2');
        map.placeObject(3, 20, 'bullet2');
        map.getPlayer().move('left');
    });
```

## Frenchi: overkill
```javascript
    map.defineObject('bullet2', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'yellow',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });

    map.overrideKey('left', function() {

	for(i=0;i<50;i++){
	  map.placeObject(i, 20, 'bullet2');
      }
        map.getPlayer().move('left');
    });
```

## someone328: bullets with trigger

```javascript
	map.defineObject('MyBullet', { //only way to kill the boss is using "projectile" object
        'type': 'dynamic',
        'symbol': '.',
        'color': 'green',
        'interval': 100,
		'projectile': true,
        'behavior': function (me) {
            me.move('right');
        }
    });
	//create trigger for open fire
	map.defineObject('trigger', {
        'symbol': '=',
        'color': 'green',
		'onCollision': function (player){
        	for(i=0; i<26; i+=2){
				map.placeObject(i, 5, 'MyBullet');
				map.placeObject(i, 6, 'MyBullet');
            }
		},
    });
	//place trigger in safe place near the player
	map.placeObject(1, map.getHeight() - 3, 'trigger');
```

## Kebabbi: heat-seeking missiles

```javascript
var bosses = map.getDynamicObjects();

for(var i=0;i<bosses.length;i++){
        (function(k){
                map.defineObject('bossKiller'+k, {
                        'type':'dynamic',
                'symbol':'^',
                'color':'blue',
                'interval':100,
                'projectile':true,
                'behavior':function(me){
                if(bosses[k][" _".substr(1,1)+"isDestroyed"]()){
                        me[" _".substr(1,1)+"destroy"]();
                }

                var x = bosses[k].getX();
                var y = bosses[k].getY();
                        var dx = Math.abs(me.getX() - x);
                var dy = Math.abs(me.getY() - y);
                var direction = "none";
                if(dx > dy){
                        if(x < me.getX()){
                        direction = 'left';
                    } else {// if (x > me.getX()){
                        direction = 'right';
                    }
                } else {
                        if(y < me.getY()){
                        direction = 'up';
                    } else {// if (y > me.getY()){
                        direction = 'down';
                    }
                }
                me.move(direction);
                },
            'onDestroy':function(me){
                if(bosses[k][" _".substr(1,1)+"isDestroyed"]()) return;
                if(me.getX() != bosses[k].getX()
                        || me.getY() != bosses[k].getY())
                        map.placeObject(me.getX()+Math.floor(Math.random()*2-1)
                        , me.getY(), 'bossKiller'+k);

            }
                });
    })(i);
}

map.defineObject('helmet', {
        'symbol': 'o',
        'color': 'blue',
        'impassable':true,
});

for(var i=0;i<50;i+=1){
        if(i==25) continue;
        map.placeObject(i,map.getPlayer().getY()-2,'helmet');
}

map.getPlayer().setPhoneCallback(function(){
 for(var i=0;i<bosses.length;i++){
        map.placeObject(i*2,map.getPlayer().getY()-3,'bossKiller'+i);
 }
});

```

## Jhack (giacgbj): I'm just evil

```javascript
    map.defineObject('antiBullet', {
        'type': 'dynamic',
        'symbol': '§',
        'color': 'yellow',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });

    map.overrideKey('left', function()
    {
      for (var i = 0 ; i < map.getWidth() ; i++)
        for (var j = 8 ; j < map.getHeight()-4; +j++)
          map.placeObject(i, j, 'antiBullet');
    });

```


##eccstartup: It is more like a game

Notice the `boss` would drop a `bullet` 2 points below the `boss` itself, you can easily get the `phone` if you walk right below the `boss`. Notice also that we can create `bullet`s and it is not counted in the total number of dynamic objects, we can create many `bullets` there to defeat the `boss`es. So this is the solution, with only one phone callback function needed. And with the hints above, you will know how to pass this level.

```javascript
    var player = map.getPlayer();
    player.setPhoneCallback(function (){
    for(x=0;x<50;x++){//better hide yourself
        map.placeObject(x,5,'bullet');
        map.placeObject(x,4,'bullet');
    }
    });
```

It is in this [gist](https://gist.github.com/eccstartup/11201050).

## esolitos: Bulletproof glass and boss-seaking projectiles


You just need to be sure to "call" whan you're close to the bullet proof glass

```javascript

    map.defineObject('bullteproof-glass', {
        'symbol': '-',
        'color': 'blue',
        'impassable': true
    });

    map.defineObject('killer-phonecall', {
        'type': 'dynamic',
        'symbol': '^',
        'color': 'yellow',
        'interval': 100,
        'projectile': true,
        'behavior': searchBoss
    });


    function searchBoss(obj) {
        var direction = 'left';
        var target = obj.findNearest('boss');

        if( target !== undefined ) {
            var leftDist = obj.getX() - target.x;
        	var upDist = obj.getY() - target.y;

        	if (upDist > 0 && upDist >= leftDist) {
    	        direction = 'up';
            } else if (leftDist > 0 && leftDist >= upDist) {
    	        direction = 'left';
            } else {
            	direction = 'right';
        	}
        }
        obj.move(direction);
    }

    function phonecall_shoot(){
        var p = map.getPlayer();

      	map.placeObject(p.getX(),p.getY()-1,'killer-phonecall');
    }

    // Olace some bulletproof glass
    for( var x=3; x < map.getWidth()-3; x++ ){
    	map.placeObject(x, map.getHeight() - 7, 'bullteproof-glass');
    }


    map.getPlayer().setPhoneCallback( phonecall_shoot );
```


## LostSenSS: Under attack

```javascript

    map.defineObject('myBullet', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'green',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });

    // A safe place on the way to the phone where you can wait until the boss goes to the other side
    map.placeObject(25, map.getHeight() - 4, 'block');

    // Run bullets
    map.getPlayer().setPhoneCallback(function() {
        for (var i = 8; i < 18; i++) {
            for (var x = 0; x < map.getWidth(); x++) {
                map.placeObject(x, i, 'myBullet');
            }
        }
    });
```

## larsj+apark: Random Access

```javascript
Math.random = function() { return 1; }

map.defineObject('mybullet', {
	'type': 'dynamic',
	'symbol': '.',
	'color': 'red',
	'interval': 100,
	'projectile': true,
	'behavior': function (me) {
    		me.move('right');
	}
});


map.getPlayer().setPhoneCallback(function() {
	map.placeObject(5, 5, 'mybullet');
	map.placeObject(5, 6, 'mybullet');
});

```

## garzon: hide and shoot

Don't panic! Just hide in the shelters and make phone calls. :)

```javascript
    map.defineObject('bullet2', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'green',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });
    map.defineObject('shelter', {
        'symbol': 'O',
        'color': 'green',
        'impassable':true
    });

    for(x=Math.floor(map.getWidth()/2);x>0;x--){
    	map.placeObject(2*x,12,'shelter');
        map.placeObject(2*x-1,14,'shelter');
    }

    map.getPlayer().setPhoneCallback(function(){
    	player=map.getPlayer();
        map.placeObject(player.getX()-1,player.getY(),'bullet2');
    });
```

## MI53RE: I can use drone too! >:D

	////////////////////////////////////////////////////////////////////////////////////
	//WARNING WHEN THE BOSS IS KILLED YOU STILL MIGHT DIE FFROM YOUR DRONES'S BULLET!!//
	//		  SO WATCH OUT WHEN GETTING THE ALGORYTHM!!			  //
	//		            (Still IMAO it's fun :D)				  //
	////////////////////////////////////////////////////////////////////////////////////

```javascript



	//we define a drone
	map.defineObject('drone', {
        'type': 'dynamic',
        'symbol': '☣',
        'color': 'yellow',
        'interval': 200,
        'behavior': function (me) {
        		if (Math.random() < 0.3) {
            			map.placeObject(me.getX() + 1, me.getY(), 'dbullet');
        		}
        	},
    	});
	 // we define the drone's weapon
   	map.defineObject('dbullet', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'blue',
        'interval': 100,
        'projectile': true,
       	'behavior': function (me) {
            		me.move('right');
        	},
        });
	// we prepare the callback that will be activated later
   	function callback(){
		map.placeObject(1, 5, 'drone');
    		map.placeObject(1, 6, 'drone');
	}
	//on level start we spawn a block that will help us
	//get to the phone across the bullet's rain
	map.placeObject(28, map.getHeight() - 5, 'block');
	//once we get the phone back we can start the fun >:D!!!
	map.getPlayer().setPhoneCallback(callback);
```

## Innovision: Fight the Boss with a Boss

```javascript
map.defineObject('minishield', {
        'symbol': '-',
        'color': 'blue',
        'impassable': true
    });
    
    map.placeObject(25, 21, 'minishield');
    
   map.defineObject('ANTIboss', {
        'type': 'dynamic',
        'symbol': '⊙',
        'color': 'green',
        'interval': 200,
        'onCollision': function (player) {
            player.killedBy('the ANTIboss');
        },
        'behavior': function (me) {
        	if (!me.direction) {
        		me.direction = 'right';
        	}
        	if (me.canMove(me.direction)) {
            	me.move(me.direction);
        	} else {
        		me.direction = (me.direction == 'right') ? 'left' : 'right';
        	}
        	if (Math.random() < 0.3) {
            	map.placeObject(me.getX(), me.getY() - 2, 'ANTIbullet');
        	}
        }
    });
    
    map.defineObject('ANTIbullet', {
        'type': 'dynamic',
        'symbol': '.',
        'color': 'green',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('up');
        }
    });
    
    map.getPlayer().setPhoneCallback(function(){
        map.placeObject(9, 5, 'boss');
    map.placeObject(11, 13, 'ANTIboss');
    map.placeObject(13, 13, 'ANTIboss');
    map.placeObject(15, 13, 'ANTIboss');
    map.placeObject(17, 13, 'ANTIboss');
    map.placeObject(19, 13, 'ANTIboss');
    map.placeObject(21, 13, 'ANTIboss');
    map.placeObject(23, 13, 'ANTIboss');
    map.placeObject(25, 13, 'ANTIboss');
    map.placeObject(27, 13, 'ANTIboss');
    map.placeObject(29, 13, 'ANTIboss');
    map.placeObject(31, 13, 'ANTIboss');
    
    map.placeObject(10, 14, 'ANTIboss');
    map.placeObject(12, 14, 'ANTIboss');
    map.placeObject(14, 14, 'ANTIboss');
    map.placeObject(16, 14, 'ANTIboss');
    map.placeObject(18, 14, 'ANTIboss');
    map.placeObject(20, 14, 'ANTIboss');
    map.placeObject(22, 14, 'ANTIboss');
    map.placeObject(24, 14, 'ANTIboss');
    map.placeObject(26, 14, 'ANTIboss');
    map.placeObject(28, 14, 'ANTIboss');
    map.placeObject(30, 14, 'ANTIboss');
    map.placeObject(32, 14, 'ANTIboss');
    });
```

The whole idea behind this is that before you get the function phone, you hide under the minishield (see code) for cover.  Once you reach the other side and get the function phone, call it once.  A good version of the boss (named ANTIboss in the code) will appear.  It looks exactly the same as the boss, except that it is green in color and shoots upwards.  If the boss KOs the antiboss at the first call, simply call it again.  However, when the boss is defeated, you must still get the timing right, because the ANTIboss will still shoot upwards, and if you're not careful, you will die from its bullets.

Thank you to those who have posted solutions before me.  Without your solutions, I would never have been able to understand the code and create this awesome solution.

## lz: bigger bosses

Touch the '7' to call two bigger bosses that will let you safely pick up the two items and exit.

```javascript
    map.defineObject('biggerboss', {
        'type': 'dynamic',
        'symbol': '⊙',
        'color': 'blue',
        'interval': 200,
        'onCollision': function (player) {
            player.killedBy('the biggerboss');
        },
        'behavior': function (me) {
            if (map.countObjects('boss') === 0) {
                return;
            }
            if (Math.random() < 0.3) {
                map.placeObject(me.getX() + 1, me.getY(), 'bluebullet');
            }
        }
    });
    map.defineObject('bluebullet', {
        'type': 'dynamic',
        'symbol': '-',
        'color': 'blue',
        'interval': 100,
        'projectile': true,
        'behavior': function (me) {
            me.move('right');
        }
    });
    map.defineObject('button',  {
        'symbol': '7',
        'color': 'blue',
        'onCollision': function (player) {
            map.placeObject(0, 5, 'biggerboss');
            map.placeObject(0, 6, 'biggerboss');
        }
    });
    map.placeObject(1, map.getHeight() - 3, 'button');
```