xxxxxxxxxx
58
//Find a way to have the shape move continuously whenever I hold down the arrow keys
//Find a way to create a new shape (slide 271) whenever I press enter and control that new shape instead of the old one
//find a way to get create a star when you reach a certain amount of ornaments and stop controlling things whenever the star is placed
var tree;
var x = 70;
var y = 200;
var score = 0;
function setup() {
createCanvas(400, 400);
tree = loadImage("christmasTree.jpg");
}
function draw() {
background(220);
image(tree,0,0,400,400);
textAlign(CENTER);
text("Use arrow keys to move the ornaments",200,30);
text("Press enter to place ornament and new color",200,50);
//random without arguments shows numbers between 0 and 1
ellipse(x,y,50,50);
//if (random(30)<1){
//x = random(100,300);
//y = random(100,300);
//}
//if (keyIsPressed){
//x = x + 1;
//}
}
function keyPressed(){
if (keyCode === UP_ARROW) {
y = y - 1;
}
if (keyCode === DOWN_ARROW) {
y = y + 1;
}
if (keyCode === LEFT_ARROW) {
x = x - 1;
}
if (keyCode === RIGHT_ARROW) {
x = x + 1;
}
if (keyCode === ENTER) {
fill(random(256),random(256),random(256));
ellipse (x,y,50,50);
}
}
//function mousePressed(){
//if (dist(mouseX,mouseY,x,y)<25){
//score = score + 1;
//}
//}
function newOrnaments(){
ellipse (x,y,50,50);
}