Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float [] velocidade = new float [20];
- float tempo = 0;
- float distancia;
- int i, ru=0;
- boolean chave = true;
- void setup () {
- size(600, 600);
- frameRate(60);
- for (i=0; i<=19; i++) {
- velocidade[i] = random(0, 5);
- }
- }
- void draw () {
- background(222);
- mostraGrade ();
- Car();
- }
- void mostraGrade(){
- for (int i=0;i<12;i++){
- line(0,i*50, 600, i*50);
- line(i*50,0, i*50, 600);
- }
- }
- float MRU (float velocidade, float tempo){
- float d;
- d= velocidade*tempo/60;
- return (d);
- }
- void Car (){
- int u=10;
- for(int i=0;i<=19;i++){
- Carros(i,u);
- u=u+25;
- }
- }
- void Carros (int i, int po) {
- int r,g,b;
- r=int(random(256));
- g=int(random(256));
- b=int(random(256));
- float distancia = MRU (velocidade[i], tempo);
- tempo++;
- fill(r,g,b);
- rect(distancia,po, 10, 10);
- if(distancia>600){
- fill(0);
- text("O Vecendor é o carro", 450, 550);
- text(i, 450, 570);
- noLoop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement