# Coding Questions

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

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

**Page:** 168

---

## [Not sure how to code this Random/shuffling image effect](https://discourse.processing.org/t/not-sure-how-to-code-this-random-shuffling-image-effect/5073)

<div class="topic-metadata">

**Author:** [@Damo](https://discourse.processing.org/u/Damo)\
**Replies:** 4\
**Last updated:** [November 1, 2018, 7:39pm UTC](https://discourse.processing.org/t/not-sure-how-to-code-this-random-shuffling-image-effect/5073 "2018-11-01T19:39:21Z")

</div>

I want to code a random shuffling array of images, where each square pulls from a separate folder of images and every time it refreshes its another random array of images. I’m not sure how difficult this is any help …

---

## [STOP the explosion](https://discourse.processing.org/t/stop-the-explosion/5071)

<div class="topic-metadata">

**Author:** [@kornFusion](https://discourse.processing.org/u/kornFusion)\
**Replies:** 4\
**Last updated:** [November 1, 2018, 5:36pm UTC](https://discourse.processing.org/t/stop-the-explosion/5071 "2018-11-01T17:36:43Z")

</div>

Hey Guys, I have the following code which I want to stop the particles before they leave the screen… So I dont know how to stop them near the edges of the screen… Please advice… Thanks Particle \[\] pickles = new Part…

---

## [Arc radius uglyness](https://discourse.processing.org/t/arc-radius-uglyness/4999)

<div class="topic-metadata">

**Author:** [@kll](https://discourse.processing.org/u/kll)\
**Replies:** 3\
**Last updated:** [November 1, 2018, 5:21pm UTC](https://discourse.processing.org/t/arc-radius-uglyness/4999 "2018-11-01T17:21:02Z")

</div>

in my arc i see a radial pixel jump, ( processing 3.4 , win7 ) any trick to avoid that? int m = 150, r = 200; float w =TAU/60; void setup() { size(300, 300); noFill(); strokeWeight(3); } void draw() { backgro…

---

## [What's the right approach to draw in / overlay PGraphics with transparency?](https://discourse.processing.org/t/whats-the-right-approach-to-draw-in-overlay-pgraphics-with-transparency/5060)

<div class="topic-metadata">

**Author:** [@hamoid](https://discourse.processing.org/u/hamoid)\
**Replies:** 4\
**Last updated:** [November 1, 2018, 2:11pm UTC](https://discourse.processing.org/t/whats-the-right-approach-to-draw-in-overlay-pgraphics-with-transparency/5060 "2018-11-01T14:11:50Z")

</div>

Hi! What would be the right way to have multiple PGraphics with transparency and draw them on top of each other to avoid tinting? I’ll try to show the issue with some images and code: PGraphics pg; int mode = 0; …

---

## [Trying to turn static collage image into animation](https://discourse.processing.org/t/trying-to-turn-static-collage-image-into-animation/5066)

<div class="topic-metadata">

**Author:** [@chisholmem](https://discourse.processing.org/u/chisholmem)\
**Replies:** 1\
**Last updated:** [November 1, 2018, 4:15am UTC](https://discourse.processing.org/t/trying-to-turn-static-collage-image-into-animation/5066 "2018-11-01T04:15:32Z")

</div>

Hi there, I am new to processing and trying to figure out an assignment for class. I am currently trying to figure out how to incorporate millis() into this code, to scale/descale the images I have and to add a colored s…

---

## [quadraticVertex function not working properly](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938)

<div class="topic-metadata">

**Author:** [@cbroney](https://discourse.processing.org/u/cbroney)\
**Replies:** 6\
**Last updated:** [November 1, 2018, 1:59am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938 "2018-11-01T01:59:45Z")

</div>

when I load this shape i created it doesnt draw with the curves unless I remove the “b1” from each line. can someone please tell me why PShape b1; PShape b2; PShape b3; void setup() { size(1600,1200); background(25…

---

## [Help with a computer science 10 "Red Square" assignment](https://discourse.processing.org/t/help-with-a-computer-science-10-red-square-assignment/5008)

<div class="topic-metadata">

**Author:** [@zstrei](https://discourse.processing.org/u/zstrei)\
**Replies:** 16\
**Last updated:** [November 1, 2018, 1:22am UTC](https://discourse.processing.org/t/help-with-a-computer-science-10-red-square-assignment/5008 "2018-11-01T01:22:55Z")

</div>

I have to create a game similar to the game in the link provided below. http://www.hypedup.co.uk/games/redsquare.html I am only in Grade Ten, so it doesn’t need to be fancy or with any hard code. The Marking rubric is …

---

## [Using Millis() to scale an animation](https://discourse.processing.org/t/using-millis-to-scale-an-animation/5064)

<div class="topic-metadata">

**Author:** [@chisholmem](https://discourse.processing.org/u/chisholmem)\
**Replies:** 1\
**Last updated:** [November 1, 2018, 12:59am UTC](https://discourse.processing.org/t/using-millis-to-scale-an-animation/5064 "2018-11-01T00:59:55Z")

</div>

I’m really confused as to how I can add millis() to animation I’ve already made. If you run the code I have below, it shows yellow stars on a blue background, moving from side to side. What I want to do is to change it i…

---

## [Help a newbie with polymorphic particles](https://discourse.processing.org/t/help-a-newbie-with-polymorphic-particles/5068)

<div class="topic-metadata">

**Author:** [@jbr123](https://discourse.processing.org/u/jbr123)\
**Replies:** 5\
**Last updated:** [November 1, 2018, 12:40am UTC](https://discourse.processing.org/t/help-a-newbie-with-polymorphic-particles/5068 "2018-11-01T00:40:01Z")

</div>

Hi there, I am working on a university project with processing. This is a first time for me, so bear with me… We are creating a particle system (of sorts) that will eventually trigger sounds etc. The code I have attache…

---

## [RSS Feed to print through receipt printer](https://discourse.processing.org/t/rss-feed-to-print-through-receipt-printer/4945)

<div class="topic-metadata">

**Author:** [@Lili](https://discourse.processing.org/u/Lili)\
**Replies:** 2\
**Last updated:** [October 31, 2018, 10:54pm UTC](https://discourse.processing.org/t/rss-feed-to-print-through-receipt-printer/4945 "2018-10-31T22:54:47Z")

</div>

Hi! I’m very new to Processing and coding but I’m trying to print the content of an RSS Feed to print through a receipt/ thermal printer. I can print text through the MyPort.Write function but it’d be great if it would …

---

## [Draw order in 3D](https://discourse.processing.org/t/draw-order-in-3d/4789)

<div class="topic-metadata">

**Author:** [@garroad\_ran](https://discourse.processing.org/u/garroad_ran)\
**Replies:** 15\
**Last updated:** [October 31, 2018, 6:06pm UTC](https://discourse.processing.org/t/draw-order-in-3d/4789 "2018-10-31T18:06:44Z")

</div>

I’m getting into 3d for the first time and I’m not quite sure how I’m supposed to handle draw order. The easiest way to explain my question is probably with an image and code. void setup() { size(1280, 720, P3D); …

---

## [Chess Board: make all fields flash](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943)

<div class="topic-metadata">

**Author:** [@hexe43](https://discourse.processing.org/u/hexe43)\
**Replies:** 2\
**Last updated:** [October 31, 2018, 5:22pm UTC](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943 "2018-10-31T17:22:56Z")

</div>

Hi, I am new in processing and I have to make my chess board flash (every field in a random color in a specific frame rate) when I press enter and make it stop flashing when I press it again. I already tried several thi…

---

## [For Loop Problem](https://discourse.processing.org/t/for-loop-problem/4913)

<div class="topic-metadata">

**Author:** [@Grimtin10](https://discourse.processing.org/u/Grimtin10)\
**Replies:** 4\
**Last updated:** [October 31, 2018, 5:16pm UTC](https://discourse.processing.org/t/for-loop-problem/4913 "2018-10-31T17:16:07Z")

</div>

I have code that initializes a 2d array, but when the Y goes to zero it gives an array out of bounds exception. Why is this? How do I fix it?

---

## [Need some home help combining both of these](https://discourse.processing.org/t/need-some-home-help-combining-both-of-these/5011)

<div class="topic-metadata">

**Author:** [@orb](https://discourse.processing.org/u/orb)\
**Replies:** 3\
**Last updated:** [October 31, 2018, 10:56am UTC](https://discourse.processing.org/t/need-some-home-help-combining-both-of-these/5011 "2018-10-31T10:56:26Z")

</div>

I’m trying make the player shoot the bullets, but I have no idea how. What I do know that is that the second code can make player shoot bullets. I just need help making them fit each other. \[code re-posted below\]

---

## [Need Simple Colision Example](https://discourse.processing.org/t/need-simple-colision-example/5002)

<div class="topic-metadata">

**Author:** [@Staalone](https://discourse.processing.org/u/Staalone)\
**Replies:** 3\
**Last updated:** [October 31, 2018, 9:31am UTC](https://discourse.processing.org/t/need-simple-colision-example/5002 "2018-10-31T09:31:27Z")

</div>

Hy, I need a code for a ball that’s controlled by the mouse that when it hits any of the corners the ball goes back to the middle, thank you!

---

## [How to make a color palette from an image ordered by frequence](https://discourse.processing.org/t/how-to-make-a-color-palette-from-an-image-ordered-by-frequence/4850)

<div class="topic-metadata">

**Author:** [@BulVvyvXsWDYZl8J](https://discourse.processing.org/u/BulVvyvXsWDYZl8J)\
**Replies:** 9\
**Last updated:** [October 30, 2018, 10:20pm UTC](https://discourse.processing.org/t/how-to-make-a-color-palette-from-an-image-ordered-by-frequence/4850 "2018-10-30T22:20:42Z")

</div>

My goal is to get an array that’ll show in order the most used colours in an image. The catch is that the colours should be perceptually different. I have working code that does the first part — get all the colours in o…

---

## [PVectors, traveling a path](https://discourse.processing.org/t/pvectors-traveling-a-path/4887)

<div class="topic-metadata">

**Author:** [@jack.sibert](https://discourse.processing.org/u/jack.sibert)\
**Replies:** 4\
**Last updated:** [October 30, 2018, 6:50pm UTC](https://discourse.processing.org/t/pvectors-traveling-a-path/4887 "2018-10-30T18:50:54Z")

</div>

I’m trying to write a program that has a Ball object travel across paths determined by randomly placed PVector objects. In the Ball class i’ve written a move method that moves a Ball to the nearest PVector object in the…

---

## [How to make cooldown timer for button](https://discourse.processing.org/t/how-to-make-cooldown-timer-for-button/4890)

<div class="topic-metadata">

**Author:** [@codingsucks](https://discourse.processing.org/u/codingsucks)\
**Replies:** 3\
**Last updated:** [October 30, 2018, 6:36pm UTC](https://discourse.processing.org/t/how-to-make-cooldown-timer-for-button/4890 "2018-10-30T18:36:56Z")

</div>

I am looking for a way to add a 4 second cool down on using the button ‘w’. How do I achieve this?

---

## [Printing a sequence of number on the canvas using text()](https://discourse.processing.org/t/printing-a-sequence-of-number-on-the-canvas-using-text/4936)

<div class="topic-metadata">

**Author:** [@Dee-3\_123](https://discourse.processing.org/u/Dee-3_123)\
**Replies:** 5\
**Last updated:** [October 30, 2018, 4:41pm UTC](https://discourse.processing.org/t/printing-a-sequence-of-number-on-the-canvas-using-text/4936 "2018-10-30T16:41:09Z")

</div>

Hi! there, I am trying to print a sequence of number on canvas using text() and for loop but those numbers are overwriting on one another. actually I want to print Fibonacci sequence on the canvas and the number of step…

---

## [Why does the persistence of vision remain](https://discourse.processing.org/t/why-does-the-persistence-of-vision-remain/4668)

<div class="topic-metadata">

**Author:** [@koba](https://discourse.processing.org/u/koba)\
**Replies:** 7\
**Last updated:** [October 30, 2018, 1:03am UTC](https://discourse.processing.org/t/why-does-the-persistence-of-vision-remain/4668 "2018-10-30T01:03:00Z")

</div>

why does the persistence of vision remain in this program ? int x = 0; void setup(){ size(400,400); noStroke(); } void draw(){ fill(255); ellipse(x,200,10,10); x++; fill(0); ellipse(x,200,10,10); }

---

## [Better solutions on Bouncing Ball bugging through platform?](https://discourse.processing.org/t/better-solutions-on-bouncing-ball-bugging-through-platform/4755)

<div class="topic-metadata">

**Author:** [@jstsmedmb](https://discourse.processing.org/u/jstsmedmb)\
**Replies:** 9\
**Last updated:** [October 29, 2018, 4:51pm UTC](https://discourse.processing.org/t/better-solutions-on-bouncing-ball-bugging-through-platform/4755 "2018-10-29T16:51:09Z")

</div>

Hi :slight\_smile: I want the code below to create a ball that bounces on the bottom of the screen as well as on platforms. The bottom isn’t really the issue here, its just easier to create the problem when including it. …

---

## [Rotate two colors (新手請教各位大大教如何寫代碼不甚感激)](https://discourse.processing.org/t/rotate-two-colors/4971)

<div class="topic-metadata">

**Author:** [@alk5603](https://discourse.processing.org/u/alk5603)\
**Replies:** 2\
**Last updated:** [October 29, 2018, 1:36pm UTC](https://discourse.processing.org/t/rotate-two-colors/4971 "2018-10-29T13:36:09Z")

</div>

float x, y; void setup() { size(800, 600); strokeWeight(10); } void draw() { //background(#68CEF5); fill(0, 15); rect(-50, -50, width + 100, height + 100); translate(width/2, height/2); rotate(-frameCount…

---

## [Better collision detection](https://discourse.processing.org/t/better-collision-detection/4965)

<div class="topic-metadata">

**Author:** [@kport](https://discourse.processing.org/u/kport)\
**Replies:** 1\
**Last updated:** [October 28, 2018, 11:18pm UTC](https://discourse.processing.org/t/better-collision-detection/4965 "2018-10-28T23:18:34Z")

</div>

I have a pong-like game, where the paddle position is tied to mouse pointer position. If I move the mouse slowly, the ball bounces as expected. If I move the mouse quickly, however, the ball will likely pass through the …

---

## [Initialising a global array: this works, but WHY?](https://discourse.processing.org/t/initialising-a-global-array-this-works-but-why/4957)

<div class="topic-metadata">

**Author:** [@MuddyGardener](https://discourse.processing.org/u/MuddyGardener)\
**Replies:** 3\
**Last updated:** [October 28, 2018, 7:45pm UTC](https://discourse.processing.org/t/initialising-a-global-array-this-works-but-why/4957 "2018-10-28T19:45:46Z")

</div>

I made some simple test code for setting up and using an array of colours that worked fine as a straight through thing (i.e. no setup, no draw). Then I modified it for use with a setup and frame loop and eventually got …

---

## [Scanner (java.util.scanner) doesn't seem to be working?](https://discourse.processing.org/t/scanner-java-util-scanner-doesnt-seem-to-be-working/4958)

<div class="topic-metadata">

**Author:** [@Danny\_Posada](https://discourse.processing.org/u/Danny_Posada)\
**Replies:** 2\
**Last updated:** [October 28, 2018, 7:32pm UTC](https://discourse.processing.org/t/scanner-java-util-scanner-doesnt-seem-to-be-working/4958 "2018-10-28T19:32:11Z")

</div>

Recently I’ve been trying to experiment with user input in processing, but nothing seems to be working. I’ve tried multiple websites but none of them have given me and answer that works. The problem is that when I run th…

---

## [Help with movement on a background](https://discourse.processing.org/t/help-with-movement-on-a-background/4813)

<div class="topic-metadata">

**Author:** [@somedude](https://discourse.processing.org/u/somedude)\
**Replies:** 2\
**Last updated:** [October 28, 2018, 5:18pm UTC](https://discourse.processing.org/t/help-with-movement-on-a-background/4813 "2018-10-28T17:18:50Z")

</div>

hello i am making a code for a character that moves on oa background but i keep having the following error "Badly formed character constant(expecting quote, got E) PImage bg, personagem; int px, py; boolean cima, bai…

---

## [Need help with 2D array](https://discourse.processing.org/t/need-help-with-2d-array/4954)

<div class="topic-metadata">

**Author:** [@process14](https://discourse.processing.org/u/process14)\
**Replies:** 3\
**Last updated:** [October 28, 2018, 4:44pm UTC](https://discourse.processing.org/t/need-help-with-2d-array/4954 "2018-10-28T16:44:07Z")

</div>

Hi, so im writing a program that makes robots run from left to right. how i want to achieve that is by rolling 2 dice and the score of those 2 dices added up is the amount of px the robot should move. now i already hav…

---

## [Can't adept my plan to a loop logic](https://discourse.processing.org/t/cant-adept-my-plan-to-a-loop-logic/4952)

<div class="topic-metadata">

**Author:** [@losferatos](https://discourse.processing.org/u/losferatos)\
**Replies:** 2\
**Last updated:** [October 28, 2018, 2:40pm UTC](https://discourse.processing.org/t/cant-adept-my-plan-to-a-loop-logic/4952 "2018-10-28T14:40:45Z")

</div>

Hi there! I came across a problem regarding loops. For some reason, I want to check if there are double entries in my int array (rather String but nvm). I came up with some kind of a solution, but I deeply hope there …

---

## [When image is loaded do something](https://discourse.processing.org/t/when-image-is-loaded-do-something/4946)

<div class="topic-metadata">

**Author:** [@jensemand](https://discourse.processing.org/u/jensemand)\
**Replies:** 2\
**Last updated:** [October 28, 2018, 2:35pm UTC](https://discourse.processing.org/t/when-image-is-loaded-do-something/4946 "2018-10-28T14:35:27Z")

</div>

Hi I need some help with an “if” line. i want to know if i can so something like this: if(image is loaded) { b = true; } else { b = false; } if (b==true) { statement } if (b== false) { statement } the problem i…

---

## [Sorting a JSONArray by one of its values](https://discourse.processing.org/t/sorting-a-jsonarray-by-one-of-its-values/4911)

<div class="topic-metadata">

**Author:** [@delsey](https://discourse.processing.org/u/delsey)\
**Replies:** 5\
**Last updated:** [October 28, 2018, 12:00pm UTC](https://discourse.processing.org/t/sorting-a-jsonarray-by-one-of-its-values/4911 "2018-10-28T12:00:21Z")

</div>

I have a JSONArray which saves “Name” and “Best”. Best is always an int. I would like to be able to sort the array descending. I can not provide any code as there is none. Thanks in advance. String\[\] names = { "A", "B",…

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

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