xxxxxxxxxx
var angle, x, y;
function setup() {
createCanvas(windowWidth, windowHeight);
x = windowWidth/2;
ya = windowHeight/2;
y = 0
angle = 0;
}
function draw() {
background(100);
translate(x, ya);
rotate(radians(angle));
if (keyIsPressed) {
if (key == 'a' || key == 'A') {
angle -= 5;
}
else if (key == 'd' || key == 'D') {
angle += 5;
}
else if (key == 'w' || key == 'W') {
y -=5 ;
}
else if (key == 's' || key == 'S') {
y += 5;
}
}
triangle(0, y-10, -10, y+10, 10, y+10);
ya = windowHeight/2 + y*cos(radians(angle));
x = windowWidth/2 + y*sin(radians(angle));
y = 0;
}
/*function keyPressed() {
if (key == 'a' || key == 'A') {
angle -= 5;
}
else if (key == 'd' || key == 'D') {
angle += 5;
}
}*/