Advertisement
bethdps

Corrida

Sep 23rd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. float [] velocidade = new float [20];
  2. float tempo = 0;
  3. float distancia;
  4. int i, ru=0;
  5. boolean chave = true;
  6.  
  7. void setup () {
  8.   size(600, 600);
  9.   frameRate(60);
  10.  
  11.  
  12.   for (i=0; i<=19; i++) {
  13.     velocidade[i] = random(0, 5);
  14.   }
  15. }
  16.  
  17. void draw () {
  18.   background(222);
  19.    mostraGrade ();
  20.    Car();
  21. }
  22.  
  23. void mostraGrade(){
  24.   for (int i=0;i<12;i++){
  25.     line(0,i*50, 600, i*50);
  26.     line(i*50,0, i*50, 600);
  27.    
  28.   }
  29.  
  30. }
  31.  
  32. float MRU (float velocidade, float tempo){
  33.   float d;
  34.  
  35.   d= velocidade*tempo/60;
  36.   return (d);
  37. }
  38.  
  39. void Car (){
  40.   int u=10;
  41.   for(int i=0;i<=19;i++){    
  42.     Carros(i,u);
  43.     u=u+25;
  44.    
  45.    
  46.   }
  47. }
  48.  
  49. void Carros (int i, int po) {
  50.   int r,g,b;
  51.   r=int(random(256));
  52.   g=int(random(256));
  53.   b=int(random(256));
  54. float distancia = MRU (velocidade[i], tempo);
  55.   tempo++;
  56.   fill(r,g,b);
  57.   rect(distancia,po, 10, 10);
  58.   if(distancia>600){
  59.     fill(0);
  60.     text("O Vecendor é o carro", 450, 550);
  61.     text(i, 450, 570);
  62.        noLoop();
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement