Advertisement
Lubomir_Iliev

pucalkaaaaaaaaaa

Oct 13th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. ot bit.do/kodami
  2. // Creating variables
  3. let myX=300,myY=300,angle=0,iskeypresed=[],skorost=0;
  4. let patroniX=[],patroniY=[],angleP=[],currentshot=0,i=0;
  5. let health=100,i1=0,vidvrag=5;
  6. let vragX=[],vragY=[],broivragove=1,cooldown=0,vragAngle=[];
  7. for(i=0;i<100;i++)
  8. {
  9. patroniX[i]=10000000;
  10. patroniY[i]=10000000;
  11. angleP[i]=0;
  12. }
  13. function update() {
  14. if(health>0)
  15. {
  16. if(broivragove==100)
  17. {
  18. broivragove=0;
  19. }
  20. cooldown++;
  21. if(cooldown==25)
  22. {
  23. vidvrag=randomInteger(4)
  24. if(vidvrag==0)
  25. {
  26. vragX[broivragove]=randomInteger(1355)
  27. vragY[broivragove]=-30
  28. }
  29. if(vidvrag==1)
  30. {
  31. vragX[broivragove]=randomInteger(1355)
  32. vragY[broivragove]=775
  33. }
  34. if(vidvrag==2)
  35. {
  36. vragX[broivragove]=-30
  37. vragY[broivragove]=randomInteger(745)
  38. }
  39. if(vidvrag==3)
  40. {
  41. vragX[broivragove]=1380
  42. vragY[broivragove]=randomInteger(745)
  43. }
  44. cooldown=0;
  45. vragAngle[broivragove]=randomInteger(360)
  46. broivragove++;
  47. }
  48. for(i=0;i<100;i++)
  49. {
  50. for(i1=0;i1<broivragove;i1++)
  51. {
  52. if(areColliding(vragX[i1],vragY[i1],30,30,patroniX[i],patroniY[i],10,10))
  53. {
  54. vragX[i1]=100000000000;
  55. patroniX[i]=1000000000000000000;
  56. health=health+15;
  57. }
  58. }
  59. }
  60. for(i=0;i<100;i++)
  61. {
  62. if(areColliding(vragX[i],vragY[i],30,30,myX,myY,30,30))
  63. {
  64. health=health-50;
  65. vragX[i]=10000000;
  66. }
  67. }
  68. myX=myX+Math.cos(angle)*skorost;
  69. myY=myY-Math.sin(angle)*skorost;
  70. for(i=0;i<100;i++)
  71. {
  72. vragX[i]=vragX[i]+Math.cos(vragAngle[i])*3;
  73. vragY[i]=vragY[i]-Math.sin(vragAngle[i])*3;
  74. patroniX[i]=patroniX[i]+Math.cos(angleP[i])*5;
  75. patroniY[i]=patroniY[i]-Math.sin(angleP[i])*5;
  76. }
  77. if(iskeypresed[65]==true)
  78. {
  79. angle=angle+6.28/100;
  80. }
  81. if(iskeypresed[68]==true)
  82. {
  83. angle=angle-6.28/100;
  84. }
  85. if(iskeypresed[87]==true)
  86. {
  87. skorost=skorost+0.05;
  88. }
  89. if(iskeypresed[83]==true)
  90. {
  91. skorost=skorost-0.05;
  92. }
  93. }
  94.  
  95. }
  96. function draw() {
  97. if(health>0)
  98. {
  99. context.fillStyle="green";
  100. context.fillRect(0,0,health,20)
  101. context.fillRect(myX,myY,30,30)
  102. context.fillStyle="blue";
  103. for(i=0;i<100;i++)
  104. {
  105. context.fillRect(patroniX[i],patroniY[i],10,10)
  106. }
  107. context.fillStyle="red";
  108. for(i=0;i<broivragove;i++)
  109. {
  110. context.fillRect(vragX[i],vragY[i],30,30)
  111. }
  112. }
  113. };
  114. function keydown(key) {
  115. iskeypresed[key]=true;
  116. console.log("pressed key",key)
  117. };
  118. function keyup(key) {
  119. iskeypresed[key]=false;
  120. }
  121. function mouseup() {
  122. angleP[currentshot]=angle;
  123. patroniX[currentshot]=myX+10;
  124. patroniY[currentshot]=myY+10;
  125. currentshot++;
  126. if(currentshot>100)
  127. {
  128. currentshot=0;
  129. }
  130. console.log("Mouse clicked at", mouseX, mouseY);
  131. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement