Práctica de Processing V

Para acabar la evaluación tuvimos que simular un juego de luces que imita a las del coche fantástico:


long tiempo;
long t_actualizado;
long t_retardo;
int x,y;
char sentido;
float ancho;
int distancia;
void setup()
{
  t_retardo= 200;
  tiempo = 0;
   t_actualizado = 0;
   sentido = 'd';
   x = 100;
   y = 300;
   ancho = 50;
   distancia = 75;
size(600,600);
}
void draw()
{
  if (x>=500){
    sentido = 'i';
  }
    if (x<=50) {
    sentido = 'd';
    }

fill(0,0,0,40);
rect(0,0,width, height);
tiempo = millis();
if( tiempo > t_actualizado + t_retardo)
{
fill(255,0,0);
ellipse(x,y,ancho,ancho);
t_actualizado = tiempo;
if (sentido == 'd'){
  x = x+distancia;
}
if (sentido == 'i'){
  x = x-distancia;
}
}
}


Comentarios

Entradas populares de este blog

ACTIVIDAD 6: Mapa Interactivo Kaspersky

ACTIVIDAD 2: Norse