//Justin Chen
//Interactivity 28
//exercise L
//click to shoot lazer
int x =300;
int y = 200;
Bat a;
PShape wing;
void setup() {
size(600, 400);
noStroke();
smooth();
a = new Bat(x,y,0.01);
}
void draw() {
background (255);
a.display();
a.move();
}
class Bat {
float x;
float y;
float e;
float turn;
float a;
Bat (float xpos, float ypos, float easing) {
x = xpos;
y = ypos;
e = easing;
wing = loadShape("leftblade.svg");
}
void display() {
float angle = atan2(mouseY-y, mouseX-x);
turn = cos(a)/16;
a += 0.5;
pushMatrix();
translate(x, y);
rotate(angle);
rotate(turn);
shape(wing, 20, -10, -100, 100);
shape(wing, 20, 5, -100, -100);
popMatrix();
if (mousePressed == true) {
fill(0);
ellipse(mouseX, mouseY, 50, 50);
noFill();
stroke(0);
ellipse(mouseX, mouseY, 80, 80);
fill(0);
triangle(x,y,mouseX+10, mouseY+10,mouseX-10, mouseY-10);
}
}
void move() {
x += ((mouseX - x)* e) ;
y += ((mouseY -y) * e);
}
}
Justin - L
on Monday, Nov 24, 2008 – 2:19 am