From 4a3ed80f51245c429086f2467097c03ec753d35b Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sat, 20 Feb 2021 21:37:23 +0100 Subject: i&m: add exercise of 14th feb 2018 --- Year_2/IandM/02142018/02142018.pde | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Year_2/IandM/02142018/02142018.pde (limited to 'Year_2/IandM/02142018/02142018.pde') diff --git a/Year_2/IandM/02142018/02142018.pde b/Year_2/IandM/02142018/02142018.pde new file mode 100644 index 0000000..6bc87ab --- /dev/null +++ b/Year_2/IandM/02142018/02142018.pde @@ -0,0 +1,27 @@ +ArrayList hearts = new ArrayList(); +void setup() { + size(512, 512); + background(#011146); + frameRate(60); +} +void draw() { + fill(#011146, 100); + rect(0, 0, width, height); + + if ((int)random(1, 101) <= 5) { + Heart tmp = new Heart((int)random(0, width), height/2+10); + hearts.add(tmp); + } + + for (Heart h : hearts) { + h.draw(); + } +} + +void mouseClicked() { + for (Heart h : hearts) { + if (dist(h.positionx(), h.positiony(), mouseX, mouseY) < 30) { + h.die(); + } + } +} -- cgit v1.2.3-71-g8e6c