xxxxxxxxxx
71
/*
using keyboard
by yana
*/
// declare variables
let x = 200;
let y = 300 ;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if (keyIsDown(RIGHT_ARROW)) {
x = x + 5;
}
if (keyIsDown(LEFT_ARROW)) {
x = x - 5;
}
fill("pink");
noStroke();
// shapes
// body
rectMode(CENTER);
square(x, y, 40, 10);
// head
circle(x,y-30,40)
fill("#FAE69D");
// eyes
circle (x-10,y-30,10)
circle (x+10,y-30,10)
noStroke();
fill("pink");
// legs
circle (x-10,y+25,10)
circle (x+10,y+25,10)
noStroke();
fill("pink");
// hands
circle (x-25,y-5,10)
circle (x+25,y-5,10)
noStroke();
fill("pink");
}
// save an image of the canvas
function mousePressed() {
save("character.jpg");
}