# Coding Questions

**URL:** https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=49

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

**Page:** 50

---

## [Help needed for random change of image on mouse hover/click](https://discourse.processing.org/t/help-needed-for-random-change-of-image-on-mouse-hover-click/6820)

<div class="topic-metadata">

**Author:** [@jesspayne](https://discourse.processing.org/u/jesspayne)\
**Replies:** 9\
**Last updated:** [December 23, 2018, 8:44pm UTC](https://discourse.processing.org/t/help-needed-for-random-change-of-image-on-mouse-hover-click/6820 "2018-12-23T20:44:19Z")

</div>

Hi! I’m a student at Anglia Ruskin University’s School of Art (UK) and am working on a piece that I’d like to make interactive. I’ve recently discovered Processing and P5.js and think this could be what I need but am a …

---

## [BubbleSort Visualization (want to slow it down)](https://discourse.processing.org/t/bubblesort-visualization-want-to-slow-it-down/6742)

<div class="topic-metadata">

**Author:** [@Lillbre](https://discourse.processing.org/u/Lillbre)\
**Replies:** 3\
**Last updated:** [December 21, 2018, 12:23am UTC](https://discourse.processing.org/t/bubblesort-visualization-want-to-slow-it-down/6742 "2018-12-21T00:23:00Z")

</div>

I want to make a visualization of BubbleSort and make rectangles move to show the sorting. My code works “kind off” https://editor.p5js.org/Lillbre/sketches/HkkBABreN but I would love if every move could be seen more slo…

---

## [Seamlessly changing the render target from on-screen to a larger off-screen graphic](https://discourse.processing.org/t/seamlessly-changing-the-render-target-from-on-screen-to-a-larger-off-screen-graphic/6695)

<div class="topic-metadata">

**Author:** [@grege2](https://discourse.processing.org/u/grege2)\
**Replies:** 1\
**Last updated:** [December 18, 2018, 4:20am UTC](https://discourse.processing.org/t/seamlessly-changing-the-render-target-from-on-screen-to-a-larger-off-screen-graphic/6695 "2018-12-18T04:20:26Z")

</div>

Hi folks, Summary: I’d like to change my p5.js rendering target (ie. destination, or graphics buffer) from the on-screen physical window, to an off-screen graphics buffer, by just using some “setRenderTarget()” call, bu…

---

## [Gradient color in Line](https://discourse.processing.org/t/gradient-color-in-line/6694)

<div class="topic-metadata">

**Author:** [@noob](https://discourse.processing.org/u/noob)\
**Replies:** 3\
**Last updated:** [December 18, 2018, 3:02am UTC](https://discourse.processing.org/t/gradient-color-in-line/6694 "2018-12-18T03:02:05Z")

</div>

Hello! It’s me again :blush: with the beginner question. So I was playing around with lines as you can see in the code below and I want to make the gradient color from black to white in the lines to give effect of depth…

---

## [Help with instance mode?](https://discourse.processing.org/t/help-with-instance-mode/6647)

<div class="topic-metadata">

**Author:** [@metrocode](https://discourse.processing.org/u/metrocode)\
**Replies:** 1\
**Last updated:** [December 16, 2018, 3:35am UTC](https://discourse.processing.org/t/help-with-instance-mode/6647 "2018-12-16T03:35:04Z")

</div>

Hello, I am having trouble using instance mode. I would like to convert this code for a mini game into instance mode so that I can reference it in a bigger game file that I am coding. I am not sure if I am using the ins…

---

## [Random color but static](https://discourse.processing.org/t/random-color-but-static/6623)

<div class="topic-metadata">

**Author:** [@noob](https://discourse.processing.org/u/noob)\
**Replies:** 3\
**Last updated:** [December 15, 2018, 11:47am UTC](https://discourse.processing.org/t/random-color-but-static/6623 "2018-12-15T11:47:29Z")

</div>

I am just beginner and I am doing little bit exercise with p5.js. So please bear with me if my code is such a mess. I made multiple gameboy with random flickering screen and now I want to make another random color for t…

---

## [\[SOLVED\] When Maximized, the 'background()' is slightly too large](https://discourse.processing.org/t/solved-when-maximized-the-background-is-slightly-too-large/6602)

<div class="topic-metadata">

**Author:** [@prcoy](https://discourse.processing.org/u/prcoy)\
**Replies:** 4\
**Last updated:** [December 14, 2018, 10:53pm UTC](https://discourse.processing.org/t/solved-when-maximized-the-background-is-slightly-too-large/6602 "2018-12-14T22:53:45Z")

</div>

I making a clock. I hope to make it a screen saver (someday). // Problem: When Maximized, the ‘background()’ is slightly too large for the // screen and I get unwanted scrollbars. // When in fullscreen, I get no scrol…

---

## [New coder- added background to flappy bird game now doesn't work](https://discourse.processing.org/t/new-coder-added-background-to-flappy-bird-game-now-doesnt-work/6552)

<div class="topic-metadata">

**Author:** [@ryan19](https://discourse.processing.org/u/ryan19)\
**Replies:** 3\
**Last updated:** [December 14, 2018, 1:46am UTC](https://discourse.processing.org/t/new-coder-added-background-to-flappy-bird-game-now-doesnt-work/6552 "2018-12-14T01:46:38Z")

</div>

Please help this is my original code and when the user claps the bird goes up and down: Once we added a background image as the background the code stopped working: PLEASE HELP //Good Code: var bird; var pipes = \[\]; …

---

## [Timing a class to reveal words](https://discourse.processing.org/t/timing-a-class-to-reveal-words/6556)

<div class="topic-metadata">

**Author:** [@jamiehamill](https://discourse.processing.org/u/jamiehamill)\
**Replies:** 2\
**Last updated:** [December 12, 2018, 11:48pm UTC](https://discourse.processing.org/t/timing-a-class-to-reveal-words/6556 "2018-12-12T23:48:55Z")

</div>

hey all! my question is likely to be super confusing as it’s difficult to explain and this is my first time using this forum, but I was wondering how I can time a class (that controls my text) to send out words slowly ov…

---

## [Translate p5js code to processing code?](https://discourse.processing.org/t/translate-p5js-code-to-processing-code/6505)

<div class="topic-metadata">

**Author:** [@Anaibuk](https://discourse.processing.org/u/Anaibuk)\
**Replies:** 8\
**Last updated:** [December 11, 2018, 11:49pm UTC](https://discourse.processing.org/t/translate-p5js-code-to-processing-code/6505 "2018-12-11T23:49:58Z")

</div>

Hello everyone, I’m just having a wild crash curse of processing (generative Design) at university. As we haven’t enough time, we are just learning to code with processing and not with p5js. Unfortunaly most of the exam…

---

## [Pixelgaps using scale on a 2D tile grid](https://discourse.processing.org/t/pixelgaps-using-scale-on-a-2d-tile-grid/6420)

<div class="topic-metadata">

**Author:** [@tony32](https://discourse.processing.org/u/tony32)\
**Replies:** 4\
**Last updated:** [December 8, 2018, 3:11pm UTC](https://discourse.processing.org/t/pixelgaps-using-scale-on-a-2d-tile-grid/6420 "2018-12-08T15:11:58Z")

</div>

Hey guys. I have an annoying issue on my project im working on. I’m generating a bunch of tiles, just with basic rects at a size of 32x32 pixels and putting them inside an array of arrays. Like Array\[0\]\[5\] would be ro…

---

## [Objects becoming children of other objects. How do I make them completely separate?](https://discourse.processing.org/t/objects-becoming-children-of-other-objects-how-do-i-make-them-completely-separate/6346)

<div class="topic-metadata">

**Author:** [@castaway](https://discourse.processing.org/u/castaway)\
**Replies:** 2\
**Last updated:** [December 6, 2018, 9:13pm UTC](https://discourse.processing.org/t/objects-becoming-children-of-other-objects-how-do-i-make-them-completely-separate/6346 "2018-12-06T21:13:29Z")

</div>

Greetings, I am trying to create a small animation where squares scale down at different speeds from different positions to eventually stop at a specific size and create a mosaic made of several squares. I wrote differe…

---

## [Load with loadStrings() a text file saved with saveStrings()?](https://discourse.processing.org/t/load-with-loadstrings-a-text-file-saved-with-savestrings/6009)

<div class="topic-metadata">

**Author:** [@Laurent](https://discourse.processing.org/u/Laurent)\
**Replies:** 11\
**Last updated:** [December 6, 2018, 8:42pm UTC](https://discourse.processing.org/t/load-with-loadstrings-a-text-file-saved-with-savestrings/6009 "2018-12-06T20:42:37Z")

</div>

Hi everyone. I’d like to write two demonstration codes for my students that makes the following operations: #1 save a list of strings into a text file with saveStrings() #2 open this text file and read/transfer the sav…

---

## [I'm trying to convert a fractal tree program from processing to p5js](https://discourse.processing.org/t/im-trying-to-convert-a-fractal-tree-program-from-processing-to-p5js/6336)

<div class="topic-metadata">

**Author:** [@Sunnylimenoid](https://discourse.processing.org/u/Sunnylimenoid)\
**Replies:** 3\
**Last updated:** [December 5, 2018, 10:55pm UTC](https://discourse.processing.org/t/im-trying-to-convert-a-fractal-tree-program-from-processing-to-p5js/6336 "2018-12-05T22:55:41Z")

</div>

Hello, I’m quite new to both processing and p5.js. I am experimenting with this demo on the processing site https://processing.org/examples/tree.html. I got it working in processing and want to publish it on my blog, but…

---

## [How do I load multiple JSON urls?](https://discourse.processing.org/t/how-do-i-load-multiple-json-urls/6150)

<div class="topic-metadata">

**Author:** [@salazarspanish](https://discourse.processing.org/u/salazarspanish)\
**Replies:** 15\
**Last updated:** [December 5, 2018, 6:45pm UTC](https://discourse.processing.org/t/how-do-i-load-multiple-json-urls/6150 "2018-12-05T18:45:47Z")

</div>

Hello! I was able to load one JSON url from Yahoo Weather, but now I am having trouble loading multiple urls. I tried searching my question on stack overflow, but the posts I found mentioned one JSON url, not several. Al…

---

## [Need help from converting this p5.js/JavaScript program to Processing](https://discourse.processing.org/t/need-help-from-converting-this-p5-js-javascript-program-to-processing/6287)

<div class="topic-metadata">

**Author:** [@charmypatel](https://discourse.processing.org/u/charmypatel)\
**Replies:** 5\
**Last updated:** [December 5, 2018, 2:20pm UTC](https://discourse.processing.org/t/need-help-from-converting-this-p5-js-javascript-program-to-processing/6287 "2018-12-05T14:20:58Z")

</div>

I want to do this same exact thing and needed help converting this p5.js program to processing code. I’m not sure how to do that. Any suggestions? Or if anyone knows where I can find a simpler fireworks example that I ca…

---

## [Script error. (: line 0)](https://discourse.processing.org/t/script-error-line-0/6294)

<div class="topic-metadata">

**Author:** [@billythemusical](https://discourse.processing.org/u/billythemusical)\
**Replies:** 3\
**Last updated:** [December 5, 2018, 7:32am UTC](https://discourse.processing.org/t/script-error-line-0/6294 "2018-12-05T07:32:16Z")

</div>

Hi - this sketch worked yesterday, and now I get: Script error. (: line 0) The sketch uses a web cam, FYI. I noticed Chrome has just updated today (Dec 4 2018) to “Version 71.0.3578.80 (Official Build) (64-bit)”. I a…

---

## [Pixel Array Will Not Work](https://discourse.processing.org/t/pixel-array-will-not-work/6295)

<div class="topic-metadata">

**Author:** [@bschofield](https://discourse.processing.org/u/bschofield)\
**Replies:** 2\
**Last updated:** [December 4, 2018, 8:21pm UTC](https://discourse.processing.org/t/pixel-array-will-not-work/6295 "2018-12-04T20:21:01Z")

</div>

We want this game to count the pixels of the red and the blue strokes to see who has more pixels at the end of the game and then display who wins. But for some reason we can only get it to say Blue Wins and it is now l…

---

## [Noise generation, aka clouds, is really slow and heavy](https://discourse.processing.org/t/noise-generation-aka-clouds-is-really-slow-and-heavy/6163)

<div class="topic-metadata">

**Author:** [@michelangelo](https://discourse.processing.org/u/michelangelo)\
**Replies:** 9\
**Last updated:** [December 3, 2018, 9:08pm UTC](https://discourse.processing.org/t/noise-generation-aka-clouds-is-really-slow-and-heavy/6163 "2018-12-03T21:08:17Z")

</div>

Hello there, I have been working on this small program that I would like to use as a fullscreen background. However, it already is really heavy. Is there a way to fix that in my code or I just have to think of another w…

---

## [Shift perspective on a 2D sketch? or if not posible, easily convert to 3D?](https://discourse.processing.org/t/shift-perspective-on-a-2d-sketch-or-if-not-posible-easily-convert-to-3d/5954)

<div class="topic-metadata">

**Author:** [@gio](https://discourse.processing.org/u/gio)\
**Replies:** 2\
**Last updated:** [December 2, 2018, 6:53pm UTC](https://discourse.processing.org/t/shift-perspective-on-a-2d-sketch-or-if-not-posible-easily-convert-to-3d/5954 "2018-12-02T18:53:35Z")

</div>

Hi, I got this 2s array grid of sliding circles: https://codepen.io/giorgiomartini/pen/MzGmwW?editors=0010 Its inspired by this poster: as u can see in the poster, it has perspecive… is there a way to tilt/shift …

---

## [Displaying effect unwanted](https://discourse.processing.org/t/displaying-effect-unwanted/6129)

<div class="topic-metadata">

**Author:** [@Pr0tonX](https://discourse.processing.org/u/Pr0tonX)\
**Replies:** 1\
**Last updated:** [December 1, 2018, 3:37pm UTC](https://discourse.processing.org/t/displaying-effect-unwanted/6129 "2018-12-01T15:37:26Z")

</div>

Hello, I’m trying to remake the concept of the Patatap of jonobr1 ( see https://www.patatap.com/) wich is pretty cool : 1 song 1 shape according to the song, launched by your keyboard. So I’m stuck on only one animatio…

---

## [Applying two forces to particles](https://discourse.processing.org/t/applying-two-forces-to-particles/6127)

<div class="topic-metadata">

**Author:** [@jmean](https://discourse.processing.org/u/jmean)\
**Replies:** 1\
**Last updated:** [December 1, 2018, 1:51am UTC](https://discourse.processing.org/t/applying-two-forces-to-particles/6127 "2018-12-01T01:51:31Z")

</div>

Hi, I’m writing a sketch where I want many small particles to be attracted to large central particle, this is working. However I also want all small particles to repel from each other at the same time. I’ve tried a co…

---

## [How can I make my game create a new ball and/or restart the code?](https://discourse.processing.org/t/how-can-i-make-my-game-create-a-new-ball-and-or-restart-the-code/6111)

<div class="topic-metadata">

**Author:** [@BLy](https://discourse.processing.org/u/BLy)\
**Replies:** 6\
**Last updated:** [December 1, 2018, 12:39am UTC](https://discourse.processing.org/t/how-can-i-make-my-game-create-a-new-ball-and-or-restart-the-code/6111 "2018-12-01T00:39:17Z")

</div>

I am currently trying to make it so when a button is clicked, it will create a new ball. I’m also trying to have another button that would completely restart the game. Can someone help me out please? My code is here: va…

---

## [How to create the code of the following video effect?](https://discourse.processing.org/t/how-to-create-the-code-of-the-following-video-effect/6113)

<div class="topic-metadata">

**Author:** [@Malvan](https://discourse.processing.org/u/Malvan)\
**Replies:** 1\
**Last updated:** [November 30, 2018, 4:11pm UTC](https://discourse.processing.org/t/how-to-create-the-code-of-the-following-video-effect/6113 "2018-11-30T16:11:13Z")

</div>

Hello there! I was searching through the internet to find anything useful regarding to one of my school projects. I want to create something like this: https://vimeo.com/8218843 The problem is, I don’t really know wher…

---

## [Breaking out of For Loop when mouse is depressed?](https://discourse.processing.org/t/breaking-out-of-for-loop-when-mouse-is-depressed/6071)

<div class="topic-metadata">

**Author:** [@DarkEco](https://discourse.processing.org/u/DarkEco)\
**Replies:** 2\
**Last updated:** [November 30, 2018, 1:20am UTC](https://discourse.processing.org/t/breaking-out-of-for-loop-when-mouse-is-depressed/6071 "2018-11-30T01:20:15Z")

</div>

Hi, i’m quite new to coding in general and having a really hard time with this. Currently my loop is running from 0-1000 in a single click, but i need it to break out of the loop when i let go of the mouse. I’m guessing …

---

## [Need help for a homework (should be ez for you )](https://discourse.processing.org/t/need-help-for-a-homework-should-be-ez-for-you/6082)

<div class="topic-metadata">

**Author:** [@Robin73](https://discourse.processing.org/u/Robin73)\
**Replies:** 9\
**Last updated:** [November 30, 2018, 1:26am UTC](https://discourse.processing.org/t/need-help-for-a-homework-should-be-ez-for-you/6082 "2018-11-30T01:26:55Z")

</div>

So i have to make spawn Random Howls with random abscissa, size, and grey shades. The problem is that they are spawning and they disappear and i don’t want them to disappear here’s the code. function setup(){ crea…

---

## [Gravity for 'mouse follow' function](https://discourse.processing.org/t/gravity-for-mouse-follow-function/6040)

<div class="topic-metadata">

**Author:** [@munr](https://discourse.processing.org/u/munr)\
**Replies:** 3\
**Last updated:** [November 29, 2018, 12:09am UTC](https://discourse.processing.org/t/gravity-for-mouse-follow-function/6040 "2018-11-29T00:09:22Z")

</div>

How might gravity be implemented for this drum beater so that it can swing and droop?: https://editor.p5js.org/munr/full/rkhA74j0Q var x = 100, y = 100, angle1 = 0.0, segLength = 45; function setup() { cre…

---

## [WEBGL pointLight issue with Graphics buffer](https://discourse.processing.org/t/webgl-pointlight-issue-with-graphics-buffer/5969)

<div class="topic-metadata">

**Author:** [@r4nd0m](https://discourse.processing.org/u/r4nd0m)\
**Replies:** 1\
**Last updated:** [November 27, 2018, 4:04pm UTC](https://discourse.processing.org/t/webgl-pointlight-issue-with-graphics-buffer/5969 "2018-11-27T16:04:57Z")

</div>

Hi, does anyone know why the light source in this example is not changing position? Thanks! let gl; let offsetX = 0; function setup() { createCanvas(400, 400); gl = createGraphics(100, 100, WEBGL); } function draw(…

---

## [Debugging dodgeball game: “Cannot read property ‘x’ of undefined” when hit](https://discourse.processing.org/t/debugging-dodgeball-game-cannot-read-property-x-of-undefined-when-hit/5962)

<div class="topic-metadata">

**Author:** [@shoneyjosh](https://discourse.processing.org/u/shoneyjosh)\
**Replies:** 2\
**Last updated:** [November 26, 2018, 6:05pm UTC](https://discourse.processing.org/t/debugging-dodgeball-game-cannot-read-property-x-of-undefined-when-hit/5962 "2018-11-26T18:05:58Z")

</div>

I made a game where you need to dodge the dodgeballs and it says “Cannot read property ‘x’ of undefined” whenever I get hit by an enemy. Any ideas? var player; var enemies = \[\]; var score = 0; var gameState; var lives =…

---

## [Is there a way to use createCapture in React?](https://discourse.processing.org/t/is-there-a-way-to-use-createcapture-in-react/5955)

<div class="topic-metadata">

**Author:** [@cristiano](https://discourse.processing.org/u/cristiano)\
**Replies:** 3\
**Last updated:** [November 26, 2018, 3:58pm UTC](https://discourse.processing.org/t/is-there-a-way-to-use-createcapture-in-react/5955 "2018-11-26T15:58:07Z")

</div>

I’m attempting to draw a video along with a few shapes using p5.js on a React app. I’ve noticed that p5.dom.js is not available for React and probably for good reason. This stopped me from using createCapture(VIDEO) so …

[Previous page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=48)

[Next page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=50)
