Advertisement
bethdps

Barco

Nov 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. float z,y,x;
  2.  
  3. void setup(){
  4.   size(600,600);
  5.   rectMode(CENTER);
  6. }
  7.  
  8. void draw(){
  9.  background(255);
  10.   y = sin(x);
  11.   onda();
  12.   fill(0);
  13.   barco(252,y*30+295);
  14.   x+= 0.02; //controla a velocidade de subida e descida do barco
  15. }
  16.  
  17. void barco(float x, float  y){
  18. rect(x,y,10,10);
  19. triangle(x+5,y-5,x+5,y+5,x+10,y-5);
  20. triangle(x-5,y-5,x-5,y+5,x-10,y-5);
  21. triangle(x,y-20,x,y-10,x+10,y-10);
  22. stroke(0);
  23. line(x,y,x,y-20);
  24. }
  25.  
  26. void onda(){
  27.   noStroke();
  28.   fill(0,0,255); //azul
  29.   for (int i = 0; i < width/2; i++){//quantidade de bolas a serem feitas
  30.    float w = sin(z+frameCount*0.02); //essa multiplicaรงรฃo controla a velocidade da onda
  31.     ellipse(z*40,30*w+300,2,2); //z=periodo  w = amplitude
  32.     z+= 0.1; //controla o espassamento entre as bolinhas
  33.   }
  34.  z=0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement