Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ot bit.do/kodami
- // Creating variables
- let myX=300,myY=300,angle=0,iskeypresed=[],skorost=0;
- let patroniX=[],patroniY=[],angleP=[],currentshot=0,i=0;
- let health=100,i1=0,vidvrag=5;
- let vragX=[],vragY=[],broivragove=1,cooldown=0,vragAngle=[];
- for(i=0;i<100;i++)
- {
- patroniX[i]=10000000;
- patroniY[i]=10000000;
- angleP[i]=0;
- }
- function update() {
- if(health>0)
- {
- if(broivragove==100)
- {
- broivragove=0;
- }
- cooldown++;
- if(cooldown==25)
- {
- vidvrag=randomInteger(4)
- if(vidvrag==0)
- {
- vragX[broivragove]=randomInteger(1355)
- vragY[broivragove]=-30
- }
- if(vidvrag==1)
- {
- vragX[broivragove]=randomInteger(1355)
- vragY[broivragove]=775
- }
- if(vidvrag==2)
- {
- vragX[broivragove]=-30
- vragY[broivragove]=randomInteger(745)
- }
- if(vidvrag==3)
- {
- vragX[broivragove]=1380
- vragY[broivragove]=randomInteger(745)
- }
- cooldown=0;
- vragAngle[broivragove]=randomInteger(360)
- broivragove++;
- }
- for(i=0;i<100;i++)
- {
- for(i1=0;i1<broivragove;i1++)
- {
- if(areColliding(vragX[i1],vragY[i1],30,30,patroniX[i],patroniY[i],10,10))
- {
- vragX[i1]=100000000000;
- patroniX[i]=1000000000000000000;
- health=health+15;
- }
- }
- }
- for(i=0;i<100;i++)
- {
- if(areColliding(vragX[i],vragY[i],30,30,myX,myY,30,30))
- {
- health=health-50;
- vragX[i]=10000000;
- }
- }
- myX=myX+Math.cos(angle)*skorost;
- myY=myY-Math.sin(angle)*skorost;
- for(i=0;i<100;i++)
- {
- vragX[i]=vragX[i]+Math.cos(vragAngle[i])*3;
- vragY[i]=vragY[i]-Math.sin(vragAngle[i])*3;
- patroniX[i]=patroniX[i]+Math.cos(angleP[i])*5;
- patroniY[i]=patroniY[i]-Math.sin(angleP[i])*5;
- }
- if(iskeypresed[65]==true)
- {
- angle=angle+6.28/100;
- }
- if(iskeypresed[68]==true)
- {
- angle=angle-6.28/100;
- }
- if(iskeypresed[87]==true)
- {
- skorost=skorost+0.05;
- }
- if(iskeypresed[83]==true)
- {
- skorost=skorost-0.05;
- }
- }
- }
- function draw() {
- if(health>0)
- {
- context.fillStyle="green";
- context.fillRect(0,0,health,20)
- context.fillRect(myX,myY,30,30)
- context.fillStyle="blue";
- for(i=0;i<100;i++)
- {
- context.fillRect(patroniX[i],patroniY[i],10,10)
- }
- context.fillStyle="red";
- for(i=0;i<broivragove;i++)
- {
- context.fillRect(vragX[i],vragY[i],30,30)
- }
- }
- };
- function keydown(key) {
- iskeypresed[key]=true;
- console.log("pressed key",key)
- };
- function keyup(key) {
- iskeypresed[key]=false;
- }
- function mouseup() {
- angleP[currentshot]=angle;
- patroniX[currentshot]=myX+10;
- patroniY[currentshot]=myY+10;
- currentshot++;
- if(currentshot>100)
- {
- currentshot=0;
- }
- console.log("Mouse clicked at", mouseX, mouseY);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement