# Coding Questions

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

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

**Page:** 60

---

## [My validation for my rogue-like dungeon generation has gone wrong?](https://discourse.processing.org/t/my-validation-for-my-rogue-like-dungeon-generation-has-gone-wrong/28505)

<div class="topic-metadata">

**Author:** [@ekay](https://discourse.processing.org/u/ekay)\
**Replies:** 2\
**Last updated:** [March 14, 2021, 10:31pm UTC](https://discourse.processing.org/t/my-validation-for-my-rogue-like-dungeon-generation-has-gone-wrong/28505 "2021-03-14T22:31:42Z")

</div>

Hi everyone! I am currently writing a piece of code which randomly generates a cluster of black squares on a grid of white squares, represented using a 2D array. Each number in my code corresponds to a different coloure…

---

## [Need help with slider](https://discourse.processing.org/t/need-help-with-slider/28512)

<div class="topic-metadata">

**Author:** [@Jemo](https://discourse.processing.org/u/Jemo)\
**Replies:** 2\
**Last updated:** [March 14, 2021, 6:25pm UTC](https://discourse.processing.org/t/need-help-with-slider/28512 "2021-03-14T18:25:29Z")

</div>

So I have a slider and it works and all but how do I get the output to be used as a variable? basically when I move the slider it supposed to change the angle of a force but its not working. thanks

---

## [How to show terrain and 3d grid](https://discourse.processing.org/t/how-to-show-terrain-and-3d-grid/28491)

<div class="topic-metadata">

**Author:** [@jafal](https://discourse.processing.org/u/jafal)\
**Replies:** 15\
**Last updated:** [March 14, 2021, 5:52pm UTC](https://discourse.processing.org/t/how-to-show-terrain-and-3d-grid/28491 "2021-03-14T17:52:32Z")

</div>

@Chrisir hi i need some help if you kind i want to add this 3d rects to this sketch int cols, rows; int scl = 26; int w = 2800; int h = 2600; boolean showImage = true; PImage img; void setup() { size(800, 8…

---

## [ArrayIndexOutOfBoundsException: 1024](https://discourse.processing.org/t/arrayindexoutofboundsexception-1024/28522)

<div class="topic-metadata">

**Author:** [@babatnvn](https://discourse.processing.org/u/babatnvn)\
**Replies:** 7\
**Last updated:** [March 14, 2021, 3:24pm UTC](https://discourse.processing.org/t/arrayindexoutofboundsexception-1024/28522 "2021-03-14T15:24:28Z")

</div>

Dear everyone; when I compile a code in the processing. it has an error like this picture. Please how to fix it. Many thanks.!

---

## [Please help me with move my ellipse](https://discourse.processing.org/t/please-help-me-with-move-my-ellipse/28526)

<div class="topic-metadata">

**Author:** [@olia](https://discourse.processing.org/u/olia)\
**Replies:** 6\
**Last updated:** [March 14, 2021, 1:37pm UTC](https://discourse.processing.org/t/please-help-me-with-move-my-ellipse/28526 "2021-03-14T13:37:28Z")

</div>

im not that good in english, sorry. so i have ellipse that moves from the center to the edges. I need it to move back to the center when I click the mouse int rad = 40; // Width of the shape float xpos, ypos; …

---

## [How to zoom into an image (but at a certain point) with scale](https://discourse.processing.org/t/how-to-zoom-into-an-image-but-at-a-certain-point-with-scale/28510)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 2\
**Last updated:** [March 13, 2021, 9:29pm UTC](https://discourse.processing.org/t/how-to-zoom-into-an-image-but-at-a-certain-point-with-scale/28510 "2021-03-13T21:29:10Z")

</div>

Hello all, I have a question: I want to animate the zoom into an image, but not into its center, but into a certain area of the image (e.g. a dog or cat (or where I click the mouse) on a much bigger image). I use scal…

---

## [How to clone Object without modifying original?](https://discourse.processing.org/t/how-to-clone-object-without-modifying-original/28496)

<div class="topic-metadata">

**Author:** [@EinsMalteHH](https://discourse.processing.org/u/EinsMalteHH)\
**Replies:** 3\
**Last updated:** [March 13, 2021, 8:41pm UTC](https://discourse.processing.org/t/how-to-clone-object-without-modifying-original/28496 "2021-03-13T20:41:16Z")

</div>

I have an array of a class, that I want to clone. But if I modify the clone, the original gets modified to. Now is the question, how can i clone an array of classes without it modifying the original?

---

## [Find the number of elements in a single row](https://discourse.processing.org/t/find-the-number-of-elements-in-a-single-row/28487)

<div class="topic-metadata">

**Author:** [@Criste44](https://discourse.processing.org/u/Criste44)\
**Replies:** 7\
**Last updated:** [March 13, 2021, 4:50pm UTC](https://discourse.processing.org/t/find-the-number-of-elements-in-a-single-row/28487 "2021-03-13T16:50:38Z")

</div>

hello … \[8, 8\] I have a two dimensional array, while the game is going on I want to find out how many objects are in a single line … not the whole array, just one line, example \[i, 7\] …

---

## [How to add values to array based on condition? (read two files)](https://discourse.processing.org/t/how-to-add-values-to-array-based-on-condition-read-two-files/28340)

<div class="topic-metadata">

**Author:** [@tea\_tree](https://discourse.processing.org/u/tea_tree)\
**Replies:** 12\
**Last updated:** [March 13, 2021, 4:35pm UTC](https://discourse.processing.org/t/how-to-add-values-to-array-based-on-condition-read-two-files/28340 "2021-03-13T16:35:41Z")

</div>

I have data from two csv files that I import as Tables. The first file contains country names and their population. The second file contains migration flows between countries over 4 time periods. The files would look lik…

---

## [Handling color in eclipse with processing](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [March 13, 2021, 3:20pm UTC](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497 "2021-03-13T15:20:22Z")

</div>

Hi guys I’m hoping you can help please I’m a bit stuck. When trying to convert my code to a library I ran into the following problem, color is not recognised as a data type. I have found the following posts online aski…

---

## [Text in mousePressed() flashing (using text())](https://discourse.processing.org/t/text-in-mousepressed-flashing-using-text/28479)

<div class="topic-metadata">

**Author:** [@emmarope](https://discourse.processing.org/u/emmarope)\
**Replies:** 3\
**Last updated:** [March 12, 2021, 11:17pm UTC](https://discourse.processing.org/t/text-in-mousepressed-flashing-using-text/28479 "2021-03-12T23:17:57Z")

</div>

I want the coordinates in the string to change every time the mouse is clicked, but they flash by too quickly to read and I am not sure how to fix, code is below: PImage cityscape, landscape, sky, moon; String \[\] coord…

---

## [Painting a canvas](https://discourse.processing.org/t/painting-a-canvas/28273)

<div class="topic-metadata">

**Author:** [@Apollo](https://discourse.processing.org/u/Apollo)\
**Replies:** 9\
**Last updated:** [March 12, 2021, 8:31am UTC](https://discourse.processing.org/t/painting-a-canvas/28273 "2021-03-12T08:31:13Z")

</div>

Hi! I hope you could help me here. (@CodeMasterX , I’m mentioning you cause you’ve helped me before.) The code should create a 500x500 canvas and fills it in with a solid color (try maroon) using a 25px brush in 20 sec…

---

## [Automatic line break (text() command)](https://discourse.processing.org/t/automatic-line-break-text-command/27302)

<div class="topic-metadata">

**Author:** [@Sophie](https://discourse.processing.org/u/Sophie)\
**Replies:** 1\
**Last updated:** [January 23, 2021, 2:35pm UTC](https://discourse.processing.org/t/automatic-line-break-text-command/27302 "2021-01-23T14:35:31Z")

</div>

Hello, My code draws lines to the screen, each line in a random size in a single frame. But some lines are too long. I have to split them, but not to another frame and another random size. It should still remain in the …

---

## [Different x starting position of text](https://discourse.processing.org/t/different-x-starting-position-of-text/27308)

<div class="topic-metadata">

**Author:** [@Ida](https://discourse.processing.org/u/Ida)\
**Replies:** 3\
**Last updated:** [January 23, 2021, 5:50pm UTC](https://discourse.processing.org/t/different-x-starting-position-of-text/27308 "2021-01-23T17:50:40Z")

</div>

Hey, My code draws a text line by line to the screen in different sizes, but the lines seem to start at a different x position according to the text size. Also the first line begins at a different x position. Could some…

---

## [Drawing an PGraphic inside of a PGraphic, but image does not update itself](https://discourse.processing.org/t/drawing-an-pgraphic-inside-of-a-pgraphic-but-image-does-not-update-itself/28349)

<div class="topic-metadata">

**Author:** [@AlexAlex](https://discourse.processing.org/u/AlexAlex)\
**Replies:** 3\
**Last updated:** [March 10, 2021, 8:13am UTC](https://discourse.processing.org/t/drawing-an-pgraphic-inside-of-a-pgraphic-but-image-does-not-update-itself/28349 "2021-03-10T08:13:04Z")

</div>

Hello everyone, I have been trying to achieve something like boolean operation - difference. So that whenever the text, that is moving horizontally, is covered by the text, that is moving vertically, its pixels in the o…

---

## [Help with snake game](https://discourse.processing.org/t/help-with-snake-game/28328)

<div class="topic-metadata">

**Author:** [@NewProgrammer123](https://discourse.processing.org/u/NewProgrammer123)\
**Replies:** 4\
**Last updated:** [March 10, 2021, 7:56am UTC](https://discourse.processing.org/t/help-with-snake-game/28328 "2021-03-10T07:56:44Z")

</div>

Hello, I am new to programming and I’m trying to create the snake game. I have been able to create the food and the snake with some help from google but I cant seem to get the snake to move. Any help or tips would be gre…

---

## ['Nature of Code' Chapter 2 Query](https://discourse.processing.org/t/nature-of-code-chapter-2-query/28353)

<div class="topic-metadata">

**Author:** [@scolty2021](https://discourse.processing.org/u/scolty2021)\
**Replies:** 6\
**Last updated:** [March 9, 2021, 9:58pm UTC](https://discourse.processing.org/t/nature-of-code-chapter-2-query/28353 "2021-03-09T21:58:23Z")

</div>

Hi, Thanks for taking the trouble to click on this Topic. I’m currently working my way thru Daniel Shiffman’s Learning Processing & the Nature of Code books, and have the following query about a section in the latter, …

---

## [Can someone help me with this game? (image order)](https://discourse.processing.org/t/can-someone-help-me-with-this-game-image-order/28147)

<div class="topic-metadata">

**Author:** [@cocopuffs](https://discourse.processing.org/u/cocopuffs)\
**Replies:** 30\
**Last updated:** [March 9, 2021, 2:11pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-game-image-order/28147 "2021-03-09T14:11:27Z")

</div>

So I’m trying to make a game where processing shuffles the 4 images, and the player just has to click the correct image in a certain order to win. Very simple game, nothing fancy or complicated, just trying to practice s…

---

## [Do you know how to modify this?](https://discourse.processing.org/t/do-you-know-how-to-modify-this/28323)

<div class="topic-metadata">

**Author:** [@Apollo](https://discourse.processing.org/u/Apollo)\
**Replies:** 5\
**Last updated:** [March 9, 2021, 7:46am UTC](https://discourse.processing.org/t/do-you-know-how-to-modify-this/28323 "2021-03-09T07:46:14Z")

</div>

Good day/morning/evening/afternoon! So I got his code which I wanna utilize for another task: void setup() { size(800,400); } void draw() { loadPixels(); int w = width/2, h = height; for(float j = 0; j \< w; j++) …

---

## [Funky curveVertx results](https://discourse.processing.org/t/funky-curvevertx-results/28317)

<div class="topic-metadata">

**Author:** [@travis.stdenis](https://discourse.processing.org/u/travis.stdenis)\
**Replies:** 4\
**Last updated:** [March 8, 2021, 10:48pm UTC](https://discourse.processing.org/t/funky-curvevertx-results/28317 "2021-03-08T22:48:18Z")

</div>

I’m drawing a series of lines that diverge in the middle of the screen using a gaussian function (getGaussian below). Usually this is fine as you can see in theis picture (only two lines here to see the issue. The pro…

---

## [Why isn't the ellipse displaying?](https://discourse.processing.org/t/why-isnt-the-ellipse-displaying/28341)

<div class="topic-metadata">

**Author:** [@psn](https://discourse.processing.org/u/psn)\
**Replies:** 1\
**Last updated:** [March 8, 2021, 3:58pm UTC](https://discourse.processing.org/t/why-isnt-the-ellipse-displaying/28341 "2021-03-08T15:58:32Z")

</div>

Title is pretty self-explanatory, i need help to see what’s wrong with my code. Any help is appreciated, thanks! class Ellipse { int x; int y; int w; int h; int c; Ellipse(int inputX, int inputY, int inputWi…

---

## [Select random element from list](https://discourse.processing.org/t/select-random-element-from-list/28178)

<div class="topic-metadata">

**Author:** [@Criste44](https://discourse.processing.org/u/Criste44)\
**Replies:** 6\
**Last updated:** [March 2, 2021, 10:30am UTC](https://discourse.processing.org/t/select-random-element-from-list/28178 "2021-03-02T10:30:28Z")

</div>

I want to select a random element from a list and make an if operation on the selected item. Can I do them in void awake or void start?

---

## [I need help for a code please](https://discourse.processing.org/t/i-need-help-for-a-code-please/28314)

<div class="topic-metadata">

**Author:** [@KIRA](https://discourse.processing.org/u/KIRA)\
**Replies:** 2\
**Last updated:** [March 7, 2021, 8:32pm UTC](https://discourse.processing.org/t/i-need-help-for-a-code-please/28314 "2021-03-07T20:32:59Z")

</div>

Hello i have to do a game on processing, This game is an aim trainer with circles and when we click on them, other spawn… The game must have 3 levels of difficulty and a point counter. If the circles can have differen…

---

## [Having trouble undoing a camera() transformation](https://discourse.processing.org/t/having-trouble-undoing-a-camera-transformation/28293)

<div class="topic-metadata">

**Author:** [@Sethran](https://discourse.processing.org/u/Sethran)\
**Replies:** 5\
**Last updated:** [March 7, 2021, 7:08pm UTC](https://discourse.processing.org/t/having-trouble-undoing-a-camera-transformation/28293 "2021-03-07T19:08:27Z")

</div>

hi, I’ve tried searching for a solution online but I wasn’t able to find one I could understand. I’m kinda new to coding in general. This is what I’ve got so far; //make varuables PVector offset = new PVector(width/…

---

## [Problem with drawing a Pythagoras Tree using L-system](https://discourse.processing.org/t/problem-with-drawing-a-pythagoras-tree-using-l-system/28270)

<div class="topic-metadata">

**Author:** [@Esther](https://discourse.processing.org/u/Esther)\
**Replies:** 3\
**Last updated:** [March 6, 2021, 10:53am UTC](https://discourse.processing.org/t/problem-with-drawing-a-pythagoras-tree-using-l-system/28270 "2021-03-06T10:53:42Z")

</div>

Hi, I am drawing a Pythagoras Tree using L-system and 2 production rules. I managed to use the first rule called “F-rule” to draw the right handside of the tree. I tried using the second rule “H-rule” to draw the left ha…

---

## [ChildPApplet and closing when not disposed](https://discourse.processing.org/t/childpapplet-and-closing-when-not-disposed/28277)

<div class="topic-metadata">

**Author:** [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Replies:** 0\
**Last updated:** [March 5, 2021, 8:54am UTC](https://discourse.processing.org/t/childpapplet-and-closing-when-not-disposed/28277 "2021-03-05T08:54:15Z")

</div>

Hi all, I am trying to do a simple user interface on processing and I am running into a problem when closing a PApplet. The main window is able to create/reopen and close the second window without problems and disposes…

---

## [Grab mouse using OpenGL](https://discourse.processing.org/t/grab-mouse-using-opengl/28259)

<div class="topic-metadata">

**Author:** [@yeppii](https://discourse.processing.org/u/yeppii)\
**Replies:** 11\
**Last updated:** [March 4, 2021, 5:29pm UTC](https://discourse.processing.org/t/grab-mouse-using-opengl/28259 "2021-03-04T17:29:49Z")

</div>

I am making a game and I want to grab the mouse using OpenGL. How could I do this?

---

## [Structural diagrams for processing code](https://discourse.processing.org/t/structural-diagrams-for-processing-code/28253)

<div class="topic-metadata">

**Author:** [@kalle](https://discourse.processing.org/u/kalle)\
**Replies:** 0\
**Last updated:** [March 4, 2021, 11:12am UTC](https://discourse.processing.org/t/structural-diagrams-for-processing-code/28253 "2021-03-04T11:12:40Z")

</div>

Processing is now an interesting alternative to other programming languages at many universities in courses. As far as algorithms are concerned different graphical representations are used: UML, flow charts, structure …

---

## [Get location of a PApplet window](https://discourse.processing.org/t/get-location-of-a-papplet-window/28039)

<div class="topic-metadata">

**Author:** [@yeppii](https://discourse.processing.org/u/yeppii)\
**Replies:** 11\
**Last updated:** [March 4, 2021, 10:40am UTC](https://discourse.processing.org/t/get-location-of-a-papplet-window/28039 "2021-03-04T10:40:00Z")

</div>

How can I get the location of a PApplet window?

---

## [Dynamite screen clear game](https://discourse.processing.org/t/dynamite-screen-clear-game/28241)

<div class="topic-metadata">

**Author:** [@boomstick55](https://discourse.processing.org/u/boomstick55)\
**Replies:** 2\
**Last updated:** [March 4, 2021, 9:56am UTC](https://discourse.processing.org/t/dynamite-screen-clear-game/28241 "2021-03-04T09:56:17Z")

</div>

Im trying to simulate a player pushing down ignition for dynamite to explode and clear the screen of bad guys but I cant figure out how to detect the rect reaching a certain point of the screen to clear it here’s my cod…

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

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