Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. let a = [];
  2.  
  3. function setup() {
  4. createCanvas(400, 400);
  5. for (let i = 0; i < 10; i++) {
  6. a[i] = i * 20;
  7. }
  8. }
  9.  
  10. function draw() {
  11. background(220);
  12. for (let i = 0; i < a.length; i++) {
  13. rect(a[i], 20, 20, 20);
  14. }
  15. }
  16.  
  17. function mousePressed() {
  18. for (let i = 0; i < 10; i++) {
  19. if (mouseX > a[i] && mouseX < a[i] + 20 && mouseY > 20 && mouseY < 20 + 20) {
  20. a.splice(i, 1);
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement