# Coding Questions

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

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

**Page:** 170

---

## [How to make a program that works by coloring each pixel by distance to another?](https://discourse.processing.org/t/how-to-make-a-program-that-works-by-coloring-each-pixel-by-distance-to-another/4669)

<div class="topic-metadata">

**Author:** [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Replies:** 12\
**Last updated:** [October 23, 2018, 9:58pm UTC](https://discourse.processing.org/t/how-to-make-a-program-that-works-by-coloring-each-pixel-by-distance-to-another/4669 "2018-10-23T21:58:01Z")

</div>

Hey, so the question might be very confusing, but its actually pretty simple^^ What i would like to do, is to write a program that has an unspecified number of Points (1-20 or so… maybe more) that all maintain a certain …

---

## [How to connect (draw lines) of all elements (ellipses) of an ArrayList?](https://discourse.processing.org/t/how-to-connect-draw-lines-of-all-elements-ellipses-of-an-arraylist/4731)

<div class="topic-metadata">

**Author:** [@philpq12](https://discourse.processing.org/u/philpq12)\
**Replies:** 5\
**Last updated:** [October 24, 2018, 7:47am UTC](https://discourse.processing.org/t/how-to-connect-draw-lines-of-all-elements-ellipses-of-an-arraylist/4731 "2018-10-24T07:47:35Z")

</div>

Hi, In my project, I’m trying to draw a multitude of ellipses that will spawn randomly on the y-axis, all of them scrolling toward the left on the x-axis. Then after, my goal is to connected all those ellipses with a l…

---

## [Camera SEEMS upside down](https://discourse.processing.org/t/camera-seems-upside-down/4787)

<div class="topic-metadata">

**Author:** [@Grim4d](https://discourse.processing.org/u/Grim4d)\
**Replies:** 0\
**Last updated:** [October 23, 2018, 11:04pm UTC](https://discourse.processing.org/t/camera-seems-upside-down/4787 "2018-10-23T23:04:38Z")

</div>

So I created a grid on the z x plane, and then drew small lines that showed the positive x, y, and z axis as red, green, and blue respectively. When I set the camera up I made the up values 0, 1, 0, which I’m assuming ma…

---

## [Adding Texture(img);](https://discourse.processing.org/t/adding-texture-img/4573)

<div class="topic-metadata">

**Author:** [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Replies:** 7\
**Last updated:** [October 23, 2018, 10:21pm UTC](https://discourse.processing.org/t/adding-texture-img/4573 "2018-10-23T22:21:45Z")

</div>

Hey There peeps. I’m trying stuff out on the file from the Codingtrain’s SuperShape and i’m trying to add a texture(image) on the object instead of giving it a color. I tried to load in an image and set it up as a textu…

---

## [How to register 2 keys at a time](https://discourse.processing.org/t/how-to-register-2-keys-at-a-time/4635)

<div class="topic-metadata">

**Author:** [@Schred](https://discourse.processing.org/u/Schred)\
**Replies:** 7\
**Last updated:** [October 23, 2018, 8:33pm UTC](https://discourse.processing.org/t/how-to-register-2-keys-at-a-time/4635 "2018-10-23T20:33:57Z")

</div>

Hi, so I’m trying to make a small game in which you control a litlle space ship and dodge some stuff. Something like that. The player should be able to move in 8 directions, including the 4 diagonal ones. I guess you ca…

---

## [Compare ArrayLists / detect line intersections](https://discourse.processing.org/t/compare-arraylists-detect-line-intersections/4509)

<div class="topic-metadata">

**Author:** [@germaine](https://discourse.processing.org/u/germaine)\
**Replies:** 3\
**Last updated:** [October 23, 2018, 9:01pm UTC](https://discourse.processing.org/t/compare-arraylists-detect-line-intersections/4509 "2018-10-23T21:01:12Z")

</div>

Hello! I’m trying to write code that checks if any two lines drawn on the canvas have intersecting points. Currently, I have an ArrayList of “Line” objects, each containing their own ArrayList of PVectors (“coords”). I …

---

## [Best random number generator](https://discourse.processing.org/t/best-random-number-generator/4674)

<div class="topic-metadata">

**Author:** [@poppanona](https://discourse.processing.org/u/poppanona)\
**Replies:** 5\
**Last updated:** [October 23, 2018, 3:29pm UTC](https://discourse.processing.org/t/best-random-number-generator/4674 "2018-10-23T15:29:51Z")

</div>

I have found that the random number function isn’t quite a normal distribution. My experiments result in errors over 10% at times, even with 100 samples. I am working on a coin toss program. Are there better formulation…

---

## [Add several values to IntList](https://discourse.processing.org/t/add-several-values-to-intlist/4779)

<div class="topic-metadata">

**Author:** [@flashbacker](https://discourse.processing.org/u/flashbacker)\
**Replies:** 8\
**Last updated:** [October 23, 2018, 3:11pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779 "2018-10-23T15:11:41Z")

</div>

Hi, I’m starting to use IntList in a project, not absolutely comfortable with everything yet… I’m seeing in the documentation that I can add several int at once with myList.append(values) or myList.append(list) but eac…

---

## [Re Randomizing Variables](https://discourse.processing.org/t/re-randomizing-variables/4745)

<div class="topic-metadata">

**Author:** [@klarj](https://discourse.processing.org/u/klarj)\
**Replies:** 3\
**Last updated:** [October 23, 2018, 2:07pm UTC](https://discourse.processing.org/t/re-randomizing-variables/4745 "2018-10-23T14:07:07Z")

</div>

I’m trying to create a program where 1st a ball is randomly placed and when clicked on, the old one is removed and a new one is placed randomly. The problem is that even though I do random() again for that variable it do…

---

## [Beginner has a question about 3D drawing flicker](https://discourse.processing.org/t/beginner-has-a-question-about-3d-drawing-flicker/4666)

<div class="topic-metadata">

**Author:** [@wsnicol](https://discourse.processing.org/u/wsnicol)\
**Replies:** 4\
**Last updated:** [October 22, 2018, 10:26pm UTC](https://discourse.processing.org/t/beginner-has-a-question-about-3d-drawing-flicker/4666 "2018-10-22T22:26:16Z")

</div>

A simple program used to introduce people to 3D drawing was working fine the other day but now the image is flickering, why is it doing this and how can I stop it ? size(100,100,P3D); background(0); translate(0,height…

---

## [Blur / Filter only part of the image / canvas? (Masking?)](https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760)

<div class="topic-metadata">

**Author:** [@evn](https://discourse.processing.org/u/evn)\
**Replies:** 1\
**Last updated:** [October 22, 2018, 7:37pm UTC](https://discourse.processing.org/t/blur-filter-only-part-of-the-image-canvas-masking/4760 "2018-10-22T19:37:44Z")

</div>

I have a large canvas and want to use the blur feature, but it’s too much for my computer to handle in real time. I only really care about the center of the canvas being blurred. (let’s say a circle with radius of 50 or …

---

## [Correct memory diagram? Need a second opinion from someone experienced](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622)

<div class="topic-metadata">

**Author:** [@engg23369](https://discourse.processing.org/u/engg23369)\
**Replies:** 5\
**Last updated:** [October 22, 2018, 4:07pm UTC](https://discourse.processing.org/t/correct-memory-diagram-need-a-second-opinion-from-someone-experienced/4622 "2018-10-22T16:07:43Z")

</div>

Can someone with more experience please verify if this is the correct memory diagram.

---

## [Text() doesn't seem to be working](https://discourse.processing.org/t/text-doesnt-seem-to-be-working/4712)

<div class="topic-metadata">

**Author:** [@Tsskyx](https://discourse.processing.org/u/Tsskyx)\
**Replies:** 2\
**Last updated:** [October 22, 2018, 5:23am UTC](https://discourse.processing.org/t/text-doesnt-seem-to-be-working/4712 "2018-10-22T05:23:40Z")

</div>

Here’s my project: import com.jogamp.newt.opengl.GLWindow; GLWindow r; PGraphics w, u; int R, L, F, B, U, D, S = 30; float blockSize = 256, mouseSens = .003; PVector move = new PVector(), dir = new PVector(), pos = new…

---

## [\[RESOLVED\] mouseX Position as Degrees to Rotate the drawing](https://discourse.processing.org/t/resolved-mousex-position-as-degrees-to-rotate-the-drawing/4722)

<div class="topic-metadata">

**Author:** [@SuBluCat](https://discourse.processing.org/u/SuBluCat)\
**Replies:** 8\
**Last updated:** [October 21, 2018, 11:50pm UTC](https://discourse.processing.org/t/resolved-mousex-position-as-degrees-to-rotate-the-drawing/4722 "2018-10-21T23:50:05Z")

</div>

I have an assignment due tomorrow and there is this one part where it says “Use the mouse’s horizontal position as the amount of degrees to rotate the hero”. (Edit) I’m uploading the complete code cause I realized just …

---

## [Processing Animation Question](https://discourse.processing.org/t/processing-animation-question/4705)

<div class="topic-metadata">

**Author:** [@chisholmem](https://discourse.processing.org/u/chisholmem)\
**Replies:** 4\
**Last updated:** [October 21, 2018, 5:46pm UTC](https://discourse.processing.org/t/processing-animation-question/4705 "2018-10-21T17:46:38Z")

</div>

Hi there- I am currently trying to make an animation for homework for my coding class and I am having trouble. I have three separate squares on the screen, but I don’t know how to properly make them go at different times…

---

## [More efficent ways to get PVector heading or atan2](https://discourse.processing.org/t/more-efficent-ways-to-get-pvector-heading-or-atan2/4706)

<div class="topic-metadata">

**Author:** [@Sarah](https://discourse.processing.org/u/Sarah)\
**Replies:** 2\
**Last updated:** [October 21, 2018, 11:23am UTC](https://discourse.processing.org/t/more-efficent-ways-to-get-pvector-heading-or-atan2/4706 "2018-10-21T11:23:41Z")

</div>

Hi, I’ve been experimenting on some steering behaviors, and some of the functions need the velocities heading, but it seemed that PVector.heading() takes up a lot of CPU as it uses atan2() and makes the sketch run slowe…

---

## [Ship fly through the gate (asteroids game)](https://discourse.processing.org/t/ship-fly-through-the-gate-asteroids-game/4647)

<div class="topic-metadata">

**Author:** [@nhghi](https://discourse.processing.org/u/nhghi)\
**Replies:** 3\
**Last updated:** [October 21, 2018, 12:09am UTC](https://discourse.processing.org/t/ship-fly-through-the-gate-asteroids-game/4647 "2018-10-21T00:09:20Z")

</div>

hi, guys, I’m trying to make a small game look like asteroids game but I this time I just need my ship to fly through the gate ( make from 2 direct that the ship can fly in) if it hit the gate the ship should stop at whe…

---

## [Function to turn sentence into all caps](https://discourse.processing.org/t/function-to-turn-sentence-into-all-caps/4673)

<div class="topic-metadata">

**Author:** [@engg23369](https://discourse.processing.org/u/engg23369)\
**Replies:** 5\
**Last updated:** [October 20, 2018, 9:50pm UTC](https://discourse.processing.org/t/function-to-turn-sentence-into-all-caps/4673 "2018-10-20T21:50:53Z")

</div>

I’m trying to make my own function that takes a sentence and turns every letter in it into an uppercase. I know there’s a pre-defined function that does this but i’m trying to make own myself. Here’s what I have so far. …

---

## [Game Snake: fluidity problem](https://discourse.processing.org/t/game-snake-fluidity-problem/4664)

<div class="topic-metadata">

**Author:** [@LECARROU](https://discourse.processing.org/u/LECARROU)\
**Replies:** 3\
**Last updated:** [October 20, 2018, 1:37pm UTC](https://discourse.processing.org/t/game-snake-fluidity-problem/4664 "2018-10-20T13:37:21Z")

</div>

Hello, I’m currently programming a snake game under processing and overall the game works with the most basic features: moving snakes that can be directed to the keyboard and I record positions already occupied that can…

---

## [Save string into byte array](https://discourse.processing.org/t/save-string-into-byte-array/4371)

<div class="topic-metadata">

**Author:** [@jacobrejin](https://discourse.processing.org/u/jacobrejin)\
**Replies:** 18\
**Last updated:** [October 20, 2018, 9:48am UTC](https://discourse.processing.org/t/save-string-into-byte-array/4371 "2018-10-20T09:48:11Z")

</div>

currently I am converting my text file into a string array and then combining them. once combined I an converting them into an integer array by using split() all the data int the text file is numbers that are a byte lo…

---

## [.dat file does not exist](https://discourse.processing.org/t/dat-file-does-not-exist/4651)

<div class="topic-metadata">

**Author:** [@rva1945](https://discourse.processing.org/u/rva1945)\
**Replies:** 2\
**Last updated:** [October 19, 2018, 8:48pm UTC](https://discourse.processing.org/t/dat-file-does-not-exist/4651 "2018-10-19T20:48:40Z")

</div>

Is there anyway of checking of the file exists prior to loadBytes()? Inicially the file does not exist and the sketch stops. Thanks

---

## [Make a ball move at a speed to where the mouse is clicked](https://discourse.processing.org/t/make-a-ball-move-at-a-speed-to-where-the-mouse-is-clicked/4652)

<div class="topic-metadata">

**Author:** [@kome](https://discourse.processing.org/u/kome)\
**Replies:** 1\
**Last updated:** [October 19, 2018, 6:20pm UTC](https://discourse.processing.org/t/make-a-ball-move-at-a-speed-to-where-the-mouse-is-clicked/4652 "2018-10-19T18:20:03Z")

</div>

I’m new to processing and I’m trying to move a ball (an ellipse) to the position of where the mouse is clicked but I don’t what it to jump there . I want it to move there at a certain speed . int golfBallX = 200; int g…

---

## [Make the object move in the circle (asteroids game)](https://discourse.processing.org/t/make-the-object-move-in-the-circle-asteroids-game/4606)

<div class="topic-metadata">

**Author:** [@nhghi](https://discourse.processing.org/u/nhghi)\
**Replies:** 14\
**Last updated:** [October 19, 2018, 5:56pm UTC](https://discourse.processing.org/t/make-the-object-move-in-the-circle-asteroids-game/4606 "2018-10-19T17:56:04Z")

</div>

i have an object like an arrow and if i want to move all the arrow to move in the circle how can i do it

---

## [How can I access object method inside other object?](https://discourse.processing.org/t/how-can-i-access-object-method-inside-other-object/4609)

<div class="topic-metadata">

**Author:** [@enonod](https://discourse.processing.org/u/enonod)\
**Replies:** 5\
**Last updated:** [October 19, 2018, 8:54am UTC](https://discourse.processing.org/t/how-can-i-access-object-method-inside-other-object/4609 "2018-10-19T08:54:41Z")

</div>

Within DPanel I have added two objects, captionBar and btnClose and have called their display() methods successfully as shown in DPanel.display(). I have attempted to bring in a third object via the DPanel method addObje…

---

## [How to make game say you won?](https://discourse.processing.org/t/how-to-make-game-say-you-won/4560)

<div class="topic-metadata">

**Author:** [@ant](https://discourse.processing.org/u/ant)\
**Replies:** 7\
**Last updated:** [October 19, 2018, 2:26am UTC](https://discourse.processing.org/t/how-to-make-game-say-you-won/4560 "2018-10-19T02:26:43Z")

</div>

I want to make it so when the ball hits the white finish box it says you win and restarts the code. //Varaibles for images PImage frankenstein,ghost; PImage startscreen; //variables for start screen int screensizex,scre…

---

## [Save an image from display window coordinates](https://discourse.processing.org/t/save-an-image-from-display-window-coordinates/4610)

<div class="topic-metadata">

**Author:** [@Daniel\_Tex](https://discourse.processing.org/u/Daniel_Tex)\
**Replies:** 4\
**Last updated:** [October 19, 2018, 12:54am UTC](https://discourse.processing.org/t/save-an-image-from-display-window-coordinates/4610 "2018-10-19T00:54:25Z")

</div>

How to save an image from the display window within coordinates? (Such as x \> 0 && x \< 100 && y \> 100 && y \< 200).

---

## [Need help with rotating a shape](https://discourse.processing.org/t/need-help-with-rotating-a-shape/4548)

<div class="topic-metadata">

**Author:** [@rebelcoder](https://discourse.processing.org/u/rebelcoder)\
**Replies:** 10\
**Last updated:** [October 18, 2018, 9:51pm UTC](https://discourse.processing.org/t/need-help-with-rotating-a-shape/4548 "2018-10-18T21:51:27Z")

</div>

Hi guys I am new to processing. I am trying to make a spaceship in an asteroid game. I have to make the spaceship using the 4 points using quad shape. The spaceship moves across the screen which is pretty simple by chang…

---

## [Object to object referencing](https://discourse.processing.org/t/object-to-object-referencing/4598)

<div class="topic-metadata">

**Author:** [@jakstb](https://discourse.processing.org/u/jakstb)\
**Replies:** 2\
**Last updated:** [October 18, 2018, 7:33pm UTC](https://discourse.processing.org/t/object-to-object-referencing/4598 "2018-10-18T19:33:51Z")

</div>

Hi, I have problem referencing to a object from within another object. Here is my code that is a bit simplified to only show my problem; class Team { String team; int elements; int maxElements; Bubble\[\] b; …

---

## [Multiple shaders](https://discourse.processing.org/t/multiple-shaders/4595)

<div class="topic-metadata">

**Author:** [@bitCrasher](https://discourse.processing.org/u/bitCrasher)\
**Replies:** 6\
**Last updated:** [October 18, 2018, 5:36pm UTC](https://discourse.processing.org/t/multiple-shaders/4595 "2018-10-18T17:36:44Z")

</div>

is there a better solution to create a sketch using multiple shaders? PShader myShader, pixelate; PImage img; PGraphics pg, buf; void settings() { size(1000, 1000, P3D); } void setup() { myShader = loadShader("gli…

---

## [Array object doesn't work](https://discourse.processing.org/t/array-object-doesnt-work/4584)

<div class="topic-metadata">

**Author:** [@rva1945](https://discourse.processing.org/u/rva1945)\
**Replies:** 4\
**Last updated:** [October 18, 2018, 12:17am UTC](https://discourse.processing.org/t/array-object-doesnt-work/4584 "2018-10-18T00:17:41Z")

</div>

Hi: I used this example as a guide https://processing.org/examples/arrayobjects.html but my sketch hangs the Java windows and I have to close the window. Turnout\[\] aTurnouts; void setup() { size(1024,500); aTurno…

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

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