-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawing.js
More file actions
841 lines (787 loc) · 49.8 KB
/
drawing.js
File metadata and controls
841 lines (787 loc) · 49.8 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
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
fire = class
{
constructor (x, y, pos_x, pos_y, r)
{
this.active = 0;// 0 - it damages; 1 - damages near units at one 'for'; 2 - doesn't active
this.who_is_it = 2;
this.x = x;
this.y = y;
this.animation_walk = 0;
this.x1_func = unit[0].object_x;
this.y1_func = unit[0].object_y;
this.object_x = x + pos_x ;//where is he
this.object_y = y + pos_y;//where is he
this.target_y = y / 11 ;
this.light = screen_w * 0.2;
this.radius = r + screen_w * 0.005;
//this.enemy = x / 2;
this.life = 4;
this.direct = -1;
this.damage = z / 1100;
}
draw()
{
ctx.globalCompositeOperation="destination-over";
this.life--;
ctx.beginPath();
ctx.fillStyle = "orange";
ctx.arc(this.x, this.y, this.radius, 0, 2*Math.PI, false);
ctx.fill();
ctx.closePath();
}
}
hero = class
{
constructor (x, y, pos_x, pos_y)
{
this.who_is_it = 0;
this.x = x;
this.y = y;
this.move_x = pos_x;
this.move_y = pos_y;
this.animation_walk = 0;
this.step = true;
this.light = screen_h * 0.4;
this.light_y = screen_h * 0.4;
this.light_x = screen_w * 0.2;
this.object_x = x + pos_x;//where is he
this.object_y = y + y / 11 + pos_y;//where is he
this.target_x = 1;
this.target_y = y / 11 * 1.1;
this.radius = x / 30;
this.direct = 1;
this.life = 10;
this.take_damage = 10;
this.hp = 0.074;
this.mp = 0.074;
}
vision()
{
ctx.clearRect(unit[0].object_x - screen_w * 0.1, unit[0].object_y - screen_h * 0.26, unit[0].light_x, unit[0].light_y * 1.45);
ctx.clearRect(unit[0].object_x - screen_w * 0.106, unit[0].object_y - screen_h * 0.25, unit[0].light_x * 1.06, unit[0].light_y * 1.4);
ctx.clearRect(unit[0].object_x - screen_w * 0.112, unit[0].object_y - screen_h * 0.24, unit[0].light_x * 1.12, unit[0].light_y * 1.35);
ctx.clearRect(unit[0].object_x - screen_w * 0.118, unit[0].object_y - screen_h * 0.23, unit[0].light_x * 1.18, unit[0].light_y * 1.3);
ctx.clearRect(unit[0].object_x - screen_w * 0.124, unit[0].object_y - screen_h * 0.22, unit[0].light_x * 1.24, unit[0].light_y * 1.25);
ctx.clearRect(unit[0].object_x - screen_w * 0.13, unit[0].object_y - screen_h * 0.21, unit[0].light_x * 1.3, unit[0].light_y * 1.2);
ctx.clearRect(unit[0].object_x - screen_w * 0.136, unit[0].object_y - screen_h * 0.2, unit[0].light_x * 1.36, unit[0].light_y * 1.15);
}
draw()
{
ctx.globalCompositeOperation="destination-over";
/*ctx.beginPath(); // check our target body and head
ctx.fillStyle = "black";
ctx.arc(this.object_x, this.object_y, this.radius, 0, 2*Math.PI, false);
ctx.fill();
ctx.closePath();
ctx.beginPath();
ctx.arc(this.object_x, this.object_y + this.target_y, this.radius, 0, 2*Math.PI, false);
ctx.fill();
ctx.closePath();*/
if (this.take_damage < 10) this.take_damage--;
if (this.take_damage == 0) this.take_damage = 10;
ctx.beginPath();//HP MP R menu
ctx.lineWidth = screen_w / 1000;
ctx.fillStyle = "green";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x * this.hp, this.y / 60);
ctx.fillStyle = "red";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x *0.074, this.y / 60);
ctx.fillStyle = "black";
ctx.rect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x * 0.074 * 0.25, this.y / 60)
ctx.rect(this.x * 0.9625 + this.move_x + this.x * 0.074 * 0.25, this.y * 0.957 + this.move_y , this.x * 0.074 * 0.25, this.y / 60)
ctx.rect(this.x * 0.9625 + this.move_x + this.x * 0.074 * 0.5, this.y * 0.957 + this.move_y , this.x * 0.074 * 0.25, this.y / 60)
ctx.rect(this.x * 0.9625 + this.move_x + this.x * 0.074 * 0.75, this.y * 0.957 + this.move_y , this.x * 0.074 * 0.25, this.y / 60)
//ctx.rect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x * this.mp / 3, this.y / 60)
//ctx.rect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x * this.mp / 2, this.y / 60)
//ctx.rect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x * this.mp / 4, this.y / 60)
ctx.stroke();
ctx.fillStyle = "blue";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x * this.mp, this.y / 60);
ctx.fillStyle = "red";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.957 + this.move_y , this.x *0.074, this.y / 60);
ctx.fillStyle = "black";
ctx.fillRect(this.x * 0.96 + this.move_x, this.y * 0.93 + this.move_y , this.x *0.079, this.y / 20);
ctx.closePath();
ctx.fillStyle = "aqua";
ctx.fillRect(this.x * 0.947 + this.move_x, this.y * 0.958 + this.move_y , this.x * 0.09 * 0.1, this.y * 0.015);
ctx.fillStyle = "orange";
ctx.fillRect(this.x * 0.947 + this.move_x, this.y * 0.934 + this.move_y , this.x * 0.09 * 0.1, this.y * 0.015);
ctx.fillStyle = "black";
if (Keys.freez) ctx.fillRect(this.x * 0.945 + this.move_x, this.y * 0.955 + this.move_y , this.x * 0.14 * 0.1, this.y * 0.023);
else ctx.fillRect(this.x * 0.945 + this.move_x, this.y * 0.93 + this.move_y , this.x * 0.14 * 0.1, this.y * 0.023);
if (!Keys.mouse)//doesn't atack
{
ctx.beginPath()//arm with scipitor
if (this.take_damage < 10) ctx.fillStyle = "rgb(116, 98, 113)";
else ctx.fillStyle = "rgb(201, 171, 196)";
ctx.arc(this.x * (1 + 0.036 * this.direct) + this.move_x, this.y* 1.2 + this.move_y, this.x / 150, 0, 2*Math.PI, false)
ctx.fill();
ctx.closePath();
ctx.beginPath();//scipitor
ctx.strokeStyle = "black";
ctx.lineWidth = this.x / 300;
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.25 + this.move_y);
ctx.lineTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.09 + this.move_y)
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y + this.move_y, this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.03 + this.move_y);
ctx.stroke();
ctx.closePath();
}
else//atacks
{
ctx.beginPath()//arm with scipitor
if (this.take_damage < 10) ctx.fillStyle = "rgb(116, 98, 113)";
else ctx.fillStyle = "rgb(201, 171, 196)";
ctx.arc(this.x * (1 + 0.036 * this.direct) + this.move_x, this.y* 1.13 + this.move_y, this.x / 150, 0, 2*Math.PI, false)
ctx.fill();
ctx.closePath();
ctx.beginPath();//scipitor
ctx.strokeStyle = "black";
ctx.lineWidth = this.x / 300;
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.18 + this.move_y);
ctx.lineTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.03 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.02 + this.move_y)
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 0.92 + this.move_y, this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 0.96 + this.move_y);
ctx.stroke();
ctx.closePath();
if (this.mp >= 0.074 * 0.25)
{
ctx.beginPath();
if (Keys.freez)
{
if (this.take_damage < 10) ctx.fillStyle = "rgb(0, 110, 110)";
else ctx.fillStyle = 'aqua';
}
else
{
if (this.take_damage < 10) ctx.fillStyle = "rgb(161, 105, 0)";
else ctx.fillStyle = 'orange';
}
ctx.arc(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.01 + this.move_y, this.x / 150, 0, 2*Math.PI, false);
ctx.fill();
if (Keys.freez)
{
if (this.take_damage < 10) ctx.fillStyle = "rgb(161, 105, 0)";
else ctx.fillStyle = 'orange';
}
else
{
if (this.take_damage < 10) ctx.fillStyle = "rgb(0, 110, 110)";
else ctx.fillStyle = 'aqua';
}
ctx.arc(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.01 + this.move_y, this.x / 80, 0, 2*Math.PI, false);
ctx.fill();
ctx.closePath();
}
}
ctx.beginPath()//arm with flashlight
if (this.take_damage < 10) ctx.fillStyle = "rgb(116, 98, 113)";
else ctx.fillStyle = "rgb(201, 171, 196)";
ctx.arc(this.x* (1 + 0.005 * this.direct) + this.move_x, this.y* 1.2 + this.move_y, this.x / 150, 0, 2*Math.PI, false)
ctx.fill();
ctx.closePath();
ctx.beginPath();//flashlight
ctx.moveTo(this.x * (1 + 0.005 * this.direct) + this.move_x, this.y* 1.17 + this.move_y);
ctx.lineWidth = this.x / 100;
ctx.lineTo(this.x * (1 + 0.005 * this.direct) + this.move_x, this.y* 1.2 + this.move_y)
ctx.stroke();
ctx.closePath();
ctx.beginPath();
ctx.lineWidth = this.x / 300;
if (this.take_damage < 10) ctx.fillStyle = "rgb(170, 170, 0)";
else ctx.fillStyle = "yellow";
ctx.moveTo(this.x * (1 + 0.005 * this.direct) + this.move_x, this.y* 1.2 + this.move_y);
ctx.lineTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y* 1.23 + this.move_y);
ctx.lineTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y* 1.23 + this.move_y);
ctx.lineTo(this.x * (1 + 0.005 * this.direct) + this.move_x, this.y* 1.2 + this.move_y);
ctx.stroke();
ctx.fill();
ctx.closePath();
ctx.beginPath();//eye
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.0001 * this.direct) + this.move_x, this.y * 1.1124 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.097 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.09 + this.move_y, this.x * (1 + 0.013 * this.direct) + this.move_x, this.y * 1.07 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.097 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
if (this.take_damage < 10) ctx.fillStyle = "rgb(0, 110, 110)";
else ctx.fillStyle = 'aqua';
ctx.fill();
ctx.beginPath();//hair forward
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y *1.14 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 - 0.05 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 - 0.02 * this.direct) + this.move_x, this.y *1.12 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y *1.14 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(10, 122, 0)";
else ctx.fillStyle = "rgb(32, 199, 17)";
ctx.fill();
ctx.closePath();
ctx.beginPath();//hair forward
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.06 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 - 0.04 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y *1.14 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 + 0.02 * this.direct) + this.move_x, this.y *1.12 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.02 * this.direct) + this.move_x, this.y * 0.97 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y *1.14 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(10, 122, 0)";
else ctx.fillStyle = "rgb(32, 199, 17)";
ctx.fill();
ctx.closePath();
ctx.beginPath();//head
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.02 + this.move_y, this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x + this.move_x, this.y *1.16 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.05 * this.direct) + this.move_x, this.y * 1.02 + this.move_y, this.x * (1 - 0.04 * this.direct) + this.move_x, this.y * 1.12 + this.move_y, this.x + this.move_x, this.y * 1.16 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(116, 98, 113)";
else ctx.fillStyle = "rgb(201, 171, 196)";
ctx.fill();
ctx.closePath();
ctx.beginPath()//body
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x + this.move_x, this.y * 1.1 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.1 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 + 0.1 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.1 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(0, 4, 32)";
else ctx.fillStyle = "rgb(4, 17, 112)";
ctx.fill();
ctx.closePath();
if(this.step)
{
ctx.beginPath()//legs stand
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(44, 20, 23)";
else ctx.fillStyle = "rgb(77, 36, 40)";
ctx.fill();
ctx.closePath();
}
else
{
ctx.beginPath()//legs walk
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.fillStyle = "rgb(77, 36, 40)";
ctx.fill();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(44, 20, 23)";
else ctx.fillStyle = "rgb(77, 36, 40)";
ctx.fill();
ctx.closePath();
}
}
}
gule = class
{
constructor (x, y, pos_x, pos_y)
{
this.slow = 1;
this.atack = false;
this.who_is_it = 1;
this.x = x;
this.y = y;
this.move_x = 0 + pos_x;
this.move_y = 0 + pos_y;
this.animation_walk = 0;
this.step = true;
this.light = screen_w * 0.2;
this.object_x = x + pos_x ;//where is he
this.object_y = y + pos_y + y / 12;//where is he
this.target_y = y / 11 ;
this.radius = x / 30;
this.enemy = x / 2;
this.direct = -1;
this.life = 10;
this.take_damage = 10;
this.hp = 0.074;
this.see_hero = false;
this.atack_reboot = false;
this.reboot = 0;
this.bit = false;
this.fast = screen_w / 300;
this.damage = 0.008;
}
draw()
{
ctx.globalCompositeOperation="destination-over";
/* ctx.beginPath(); // check our target body and head
ctx.fillStyle = "black";
ctx.arc(this.object_x, this.object_y, this.radius, 0, 2*Math.PI, false);
ctx.arc(this.object_x, this.object_y + this.target_y, this.radius, 0, 2*Math.PI, false);
ctx.fill();
ctx.closePath();*/
if (this.slow < 1) this.slow += 0.01; if (this.slow > 1) this.slow = 1;
if (this.atack_reboot) this.reboot += 1;
if ((this.reboot == 20) && (this.atack_reboot)) {this.reboot = 0; this.atack_reboot = false;}
ctx.beginPath();//HP MP R menu
ctx.fillStyle = "green";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x * this.hp, this.y / 60);
ctx.fillStyle = "red";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x *0.074, this.y / 60);
ctx.fillStyle = "black";
ctx.fillRect(this.x * 0.96 + this.move_x, this.y * 0.93 + this.move_y , this.x *0.079, this.y / 35);
ctx.closePath();
ctx.beginPath();//draw forward arm
if (this.take_damage < 10) this.take_damage--;
if (this.take_damage == 0) this.take_damage = 10;
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.arc(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x / 140, 0, 2*Math.PI, false);
ctx.fill();
ctx.fillStyle = "black";
ctx.arc(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x / 110, 0, 2*Math.PI, false);
ctx.fill();
ctx.moveTo(this.x * (1 - 0.019 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.lineTo(this.x * (1 - 0.015 * this.direct) + this.move_x, this.y * 1.21 + this.move_y);
ctx.lineTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.lineTo(this.x * (1 - 0.009 * this.direct) + this.move_x, this.y * 1.22 + this.move_y);
ctx.lineTo(this.x * (1 - 0.003 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.lineTo(this.x * (1 + 0.001 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.lineTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(141, 133, 133)";
else ctx.fillStyle = "white";
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.beginPath();//eye
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.0001 * this.direct) + this.move_x, this.y * 1.02 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.055 * this.direct) + this.move_x, this.y * 1.04 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
if (this.take_damage < 10) ctx.fillStyle = "rgb(128, 1, 1)";
else ctx.fillStyle = 'red';
ctx.fill();
ctx.closePath();
if (this.reboot > 0) this.bit = true;
if (this.reboot > 10) this.bit = false;
if (!this.bit)
{
ctx.beginPath();//head
ctx.lineWidth = this.x / 200;
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y + this.move_y, this.x *(1 + 0.05 * this.direct) + this.move_x, this.y * 1.05 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.lineTo(this.x * (1 + 0.035 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.lineTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.lineTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.lineTo(this.x * (1 + 0.015 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.lineTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.001 * this.direct) + this.move_x, this.y * 1.03 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.lineTo(this.x * (1 + 0.017 * this.direct) + this.move_x, this.y * 1.11 + this.move_y);
ctx.lineTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.lineTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.11 + this.move_y);
ctx.lineTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x + this.move_x, this.y + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.stroke();
ctx.closePath();
}
else
{
ctx.beginPath();//head
ctx.lineWidth = this.x / 200;
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y + this.move_y, this.x *(1 + 0.05 * this.direct) + this.move_x, this.y * 1.05 + this.move_y, this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.11 + this.move_y);
ctx.lineTo(this.x * (1 + 0.033 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.lineTo(this.x * (1 + 0.027 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.lineTo(this.x * (1 + 0.018 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.lineTo(this.x * (1 + 0.013 * this.direct) + this.move_x, this.y * 1.1 + this.move_y);
ctx.lineTo(this.x * (1 + 0.007 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.001 * this.direct) + this.move_x, this.y * 1.03 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.115 + this.move_y);
ctx.lineTo(this.x * (1 + 0.017 * this.direct) + this.move_x, this.y * 1.11 + this.move_y);
ctx.lineTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.lineTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.11 + this.move_y);
ctx.lineTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x + this.move_x, this.y + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.stroke();
ctx.closePath();
}
ctx.beginPath();//inside mouth
ctx.moveTo(this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.quadraticCurveTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.07 + this.move_y, this.x * (1 + 0.017 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.155 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.01 + this.move_y, this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(128, 1, 1)";
else ctx.fillStyle = 'red';
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.beginPath();//boobs
ctx.lineWidth = this.x /350;
ctx.moveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.2 + this.move_y, this.x * (1 + 0.005 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.quadraticCurveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.18 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.17 + this.move_y);
ctx.stroke();
ctx.closePath();
ctx.beginPath();//body
ctx.lineWidth = this.x / 400;
ctx.moveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.1 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 + 0.12 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.07 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.closePath();
if(this.step)
{
ctx.beginPath()//legs stand
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.closePath();
}
else
{
ctx.beginPath()//legs walk
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.fill();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.closePath();
}
ctx.beginPath();//arm
ctx.arc(this.x * (1 + 0.027 * this.direct) + this.move_x, this.y * 1.16 + this.move_y, this.x / 140, 0, 2*Math.PI, false);
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.arc(this.x * (1 + 0.027 * this.direct) + this.move_x, this.y * 1.16 + this.move_y, this.x / 110, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.moveTo(this.x * (1 + 0.035 * this.direct) + this.move_x, this.y * 1.16 + this.move_y);
ctx.lineTo(this.x * (1 + 0.032 * this.direct) + this.move_x, this.y * 1.21 + this.move_y);
ctx.lineTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.16 + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(141, 133, 133)";
else ctx.fillStyle = "white";
ctx.fill();
ctx.stroke();
ctx.closePath();
}
}
ghost = class
{
constructor (x, y, pos_x, pos_y)
{
this.slow = 1;
this.atack = false;
this.who_is_it = 2;
this.x = x;
this.y = y;
this.move_x = 0 + pos_x;
this.move_y = 0 + pos_y;
this.animation_walk = 0;
this.step = true;
this.light = screen_w * 0.2;
this.object_x = x + pos_x ;//where is he
this.object_y = y + pos_y + y / 12;//where is he
this.target_y = y / 11 ;
this.radius = x / 30;
this.enemy = x / 2.3;
this.direct = -1;
this.life = 10;
this.take_damage = 10;
this.hp = 0.074;
this.see_hero = false;
this.atack_reboot = false;
this.reboot = 0;
this.bit = false;
this.fast = screen_w / 250;
this.damage = 0.027;
}
draw()
{
if (this.slow < 1) this.slow += 0.01; if (this.slow > 1) this.slow = 1;
if (this.atack_reboot) this.reboot += 1;
if ((this.reboot == 20) && (this.atack_reboot)) {this.reboot = 0; this.atack_reboot = false;}
ctx.beginPath();//HP MP R menu
ctx.fillStyle = "green";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x * this.hp, this.y / 60);
ctx.fillStyle = "red";
ctx.fillRect(this.x * 0.9625 + this.move_x, this.y * 0.935 + this.move_y , this.x *0.074, this.y / 60);
ctx.fillStyle = "black";
ctx.fillRect(this.x * 0.96 + this.move_x, this.y * 0.93 + this.move_y , this.x *0.079, this.y / 35);
ctx.closePath();
ctx.beginPath();//draw forward arm
if (this.take_damage < 10) this.take_damage--;
if (this.take_damage == 0) this.take_damage = 10;
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
if (this.reboot > 0) this.bit = true;
if (this.reboot > 10) this.bit = false;
if (!this.bit)
{
ctx.beginPath();//eye
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.0001 * this.direct) + this.move_x, this.y * 1.05 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.055 * this.direct) + this.move_x, this.y * 1.04 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
if (this.take_damage < 10) ctx.fillStyle = "rgb(128, 1, 1)";
else ctx.fillStyle = 'black';
ctx.fill();
ctx.closePath();
ctx.beginPath();
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.0001 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.12 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.stroke();
ctx.closePath();
ctx.beginPath();//head
ctx.lineWidth = this.x / 200;
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y + this.move_y, this.x *(1 + 0.05 * this.direct) + this.move_x, this.y * 1.05 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.15 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.045 * this.direct) + this.move_x, this.y * 1.16 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.25 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.2 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.22 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.2 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.025 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x *(1 + 0.01 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.025 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x *(1 + 0.01 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
//ctx.bezierCurveTo(this.x * (1 - 0.001 * this.direct) + this.move_x, this.y * 1.03 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x + this.move_x, this.y + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "white";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.stroke();
ctx.closePath();
}
else
{
ctx.beginPath();//eye
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.005 + this.move_y, this.x * (1 - 0.005 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.04 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.05 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
if (this.take_damage < 10) ctx.fillStyle = "rgb(128, 1, 1)";
else ctx.fillStyle = 'aqua';
ctx.fill();
ctx.closePath();
ctx.beginPath();
ctx.moveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.bezierCurveTo(this.x * (1- 0.01 * this.direct) + this.move_x, this.y * 1.08 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.025 * this.direct) + this.move_x, this.y * 1.12 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.0098 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.08 + this.move_y);
ctx.stroke();
ctx.fill();
ctx.closePath();
ctx.beginPath();//head
ctx.lineWidth = this.x / 200;
ctx.moveTo(this.x + this.move_x, this.y + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.05 * this.direct) + this.move_x, this.y + this.move_y, this.x *(1 + 0.05 * this.direct) + this.move_x, this.y * 1.05 + this.move_y, this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.15 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.045 * this.direct) + this.move_x, this.y * 1.16 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.06 * this.direct) + this.move_x, this.y * 1.25 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.2 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 + 0.03 * this.direct) + this.move_x, this.y * 1.22 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.2 + this.move_y, this.x *(1 + 0.04 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 - 0.001 * this.direct) + this.move_x, this.y * 1.23 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.025 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x *(1 + 0.01 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x * (1 - 0.02 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.025 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x *(1 + 0.01 * this.direct) + this.move_x, this.y * 1.15 + this.move_y, this.x * (1 - 0.05 * this.direct) + this.move_x, this.y * 1.16 + this.move_y);
//ctx.bezierCurveTo(this.x * (1 - 0.001 * this.direct) + this.move_x, this.y * 1.03 + this.move_y, this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y, this.x * (1 + 0.01 * this.direct) + this.move_x, this.y * 1.13 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.17 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.1 + this.move_y, this.x + this.move_x, this.y + this.move_y);
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "white";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.stroke();
ctx.closePath();
}
/*if(this.step)
{
ctx.beginPath()//legs stand
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.closePath();
}
else
{
ctx.beginPath()//legs walk
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 - 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 - 0.01 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 + 0.05 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
ctx.fill();
ctx.strokeStyle = "black";
ctx.moveTo(this.x * (1 + 0.029 * this.direct) + this.move_x, this.y * 1.2 + this.move_y);
ctx.bezierCurveTo(this.x * (1 + 0.02 * this.direct) + this.move_x, this.y * 1.3 + this.move_y, this.x * (1 - 0.03 * this.direct) + this.move_x, this.y * 1.33 + this.move_y, this.x + this.move_x, this.y * 1.2 + this.move_y);
ctx.stroke();
if (this.take_damage < 10) ctx.fillStyle = "rgb(63, 62, 62)"
else ctx.fillStyle = "grey";
if (this.slow < 1) ctx.fillStyle = "rgb(87, 102, 172)"
ctx.fill();
ctx.closePath();
} */
}
}
chest = class
{
constructor (x, y, pos_x, pos_y)
{
this.x = x;
this.y = y;
this.object_x = pos_x;
this.object_y = pos_y;
this.radius = screen_w * 0.02;
}
draw()
{
ctx.beginPath();
/*ctx.beginPath();
ctx.arc(this.x + this.object_x * 1.05, this.y + this.object_y, screen_w * 0.02, 0, 2*Math.PI, false);
ctx.fillStyle = "green";
ctx.fill();
ctx.closePath();*/
ctx.fillRect(this.x + this.object_x, this.y + this.object_y, screen_w / 20, screen_h / 20);
ctx.fillStyle = "black";
ctx.fillRect(this.x + this.object_x * 0.998, this.y + this.object_y * 0.998, screen_w * 0.052, screen_h * 0.0565);
ctx.arc(this.x + this.object_x * 1.01, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.01, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.06, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.06, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.03, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.03, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.04, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.04, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.09, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.09, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.07, this.y + this.object_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "yellow";
ctx.fill();
ctx.arc(this.x + this.object_x * 1.07, this.y + this.object_y, screen_w * 0.006, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.moveTo(this.x + this.object_x, this.y + this.object_y);
ctx.lineTo(this.x + this.object_x, this.y + this.object_y * 0.95);
ctx.lineTo(this.x + this.object_x * 1.1, this.y + this.object_y * 0.95);
ctx.lineTo(this.x + this.object_x * 1.1, this.y + this.object_y);
ctx.fillStyle = "rgb(77, 36, 40)";
ctx.fill();
ctx.stroke();
ctx.closePath();
}
}
room_key = class
{
constructor(x, y, size_x, size_y, pos_x, pos_y, key)
{
this.x = x;
this.y = y;
this.pos_x = pos_x;
this.pos_y = pos_y;
this.size_x = size_x;
this.size_y = size_y;
this.which_door = key;
this.radius = screen_w * 0.005
}
draw()
{
ctx.beginPath();
/*ctx.arc(this.x * 1.05 + this.pos_x, this.y * 1.15 + this.pos_y, screen_w * 0.005, 0, 2*Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();*/
ctx.fillStyle = "rgb(222, 148, 170)";
ctx.fillRect(this.x * 1.02 + this.pos_x, this.y * 1.04 + this.pos_y, this.size_x * 0.6, this.size_y * 0.25)
ctx.fillStyle = "gold";
ctx.fillRect(this.x + this.pos_x, this.y + this.pos_y, this.size_x, this.size_y * 0.5);
ctx.fillRect(this.x * 1.04 + this.pos_x, this.y * 1.05 + this.pos_y, this.size_x * 0.25, this.size_y);
ctx.fillRect(this.x * 1.02 + this.pos_x, this.y * 1.27 + this.pos_y, this.size_x * 0.25, this.size_y * 0.2);
ctx.closePath();
}
}