Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let a = [];
- function setup() {
- createCanvas(400, 400);
- for (let i = 0; i < 10; i++) {
- a[i] = i * 20;
- }
- }
- function draw() {
- background(220);
- for (let i = 0; i < a.length; i++) {
- rect(a[i], 20, 20, 20);
- }
- }
- function mousePressed() {
- for (let i = 0; i < 10; i++) {
- if (mouseX > a[i] && mouseX < a[i] + 20 && mouseY > 20 && mouseY < 20 + 20) {
- a.splice(i, 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement