From b6dc65da7d5f498190c07baf3e33fd520f8db1aa Mon Sep 17 00:00:00 2001 From: O-01-67 <68935009+O-01-67@users.noreply.github.com> Date: Thu, 28 Jul 2022 21:07:32 -0400 Subject: [PATCH] New random event Paint event: paints a random circle a random color --- mods/paint_event.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 mods/paint_event.js diff --git a/mods/paint_event.js b/mods/paint_event.js new file mode 100644 index 00000000..9792abf3 --- /dev/null +++ b/mods/paint_event.js @@ -0,0 +1,17 @@ +randomEvents.paint = function() { + // set the color of a random circle to a random color + var x = Math.floor(Math.random()*(width-1))+1; + var y = Math.floor(Math.random()*(height-1))+1; + var randomR = Math.floor(Math.random() * 256); + var randomG = Math.floor(Math.random() * 256); + var randomB = Math.floor(Math.random() * 256); + var radius = Math.floor(Math.random()*4)+3; + var rColor = "rgb(" + randomR + "," + randomG + "," + randomB + ")"; + var coords = circleCoords(x,y,radius); + for (var i = 0; i < coords.length; i++) { + var coord = coords[i]; + if (!outOfBounds(coord.x,coord.y) && !isEmpty(coord.x,coord.y)) { + pixelMap[coord.x][coord.y].color = rColor; + }; + }; +}; \ No newline at end of file