# Coding Questions

**URL:** https://discourse.processing.org/c/processing/processing-questions/15.md?page=40

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

**Page:** 41

---

## [I want to create a pattern where i have 4 different squares in different colours that directly change color as a code. This is what i have, but i dont know how to change the color of the sqaures and then turn them back to normal in one time. Please help](https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254)

<div class="topic-metadata">

**Author:** [@LeRonald](https://discourse.processing.org/u/LeRonald)\
**Replies:** 1\
**Last updated:** [November 2, 2021, 12:25pm UTC](https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254 "2021-11-02T12:25:27Z")

</div>

please format code with \</\> button \* homework policy \* asking questions int lastTimeCheck; int timeIntervalFlag = 3000; // 3 seconds because we are working with millis void setup() { size(500,500); background(0); …

---

## [Merging two sketches (for a school project)](https://discourse.processing.org/t/merging-two-sketches-for-a-school-project/33231)

<div class="topic-metadata">

**Author:** [@acb](https://discourse.processing.org/u/acb)\
**Replies:** 3\
**Last updated:** [November 2, 2021, 12:44pm UTC](https://discourse.processing.org/t/merging-two-sketches-for-a-school-project/33231 "2021-11-02T12:44:23Z")

</div>

I have been working on two codes that I would now like to have in the same frame, one over the other. I am asking for advice or just straight up the full solutions to merging these two codes. I have tried everything that…

---

## [How to have textbox only appear when boolean is true?](https://discourse.processing.org/t/how-to-have-textbox-only-appear-when-boolean-is-true/33235)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 0\
**Last updated:** [November 1, 2021, 9:10pm UTC](https://discourse.processing.org/t/how-to-have-textbox-only-appear-when-boolean-is-true/33235 "2021-11-01T21:10:21Z")

</div>

I want to make the textbox only appear when killb=true, how do i do this? static final int NUM = 2; final TextBox\[\] tboxes = new TextBox\[NUM\]; int idx; PImage shop; PImage settings; PImage teams; PImage kill; PImage…

---

## [Why is it not displaying my typed keys?](https://discourse.processing.org/t/why-is-it-not-displaying-my-typed-keys/33230)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 0\
**Last updated:** [November 1, 2021, 6:24pm UTC](https://discourse.processing.org/t/why-is-it-not-displaying-my-typed-keys/33230 "2021-11-01T18:24:39Z")

</div>

i would like text to show up in the rectangle that appears when kill is true, but it’s not working. why? PImage shop; PImage settings; PImage teams; PImage kill; PImage phone; PImage coin; PImage bounty; boolean invert…

---

## [Calling a PShape too many times](https://discourse.processing.org/t/calling-a-pshape-too-many-times/33209)

<div class="topic-metadata">

**Author:** [@bcabc](https://discourse.processing.org/u/bcabc)\
**Replies:** 1\
**Last updated:** [November 1, 2021, 5:58pm UTC](https://discourse.processing.org/t/calling-a-pshape-too-many-times/33209 "2021-11-01T17:58:57Z")

</div>

Hi there - I am calling PShape Shape1 within a for loop. for (Shape1 mod : mods) { mod.display(); I have set a value for an array of mods elsewhere in the code. mods = new Shape1\[count\*someother\]; My issue …

---

## [Movement to where I touch on the screen](https://discourse.processing.org/t/movement-to-where-i-touch-on-the-screen/33193)

<div class="topic-metadata">

**Author:** [@tati1202](https://discourse.processing.org/u/tati1202)\
**Replies:** 3\
**Last updated:** [November 1, 2021, 3:50pm UTC](https://discourse.processing.org/t/movement-to-where-i-touch-on-the-screen/33193 "2021-11-01T15:50:36Z")

</div>

Hey, I’m working in this videogame where you have to shoot the ball pressing in x place in the net/goal. Does anyone knows how to incorporate this with easy coding? Thanks

---

## [Array sorting of file paths](https://discourse.processing.org/t/array-sorting-of-file-paths/33096)

<div class="topic-metadata">

**Author:** [@garrettlynch](https://discourse.processing.org/u/garrettlynch)\
**Replies:** 8\
**Last updated:** [November 1, 2021, 10:17am UTC](https://discourse.processing.org/t/array-sorting-of-file-paths/33096 "2021-11-01T10:17:33Z")

</div>

I am creating an array from a directory of images using listFiles() and then sorting them like so. images = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { …

---

## [How to create a good fractal zoom?](https://discourse.processing.org/t/how-to-create-a-good-fractal-zoom/33217)

<div class="topic-metadata">

**Author:** [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Replies:** 0\
**Last updated:** [November 1, 2021, 9:29am UTC](https://discourse.processing.org/t/how-to-create-a-good-fractal-zoom/33217 "2021-11-01T09:29:30Z")

</div>

Hi! I created a mandelbrot set explorer, with which, you can zoom into the fractal if you use the mouse wheel. But I can’t seem to get the mouse wheel zoom working correctly. What can I do to fix it? Right now, both zo…

---

## [How to make more images appear over time?](https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 1\
**Last updated:** [October 31, 2021, 6:50pm UTC](https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194 "2021-10-31T18:50:40Z")

</div>

hey right now there is only one “trash” image but i’m trying to make it so the amount of “trash” images is equal to score+1 here’s my code: float trashX; float trashY; float boatX; float boatY; float ropelenght = 0; …

---

## [Light reflection](https://discourse.processing.org/t/light-reflection/33177)

<div class="topic-metadata">

**Author:** [@zack10](https://discourse.processing.org/u/zack10)\
**Replies:** 3\
**Last updated:** [October 30, 2021, 9:48pm UTC](https://discourse.processing.org/t/light-reflection/33177 "2021-10-30T21:48:25Z")

</div>

Hello i want to illuminate objects that are close to the sphere so when it’s dark i can see the object in the dark and also the objects which is close to it thank you

---

## [How to have image move in random directions](https://discourse.processing.org/t/how-to-have-image-move-in-random-directions/33176)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 0\
**Last updated:** [October 30, 2021, 3:15pm UTC](https://discourse.processing.org/t/how-to-have-image-move-in-random-directions/33176 "2021-10-30T15:15:12Z")

</div>

how do i make the “trash” image move in a random direction with 10 pixels per frame. (so randomly have trashX move either -10 or +10 pixels) float trashX; float trashY; float boatX; float boatY; float movingspeed = 10…

---

## [My Space Ship's Velocity is going whack](https://discourse.processing.org/t/my-space-ships-velocity-is-going-whack/33065)

<div class="topic-metadata">

**Author:** [@DividedRabbit](https://discourse.processing.org/u/DividedRabbit)\
**Replies:** 1\
**Last updated:** [October 30, 2021, 12:00am UTC](https://discourse.processing.org/t/my-space-ships-velocity-is-going-whack/33065 "2021-10-30T00:00:35Z")

</div>

Running this code is fine at first, but after a bit the velocity and gravity start moving to opposite extremes, but since they’re opposite they average out to the ship’s velocity. Eventually the ship starts acting weird …

---

## [flowField:Defining a vector from a table](https://discourse.processing.org/t/flowfield-defining-a-vector-from-a-table/33164)

<div class="topic-metadata">

**Author:** [@sigbjorn](https://discourse.processing.org/u/sigbjorn)\
**Replies:** 0\
**Last updated:** [October 29, 2021, 5:26pm UTC](https://discourse.processing.org/t/flowfield-defining-a-vector-from-a-table/33164 "2021-10-29T17:26:38Z")

</div>

Hi! I found a Perlin Noise code on Github which I would like to tweak for an art project at school. I would like to add an new Pvector forcefield which is based on a some x,y coordinates I have in a .csv file. I would …

---

## [User Type Input](https://discourse.processing.org/t/user-type-input/33101)

<div class="topic-metadata">

**Author:** [@Ethanation](https://discourse.processing.org/u/Ethanation)\
**Replies:** 1\
**Last updated:** [October 29, 2021, 8:35am UTC](https://discourse.processing.org/t/user-type-input/33101 "2021-10-29T08:35:23Z")

</div>

Hello, I am having trouble with this, when I press enter for the first screen, it switches to the next screen just fine. But I cannot type anything in on the second screen as I should be able to. //sets up all of the in…

---

## [Spawning PGraphics using 2D array](https://discourse.processing.org/t/spawning-pgraphics-using-2d-array/33087)

<div class="topic-metadata">

**Author:** [@Skycstls](https://discourse.processing.org/u/Skycstls)\
**Replies:** 0\
**Last updated:** [October 26, 2021, 1:14pm UTC](https://discourse.processing.org/t/spawning-pgraphics-using-2d-array/33087 "2021-10-26T13:14:41Z")

</div>

Hello Processing forum! I’ve been learning a lot of stuff using processing, its really fun and all errors and things i didnt understand were easy to find here in the forum or in the reference, today i wanted to start usi…

---

## [Getting message that y is not defined](https://discourse.processing.org/t/getting-message-that-y-is-not-defined/33028)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 6\
**Last updated:** [October 27, 2021, 7:24pm UTC](https://discourse.processing.org/t/getting-message-that-y-is-not-defined/33028 "2021-10-27T19:24:12Z")

</div>

class Drop { float x = random(0, width); float y = random(-100, -300); float ySpeed = 2; void fall() { y = y + ySpeed if (y \< height) { y = random(-100, -300); } } void show() { stroke(192, 225,…

---

## [Randomized lines on a grid - homework help - it's kinda due tonight](https://discourse.processing.org/t/randomized-lines-on-a-grid-homework-help-its-kinda-due-tonight/32964)

<div class="topic-metadata">

**Author:** [@Jamii](https://discourse.processing.org/u/Jamii)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 4:55pm UTC](https://discourse.processing.org/t/randomized-lines-on-a-grid-homework-help-its-kinda-due-tonight/32964 "2021-10-26T16:55:40Z")

</div>

Hi, I’m really new to processing and I need some help on an idea I don’t really know where to start at. What I have now is a grid, and I’ll make it not visible later, it just acts as a guideline. I want a vertical line…

---

## [Different pixel sizes in one image - radial small to big](https://discourse.processing.org/t/different-pixel-sizes-in-one-image-radial-small-to-big/33047)

<div class="topic-metadata">

**Author:** [@AntoniaVincenza](https://discourse.processing.org/u/AntoniaVincenza)\
**Replies:** 17\
**Last updated:** [October 26, 2021, 11:21am UTC](https://discourse.processing.org/t/different-pixel-sizes-in-one-image-radial-small-to-big/33047 "2021-10-26T11:21:55Z")

</div>

Hi! I would like to rasterize an image into pixels, but have struggles to find the right code for what I am looking for: I would like it to have a very high resolution in the middle and then kind of “fall apart” into bi…

---

## [Having trouble trying to implement bucket sort algorithm](https://discourse.processing.org/t/having-trouble-trying-to-implement-bucket-sort-algorithm/33066)

<div class="topic-metadata">

**Author:** [@systemCollapse](https://discourse.processing.org/u/systemCollapse)\
**Replies:** 2\
**Last updated:** [October 25, 2021, 7:34pm UTC](https://discourse.processing.org/t/having-trouble-trying-to-implement-bucket-sort-algorithm/33066 "2021-10-25T19:34:51Z")

</div>

Im trying to bucket sort an array and represent the sorting visually with processing functions. Found this bucket sort code to be rather common used in Java: import java.util.\*; import java.util.Collections; float\[\] ar…

---

## [Recreating the Photoshop Pen Tool in Processing](https://discourse.processing.org/t/recreating-the-photoshop-pen-tool-in-processing/33042)

<div class="topic-metadata">

**Author:** [@sebest\_design](https://discourse.processing.org/u/sebest_design)\
**Replies:** 2\
**Last updated:** [October 25, 2021, 2:50pm UTC](https://discourse.processing.org/t/recreating-the-photoshop-pen-tool-in-processing/33042 "2021-10-25T14:50:49Z")

</div>

Hello. I am working on a school project. I am supposed to create a Snapchat filter. I am trying to create something close to the pen tool with Processing 3. So far I have not been able to figure out how to use arrays al…

---

## [Define a startingpoint from a .png file in processing](https://discourse.processing.org/t/define-a-startingpoint-from-a-png-file-in-processing/32896)

<div class="topic-metadata">

**Author:** [@sigbjorn](https://discourse.processing.org/u/sigbjorn)\
**Replies:** 15\
**Last updated:** [October 22, 2021, 4:31pm UTC](https://discourse.processing.org/t/define-a-startingpoint-from-a-png-file-in-processing/32896 "2021-10-22T16:31:25Z")

</div>

Hi! Im have a .png file with a black graph on it. (just a single black line on a complete white background) I would like to define two starting points from stroke-functions amongst this line. one stroke function which …

---

## [BREAKOUT Project - Help with collision detection](https://discourse.processing.org/t/breakout-project-help-with-collision-detection/16546)

<div class="topic-metadata">

**Author:** [@dunkinsa](https://discourse.processing.org/u/dunkinsa)\
**Replies:** 27\
**Last updated:** [December 30, 2019, 9:56am UTC](https://discourse.processing.org/t/breakout-project-help-with-collision-detection/16546 "2019-12-30T09:56:22Z")

</div>

Hello everyone! I’m new to Processing and attempting to create a version of Breakout. I am nearing the end of my project but I didn’t find any good way/solution to make my bricks disappear when the ball hits them. I feel…

---

## [The get() function returns NullPointerException](https://discourse.processing.org/t/the-get-function-returns-nullpointerexception/33039)

<div class="topic-metadata">

**Author:** [@s31](https://discourse.processing.org/u/s31)\
**Replies:** 5\
**Last updated:** [October 24, 2021, 4:06pm UTC](https://discourse.processing.org/t/the-get-function-returns-nullpointerexception/33039 "2021-10-24T16:06:00Z")

</div>

Hello, I’ve been trying to use the get() function inside my sketch to get the colour of a pixel at a specific position. However, when I attempt to do this inside the sketch it returns NullPointerException, I think I’ve …

---

## [How to make another ball after a click](https://discourse.processing.org/t/how-to-make-another-ball-after-a-click/33038)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 5\
**Last updated:** [October 24, 2021, 1:06pm UTC](https://discourse.processing.org/t/how-to-make-another-ball-after-a-click/33038 "2021-10-24T13:06:26Z")

</div>

class Ball { float x = random(0, width); float y = 100; float ySpeed = 1; void move() { y += ySpeed } void show() { ellipse(x, y, 20, 20); } } Ball\[\] balls = new Ball \[1\]; void setup() { frameRate(60); si…

---

## [Collisions and arrays on Processing Java #2](https://discourse.processing.org/t/collisions-and-arrays-on-processing-java-2/33033)

<div class="topic-metadata">

**Author:** [@Locohogo12](https://discourse.processing.org/u/Locohogo12)\
**Replies:** 1\
**Last updated:** [October 24, 2021, 10:12am UTC](https://discourse.processing.org/t/collisions-and-arrays-on-processing-java-2/33033 "2021-10-24T10:12:44Z")

</div>

I’ve built my space game, but am unable to get my bullet to break my moon, not sure what to use in order to achieve this, tried everything!!!

---

## [Trying to do light refraction and reflection](https://discourse.processing.org/t/trying-to-do-light-refraction-and-reflection/33035)

<div class="topic-metadata">

**Author:** [@ceresnia](https://discourse.processing.org/u/ceresnia)\
**Replies:** 0\
**Last updated:** [October 24, 2021, 5:42am UTC](https://discourse.processing.org/t/trying-to-do-light-refraction-and-reflection/33035 "2021-10-24T05:42:34Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I am trying to do a light refraction simulation under the waves. I got the wave code so I can make wavey surface but I don’t know how to expre…

---

## [How to define custom planes in processing?](https://discourse.processing.org/t/how-to-define-custom-planes-in-processing/32918)

<div class="topic-metadata">

**Author:** [@SNICKRS](https://discourse.processing.org/u/SNICKRS)\
**Replies:** 5\
**Last updated:** [October 23, 2021, 1:00am UTC](https://discourse.processing.org/t/how-to-define-custom-planes-in-processing/32918 "2021-10-23T01:00:45Z")

</div>

I’m trying to recreate a kind of sphereical-planet like world, and when making the sky, I have to define sky and ground planes to change the sky and world colors. Using a PShape to represent the sky works, but it looks l…

---

## [Collisions and arrays on Processing Java](https://discourse.processing.org/t/collisions-and-arrays-on-processing-java/32986)

<div class="topic-metadata">

**Author:** [@Locohogo12](https://discourse.processing.org/u/Locohogo12)\
**Replies:** 4\
**Last updated:** [October 22, 2021, 11:17pm UTC](https://discourse.processing.org/t/collisions-and-arrays-on-processing-java/32986 "2021-10-22T23:17:09Z")

</div>

Need help with Collosions with moving objects, along with array backgrounds

---

## [Shader glow effect](https://discourse.processing.org/t/shader-glow-effect/33001)

<div class="topic-metadata">

**Author:** [@Dazzid](https://discourse.processing.org/u/Dazzid)\
**Replies:** 2\
**Last updated:** [October 22, 2021, 1:11pm UTC](https://discourse.processing.org/t/shader-glow-effect/33001 "2021-10-22T13:11:17Z")

</div>

I would like to add a glow effect using shaders but I’m confused about how to implement examples from other sources in Processing. I want to test this example GLSL Sandbox precision mediump float; varying vec2 surface…

---

## [Aliasing in flow-field PShapes ♒](https://discourse.processing.org/t/aliasing-in-flow-field-pshapes/32989)

<div class="topic-metadata">

**Author:** [@Simple\_de\_concombre](https://discourse.processing.org/u/Simple_de_concombre)\
**Replies:** 2\
**Last updated:** [October 22, 2021, 12:57pm UTC](https://discourse.processing.org/t/aliasing-in-flow-field-pshapes/32989 "2021-10-22T12:57:50Z")

</div>

Hi! I’m getting aliased lines when drawing my flow field. The SVG export looks fine. Tried quite a few things already, without success: smooth()-ing, different stroke weights, changing the Windows application scaling, …

[Previous page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=39)

[Next page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=41)
