Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] grassX;
- int[] grassHeight;
- int x;
- void setup()
- {
- size(1024,768);
- background(#6599FF);
- grassX = new int[150];
- grassHeight = new int[150];
- grassX[0] = 5;
- grassHeight[0] = 720;
- for(int i = 1; i < 150; i++)
- {
- grassX[i] = grassX[i-1] + (int)random(6,10);
- grassHeight[i] = 710+(int)random(8,12);
- print("grassX: " + grassX[i]+ " grassHeight: " + grassHeight[i] + "\n");
- x = 0;
- }
- }
- void draw()
- {
- background(#6599FF);
- if(keyPressed && key == 'd')
- {
- x = x + 1;
- }
- else if(keyPressed && key == 'a')
- {
- x = x - 1;
- }
- boxy();
- lawn();
- }
- void lawn()
- {
- fill(#097054);
- noStroke();
- rect(0,740,width,30);
- stroke(#097054);
- strokeWeight(3);
- int i = 0;
- while(i < 150)
- {
- line(grassX[i],grassHeight[i],grassX[i]+1,740);
- i = i + 1;
- }
- }
- void boxy()
- {
- fill(#BF41BE);
- noStroke();
- rect(x,700,40,40);
- }
- void keyPressed()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement