Advertisement
MrsMcLead

boxy

Nov 17th, 2015
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. int[] grassX;
  2. int[] grassHeight;
  3. int x;
  4.  
  5. void setup()
  6. {
  7.   size(1024,768);
  8.    background(#6599FF);
  9.    grassX = new int[150];
  10.    grassHeight = new int[150];
  11.    grassX[0] = 5;
  12.    grassHeight[0] = 720;
  13.    for(int i = 1; i < 150; i++)
  14.    {
  15.     grassX[i] =  grassX[i-1] + (int)random(6,10);
  16.     grassHeight[i] = 710+(int)random(8,12);
  17.     print("grassX: " + grassX[i]+ " grassHeight: " + grassHeight[i] + "\n");
  18.     x = 0;
  19.    }
  20.  
  21. }
  22.  
  23. void draw()
  24. {
  25.    background(#6599FF);
  26.    if(keyPressed && key == 'd')
  27.    {
  28.     x = x + 1;
  29.    }
  30.    else if(keyPressed && key == 'a')
  31.    {
  32.     x = x - 1;
  33.    }
  34.    
  35.  
  36.  boxy();
  37.  lawn();
  38. }
  39.  
  40. void lawn()
  41. {
  42.   fill(#097054);
  43.  noStroke();
  44.  rect(0,740,width,30);
  45.  stroke(#097054);
  46.  strokeWeight(3);
  47.  
  48.  int i = 0;
  49.  
  50.  while(i < 150)
  51.  {
  52.    line(grassX[i],grassHeight[i],grassX[i]+1,740);
  53.    i = i + 1;
  54.   }
  55. }
  56.  
  57. void boxy()
  58. {
  59.   fill(#BF41BE);
  60.   noStroke();
  61.  rect(x,700,40,40);
  62. }
  63.  
  64. void keyPressed()
  65. {
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement