Carla Stipo Tarea 6 Movimiento
De Casiopea
Título | Tarea 6 movimiento |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 6 |
Período | 2012- |
Asignatura | Imagen Escrita 2012, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Carla Stipo |
Profesor | Herbert 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; }
} }