Carla Stipo Tarea 6 Movimiento

De Casiopea
Tarea 6 movimiento


TítuloTarea 6 movimiento
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 6
Período2012-
AsignaturaImagen Escrita 2012,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Carla Stipo
ProfesorHerbert Spencer

Ideas tomadas de http://www.learningprocessing.com/examples/chapter-8/example-8-2/

Car myCar1; Car myCar2;

void setup() {

 size (600,600);
  myCar1 = new Car(color(508,50,300),0,100,2); 
 myCar2 = new Car(color(50,100,255),0,10,1);

}

void draw() {
 background(255);
 myCar1.drive();
 myCar1.display();
 myCar2.drive();
 myCar2.display();

}

class Car {

 color c;
 float xpos;
 float ypos;
 float xspeed;
 
Car(color tempC, float tempXpos, float tempYpos, float tempXspeed) { 
   c = tempC;
   xpos = tempXpos;
   ypos = tempYpos;
   xspeed = tempXspeed;
 }
 void display() {
   stroke (47);
   fill(c);
   ellipseMode(CENTER);
   triangle(200, ypos, xpos, 250, xpos, ypos);
   

}

 void drive() {
   xpos = xpos + 3
  ;
   if (xpos > width) {
     xpos = 10;}
   ypos = ypos + 3;
   if (ypos > height) {
     ypos = 40;
   }
   

} }