SHARE
TWEET

Untitled

a guest May 25th, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Creating variables
  2. var robotX=[],robotY=[],robotCvqt=[],updates=0,pole=[],dx=[],dy=[],
  3. izbranaStrelkaZaSlagane=0,broiRoboti=0,ostavashtiUpdatiDoDvijenie=20;
  4. var vuzmojniDX=[0,-1,0,1,0,1],razmerX=50,razmerY=50;
  5. var vuzmojniDY=[0,0,-1,0,1,1],cameraX=20,cameraY=10;
  6. var fabX=[],fabY=[],fabDX=[],fabDY=[],fabCvqt=[],brFabriki=6;
  7.  
  8. for(x=0;x<razmerX;x=x+1){
  9.     pole[x]=[];
  10.     for(y=0;y<razmerY;y=y+1){
  11.         pole[x][y]=randomInteger(17);
  12.         if(pole[x][y]>5){
  13.             pole[x][y]=0;
  14.         }
  15.     }
  16. }
  17. for(iFab=0;iFab<brFabriki;iFab=iFab+1){
  18.     console.log("vlezna se za ",iFab);
  19.     fabX[iFab]=2+randomInteger(razmerX-2-2);
  20.     fabY[iFab]=2+randomInteger(razmerY-2-2);
  21.     var sluchainoIzbranaPosoka=1+randomInteger(5);
  22.     fabDX[iFab]=vuzmojniDX[sluchainoIzbranaPosoka];
  23.     fabDY[iFab]=vuzmojniDY[sluchainoIzbranaPosoka];
  24.     fabCvqt[iFab]=iFab;
  25.     pole[randomInteger(razmerX)][randomInteger(razmerY)]=100+iFab;
  26. }
  27. function update() {
  28.     ostavashtiUpdatiDoDvijenie=ostavashtiUpdatiDoDvijenie-1;
  29.     if(ostavashtiUpdatiDoDvijenie<0){
  30.         for(iR=0;iR<broiRoboti;iR=iR+1){
  31.             robotX[iR] = robotX[iR]+dx[iR];
  32.             robotY[iR] = robotY[iR]+dy[iR];
  33.             if(robotX[iR]<0||robotX[iR]>=razmerX
  34.              ||robotY[iR]<0||robotY[iR]>=razmerY){
  35.                 console.log("mri");
  36.             }else{
  37.               if(pole[robotX[iR]][robotY[iR]]!=0){
  38.                 dx[iR]=vuzmojniDX[pole[robotX[iR]][robotY[iR]]];
  39.                 dy[iR]=vuzmojniDY[pole[robotX[iR]][robotY[iR]]];
  40.               }
  41.             }
  42.         }
  43.        
  44.         rodiRobot(broiRoboti%6);
  45.         ostavashtiUpdatiDoDvijenie=20;
  46.     }
  47. }
  48. function draw() {
  49.    var kartinki=[paddle,arrowLeft,arrowUp,arrowRight,arrowDown,arrowDownRight];
  50.     kartinki[100]=joystick;
  51.     kartinki[101]=flagYellow1;
  52.     kartinki[102]=gem[42];
  53.     kartinki[103]=jewelRed;
  54.     kartinki[104]=motorBlue;
  55.     kartinki[105]=princess[17];
  56.     drawImage(backCake,0, 0, 800, 600);
  57.     for(x=0;x<razmerX;x=x+1){
  58.         for(y=0;y<razmerY;y=y+1){
  59.             drawImage(kartinki[pole[x][y]],(x-cameraX)*20,
  60.                       (y-cameraY)*20,19,19);    
  61.         }
  62.     }
  63.     for(iR=0;iR<broiRoboti;iR=iR+1){
  64.       drawImage(jelly[robotCvqt[iR]],(robotX[iR]-cameraX)*20,
  65.                 (robotY[iR]-cameraY)*20,20,20);
  66.     }
  67.    
  68.     drawImage(box,600,0,200,600);
  69.     drawImage(ballOrTarget,605,izbranaStrelkaZaSlagane*60-5,60,60);
  70.  
  71.     for(ik=0;ik<6;ik=ik+1){
  72.         drawImage(kartinki[ik],610,ik*60,50,50);
  73.     }
  74.  
  75. };
  76. function mouseup() {
  77.     if(mouseX<600){
  78.         var clicknatoX=Math.floor(mouseX/20);
  79.         var clicknatoY=Math.floor(mouseY/20);
  80.         pole[clicknatoX][clicknatoY]=izbranaStrelkaZaSlagane;
  81.     }else{
  82.         izbranaStrelkaZaSlagane=Math.floor(mouseY/60);
  83.     }
  84.     // Show coordinates of mouse on click
  85.     console.log("Mouse clicked at", mouseX, mouseY);
  86. };
  87. function rodiRobot(otKoqFabrika){
  88.     robotX[broiRoboti]=fabX[otKoqFabrika];
  89.     robotY[broiRoboti]=fabY[otKoqFabrika];
  90.     dx[broiRoboti]=fabDX[otKoqFabrika];
  91.     dy[broiRoboti]=fabDY[otKoqFabrika];
  92.     robotCvqt[broiRoboti]=fabCvqt[otKoqFabrika];
  93.     broiRoboti=broiRoboti+1;
  94.  
  95. }
  96. function keyup(key) {
  97.     if(key==39){
  98.         cameraX=cameraX+1;
  99.     }
  100. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top