# Coding Questions

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

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

**Page:** 92

---

## [Easy question from new user! +Parallel lines drawing](https://discourse.processing.org/t/easy-question-from-new-user-parallel-lines-drawing/21464)

<div class="topic-metadata">

**Author:** [@Ateroma](https://discourse.processing.org/u/Ateroma)\
**Replies:** 1\
**Last updated:** [June 1, 2020, 6:23pm UTC](https://discourse.processing.org/t/easy-question-from-new-user-parallel-lines-drawing/21464 "2020-06-01T18:23:18Z")

</div>

Hello! I’m new here and I just found this incredible software during the quarantine. I’m reading the Processing: A Programming Handbook for Visual Designers and Artists book for learning, but I remained stuck while try…

---

## [Random words from text file - how to avoid duplicate index numbers?](https://discourse.processing.org/t/random-words-from-text-file-how-to-avoid-duplicate-index-numbers/21456)

<div class="topic-metadata">

**Author:** [@Jonathan\_2](https://discourse.processing.org/u/Jonathan_2)\
**Replies:** 5\
**Last updated:** [June 1, 2020, 3:14pm UTC](https://discourse.processing.org/t/random-words-from-text-file-how-to-avoid-duplicate-index-numbers/21456 "2020-06-01T15:14:04Z")

</div>

Hey. I am quite new to processing so excuse me if my explanation of this is in the wrong terms or if things are slightly misunderstood. I am working on a code that write random words from a text on the screen every tim…

---

## [What causes a graphical sketch to start glitching out?](https://discourse.processing.org/t/what-causes-a-graphical-sketch-to-start-glitching-out/21458)

<div class="topic-metadata">

**Author:** [@BennyHacker](https://discourse.processing.org/u/BennyHacker)\
**Replies:** 3\
**Last updated:** [May 31, 2020, 7:20pm UTC](https://discourse.processing.org/t/what-causes-a-graphical-sketch-to-start-glitching-out/21458 "2020-05-31T19:20:39Z")

</div>

Hey forum, sometimes when I’m working on a particularly graphics oriented sketch it will all of a sudden start to behave very strange with no apparent cause. Has this ever happened to anyone else? I have a sketch that’s…

---

## [How to make repeating 3D ball on Y-coordinate?](https://discourse.processing.org/t/how-to-make-repeating-3d-ball-on-y-coordinate/21435)

<div class="topic-metadata">

**Author:** [@processingart](https://discourse.processing.org/u/processingart)\
**Replies:** 4\
**Last updated:** [May 31, 2020, 12:23pm UTC](https://discourse.processing.org/t/how-to-make-repeating-3d-ball-on-y-coordinate/21435 "2020-05-31T12:23:51Z")

</div>

Hello, I was making an animation on processing. Then, I confused about on a problem. I prepare a simple code for you. Also, I think the question can helpfull for beginners. :revolving\_hearts: :smiling\_face\_with\_three\_hea…

---

## [Help with space bar movement of ellipses](https://discourse.processing.org/t/help-with-space-bar-movement-of-ellipses/21428)

<div class="topic-metadata">

**Author:** [@s6277](https://discourse.processing.org/u/s6277)\
**Replies:** 5\
**Last updated:** [May 31, 2020, 11:51am UTC](https://discourse.processing.org/t/help-with-space-bar-movement-of-ellipses/21428 "2020-05-31T11:51:20Z")

</div>

Hi, im new to processing and i was wondering if anyone could help me out me in this task. I want to move an ellipse up and down, and basically every time i press the space bar the previous ellipse stops on its spot and a…

---

## [Using JNI to talk to C struct](https://discourse.processing.org/t/using-jni-to-talk-to-c-struct/21381)

<div class="topic-metadata">

**Author:** [@HackinHarry](https://discourse.processing.org/u/HackinHarry)\
**Replies:** 2\
**Last updated:** [May 31, 2020, 3:18am UTC](https://discourse.processing.org/t/using-jni-to-talk-to-c-struct/21381 "2020-05-31T03:18:16Z")

</div>

I barely understand what a struct is other than sorta like a class in java. I want to use processing and java to provide the input and then get the result back to java. I went to this link and found some code I want to…

---

## [Having proplems with string arrays](https://discourse.processing.org/t/having-proplems-with-string-arrays/21436)

<div class="topic-metadata">

**Author:** [@AntiViral\_Builder](https://discourse.processing.org/u/AntiViral_Builder)\
**Replies:** 1\
**Last updated:** [May 30, 2020, 10:13pm UTC](https://discourse.processing.org/t/having-proplems-with-string-arrays/21436 "2020-05-30T22:13:47Z")

</div>

I set my array to a size 1000000 and initialized its contents with: (int I=0;i\<1000000;i++) mytext\[I\] =" "; so why when I use something like: rec\[I\] = mytext\[I\]; to get a temporary instance of the mytext\[I\] that the …

---

## [Wall isn't working](https://discourse.processing.org/t/wall-isnt-working/21399)

<div class="topic-metadata">

**Author:** [@till](https://discourse.processing.org/u/till)\
**Replies:** 4\
**Last updated:** [May 29, 2020, 4:25pm UTC](https://discourse.processing.org/t/wall-isnt-working/21399 "2020-05-29T16:25:23Z")

</div>

float spieler\_x; float spieler\_y; float ball\_x; float ball\_y; float ball\_speed\_x; float ball\_speed\_y; int runde; void setup(){ spieler\_x = 20; spieler\_y = 20; //\*\*Ball starting position\*\* ball\_x = 500; …

---

## [How can i combine a random made background with a moving Object without redrawing?](https://discourse.processing.org/t/how-can-i-combine-a-random-made-background-with-a-moving-object-without-redrawing/21395)

<div class="topic-metadata">

**Author:** [@JohnQED](https://discourse.processing.org/u/JohnQED)\
**Replies:** 3\
**Last updated:** [May 29, 2020, 3:21pm UTC](https://discourse.processing.org/t/how-can-i-combine-a-random-made-background-with-a-moving-object-without-redrawing/21395 "2020-05-29T15:21:23Z")

</div>

Hello i am trying to make a starsky where i generate the background and the positions of the stars randomly. I now want to make some fallen stars currently trying todo it with arrays. The problem is that it always redr…

---

## [Simple Assembly](https://discourse.processing.org/t/simple-assembly/21330)

<div class="topic-metadata">

**Author:** [@AntiViral\_Builder](https://discourse.processing.org/u/AntiViral_Builder)\
**Replies:** 2\
**Last updated:** [May 29, 2020, 5:45am UTC](https://discourse.processing.org/t/simple-assembly/21330 "2020-05-29T05:45:37Z")

</div>

\*\*Hello There, I just need a simple way to install assembly code in certain routines as long as Processing puts its variables in it’s Stack I am good 2 go I really don’t need a lot of stuff just to read and write to mem…

---

## [Stacker game: how do I loop the rectangles](https://discourse.processing.org/t/stacker-game-how-do-i-loop-the-rectangles/21341)

<div class="topic-metadata">

**Author:** [@justkayy](https://discourse.processing.org/u/justkayy)\
**Replies:** 2\
**Last updated:** [May 29, 2020, 4:49am UTC](https://discourse.processing.org/t/stacker-game-how-do-i-loop-the-rectangles/21341 "2020-05-29T04:49:09Z")

</div>

So the aim is to: Add a background for the game in the form of a grid. The grid “cell” must be 90 pixels in size in both dimensions when the screen is 1280x720. Note: Do not draw your grid with rectangles or squares, dr…

---

## [Failing to follow cursor](https://discourse.processing.org/t/failing-to-follow-cursor/21370)

<div class="topic-metadata">

**Author:** [@vtr](https://discourse.processing.org/u/vtr)\
**Replies:** 1\
**Last updated:** [May 28, 2020, 7:53pm UTC](https://discourse.processing.org/t/failing-to-follow-cursor/21370 "2020-05-28T19:53:45Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi all, I am a newbie. I was trying to create a trapezoid that follows the cursor. Yet, I failed. I have given it many tries but it seems that …

---

## [Easy animation (rookie question)](https://discourse.processing.org/t/easy-animation-rookie-question/21379)

<div class="topic-metadata">

**Author:** [@Jack\_LK](https://discourse.processing.org/u/Jack_LK)\
**Replies:** 1\
**Last updated:** [May 28, 2020, 5:41pm UTC](https://discourse.processing.org/t/easy-animation-rookie-question/21379 "2020-05-28T17:41:50Z")

</div>

Hey guys, I’m a very rookie at processing and something come up that I can not solve. I want to move a rect() pixel by pixel from left to right if the key ‘x’ is pressed. My code looks like this so far: color cl; floa…

---

## [Camera distance to 3D points in parallel projection](https://discourse.processing.org/t/camera-distance-to-3d-points-in-parallel-projection/21312)

<div class="topic-metadata">

**Author:** [@recurs](https://discourse.processing.org/u/recurs)\
**Replies:** 5\
**Last updated:** [May 28, 2020, 3:20pm UTC](https://discourse.processing.org/t/camera-distance-to-3d-points-in-parallel-projection/21312 "2020-05-28T15:20:55Z")

</div>

I have a central function that I use to project 3D {x, y, z} coordinates onto a 2D picture plane. For a number of reasons, I can’t use any of Processing’s 3D functionality for what I’m doing. I’m hoping to find a way to…

---

## [Loops and object movement](https://discourse.processing.org/t/loops-and-object-movement/20384)

<div class="topic-metadata">

**Author:** [@s6277](https://discourse.processing.org/u/s6277)\
**Replies:** 6\
**Last updated:** [May 28, 2020, 10:12am UTC](https://discourse.processing.org/t/loops-and-object-movement/20384 "2020-05-28T10:12:18Z")

</div>

Hey, i’m very confused as to why my rectangle is not moving, I’ve tried everything and i still don’t get it. So i have created four rectangles going in a linear line one under each other, using the for loop. I want to be…

---

## [Shape Drawing Guidance - how to draw symmetric filled curves?](https://discourse.processing.org/t/shape-drawing-guidance-how-to-draw-symmetric-filled-curves/21352)

<div class="topic-metadata">

**Author:** [@rkk16](https://discourse.processing.org/u/rkk16)\
**Replies:** 1\
**Last updated:** [May 27, 2020, 11:09pm UTC](https://discourse.processing.org/t/shape-drawing-guidance-how-to-draw-symmetric-filled-curves/21352 "2020-05-27T23:09:55Z")

</div>

Hey guys, I’ve used a curve vertex tool to draw these eye lids on top of a sphere but they turn out pretty asymmetric since usually you need to define points on either side as ‘training’/‘direction’ points to get symme…

---

## [P3D - Sphere translation without deforming?](https://discourse.processing.org/t/p3d-sphere-translation-without-deforming/21349)

<div class="topic-metadata">

**Author:** [@rkk16](https://discourse.processing.org/u/rkk16)\
**Replies:** 5\
**Last updated:** [May 27, 2020, 6:54pm UTC](https://discourse.processing.org/t/p3d-sphere-translation-without-deforming/21349 "2020-05-27T18:54:56Z")

</div>

Hi! Thanks for all the help so far, this platform has been extremely supportive. I’m creating a 3D sphere but everytime i translate it, it also seems to rotate/deform, why is this the case? Is there an easy fix or do I n…

---

## [(Noob question) why doesn't this line of code work?](https://discourse.processing.org/t/noob-question-why-doesnt-this-line-of-code-work/21284)

<div class="topic-metadata">

**Author:** [@BennyHacker](https://discourse.processing.org/u/BennyHacker)\
**Replies:** 15\
**Last updated:** [May 27, 2020, 5:46pm UTC](https://discourse.processing.org/t/noob-question-why-doesnt-this-line-of-code-work/21284 "2020-05-27T17:46:18Z")

</div>

Consider the ArrayList(PVector) “p”. Now let’s say I’m trying to set a vector in that list p.get(i)=p.get(i+1).copy(); When I write this it says “left hand of assignment must be variable”. How do I get around this? E…

---

## [Problem with bouncing numbers](https://discourse.processing.org/t/problem-with-bouncing-numbers/21098)

<div class="topic-metadata">

**Author:** [@kukukoks](https://discourse.processing.org/u/kukukoks)\
**Replies:** 4\
**Last updated:** [May 27, 2020, 10:41am UTC](https://discourse.processing.org/t/problem-with-bouncing-numbers/21098 "2020-05-27T10:41:56Z")

</div>

Hi need help with this. I have 6 png and all of them load to program and they count from 0 to 5. What to do after that count down from 5 to 0, i mean 0,1,2,3,4,5,4,3,2,1,0 PImage\[\] zdjecia=new PImage\[6\]; int i=0; void …

---

## [Rettangoli colori](https://discourse.processing.org/t/rettangoli-colori/21308)

<div class="topic-metadata">

**Author:** [@marika20](https://discourse.processing.org/u/marika20)\
**Replies:** 1\
**Last updated:** [May 26, 2020, 4:40pm UTC](https://discourse.processing.org/t/rettangoli-colori/21308 "2020-05-26T16:40:48Z")

</div>

Sto cercando di capire come mai non riesco ad inserire i miei valori float iniziali all’interno dei mie rect(). int PuntoZero = 0; float x = 300; float y1 = 300; float y2 = 500; int w = 600; int h = 600; float latoGiall…

---

## [Explanation for the algorithm behind this generative art piece](https://discourse.processing.org/t/explanation-for-the-algorithm-behind-this-generative-art-piece/21108)

<div class="topic-metadata">

**Author:** [@the0ne](https://discourse.processing.org/u/the0ne)\
**Replies:** 6\
**Last updated:** [May 26, 2020, 9:11am UTC](https://discourse.processing.org/t/explanation-for-the-algorithm-behind-this-generative-art-piece/21108 "2020-05-26T09:11:13Z")

</div>

I recently came across this beautiful generative art piece, ’Trunk’ by Kjetil Golid (source code). I went through the code and understand what’s being done, yet I’m unable to grasp why the algorithm works the way it doe…

---

## [Switch the array places in a loop](https://discourse.processing.org/t/switch-the-array-places-in-a-loop/21084)

<div class="topic-metadata">

**Author:** [@gurki](https://discourse.processing.org/u/gurki)\
**Replies:** 12\
**Last updated:** [May 25, 2020, 11:09pm UTC](https://discourse.processing.org/t/switch-the-array-places-in-a-loop/21084 "2020-05-25T23:09:23Z")

</div>

Hello Together, I have an important question. I have a task where I need your help. this is the question. Given! Be! Two! Equal! Long! Arrays:! int\[\] a = {1,2,3,4}; int\[\] b = {10, 20, 30, 40}; Create a new array c th…

---

## [I want to change the size of each class](https://discourse.processing.org/t/i-want-to-change-the-size-of-each-class/21205)

<div class="topic-metadata">

**Author:** [@yeon](https://discourse.processing.org/u/yeon)\
**Replies:** 4\
**Last updated:** [May 25, 2020, 8:39pm UTC](https://discourse.processing.org/t/i-want-to-change-the-size-of-each-class/21205 "2020-05-25T20:39:55Z")

</div>

I’m making a game with processing. I want to change the size of each class. What should I do?

---

## [Creating a temperature simulation](https://discourse.processing.org/t/creating-a-temperature-simulation/21183)

<div class="topic-metadata">

**Author:** [@abc123](https://discourse.processing.org/u/abc123)\
**Replies:** 13\
**Last updated:** [May 25, 2020, 8:06pm UTC](https://discourse.processing.org/t/creating-a-temperature-simulation/21183 "2020-05-25T20:06:34Z")

</div>

I’m trying to creating a temperature simulation. I’m loading a picture of a room, and I want to add an arrow showing the temperature. The temperature should increase when a certain key is pressed. I’m wondering how I can…

---

## [Matmul function and PVectors](https://discourse.processing.org/t/matmul-function-and-pvectors/21279)

<div class="topic-metadata">

**Author:** [@cyberjaakko](https://discourse.processing.org/u/cyberjaakko)\
**Replies:** 1\
**Last updated:** [May 25, 2020, 2:49pm UTC](https://discourse.processing.org/t/matmul-function-and-pvectors/21279 "2020-05-25T14:49:52Z")

</div>

Hey, I’ve been learning matrix multiplication, but problems started while trying to setup a PVector that utlilzes a matmul function similar to Daniel Schiffman’s example for making 3D projections. I ran into problems wh…

---

## [Best ways to manage a canvas larger than the screen size?](https://discourse.processing.org/t/best-ways-to-manage-a-canvas-larger-than-the-screen-size/21265)

<div class="topic-metadata">

**Author:** [@dtreybig](https://discourse.processing.org/u/dtreybig)\
**Replies:** 2\
**Last updated:** [May 24, 2020, 9:14pm UTC](https://discourse.processing.org/t/best-ways-to-manage-a-canvas-larger-than-the-screen-size/21265 "2020-05-24T21:14:49Z")

</div>

Hi! I am new to Processing and having a lot of fun with it. I have developed a few algorithms I like and that I now want to try printing as a piece of physical art. So far, all of my work has been with a processing reso…

---

## [Processing button on/off](https://discourse.processing.org/t/processing-button-on-off/21256)

<div class="topic-metadata">

**Author:** [@rkk16](https://discourse.processing.org/u/rkk16)\
**Replies:** 2\
**Last updated:** [May 24, 2020, 8:00pm UTC](https://discourse.processing.org/t/processing-button-on-off/21256 "2020-05-24T20:00:15Z")

</div>

If on is true, change the background. But what happens is it flickers - I think it’s because it detects multiple mouseclicks and goes on, off, on, off. How do we avoid this? Do I need a delay term? It works, but I only n…

---

## [Null Pointer Exception on Object Array](https://discourse.processing.org/t/null-pointer-exception-on-object-array/21249)

<div class="topic-metadata">

**Author:** [@koleon03](https://discourse.processing.org/u/koleon03)\
**Replies:** 6\
**Last updated:** [May 24, 2020, 5:37pm UTC](https://discourse.processing.org/t/null-pointer-exception-on-object-array/21249 "2020-05-24T17:37:30Z")

</div>

Hey you guys, I hope you can help me with this. I am creating a little game, for which I need an array of Snowflakes (an object I created), which I create and instantiate. Despite that I am still getting a NPE. Here’s m…

---

## [Simple Button - works sometimes, doesn't work sometimes](https://discourse.processing.org/t/simple-button-works-sometimes-doesnt-work-sometimes/21232)

<div class="topic-metadata">

**Author:** [@rkk16](https://discourse.processing.org/u/rkk16)\
**Replies:** 2\
**Last updated:** [May 24, 2020, 2:12pm UTC](https://discourse.processing.org/t/simple-button-works-sometimes-doesnt-work-sometimes/21232 "2020-05-24T14:12:07Z")

</div>

I’ve got a class defined for a button. I define this button globally as b1 and in setup define the size and values. Then in draw I have b1.update() and b1.display() and if(b1.press()) {functionon = !functionon}; where fu…

---

## [How do I pass a value from one sketch to another sketch?](https://discourse.processing.org/t/how-do-i-pass-a-value-from-one-sketch-to-another-sketch/21176)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 9\
**Last updated:** [May 24, 2020, 1:45pm UTC](https://discourse.processing.org/t/how-do-i-pass-a-value-from-one-sketch-to-another-sketch/21176 "2020-05-24T13:45:50Z")

</div>

I tried to do it by using saveStrings() in one sketch and loadStrings() in the other. writer.pde String\[\] Pipe = new String\[2\]; // Declare, create void setup() { size(400, 400); noStroke(); } void draw() { back…

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

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