xxxxxxxxxx
56
/*
- Create a shape (circle, rectangle)
- Modify shape function arguments to use variables instead of fixed values
- Make the shape move left to right
*/
// let bubbleX = 150;
// let bubbleY = 200;
// let bubbleW = 160;
// let bubbleH = 100;
// let bubbleR = 255;
// let bubbleG = 0;
// let bubbleB= 200;
let bubble = {
x: 150,
y: 200,
w: 160,
h: 100,
r: 255,
g: 0,
b: 200,
move: function (){
this.x++;
}
}
function setup() {
createCanvas(400, 400);
}
// function move(item){
// item.x += 1;
// }
function draw() {
background(220);
// fill(bubbleR, bubbleG, bubbleB);
// rect(bubbleX, bubbleY, bubbleW,bubbleH);
// bubbleX+=1;
fill(bubble.r, bubble.g, bubble.b);
rect(bubble.x, bubble.y, bubble.w, bubble.h);
bubble.x+=1;
// move(bubble);
// bubble.move();
}
/*
- Make a different shape. Look at the docs to see different options
- Make the shape change size and move up and down
- Make the shape move like pac man. disappear on one edge and reappear on the other
- Try to make the shape be a random walker (https://en.wikipedia.org/wiki/Random_walk)
- Transform your code have a character, can be an image or a shape that is an object with different properties
- colour, width, height, x, y, maybe a function, an array, another object
*/