# Coding Questions

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

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

**Page:** 103

---

## [Load different SVG files based on table data (Simple, Beginner!)](https://discourse.processing.org/t/load-different-svg-files-based-on-table-data-simple-beginner/19186)

<div class="topic-metadata">

**Author:** [@BenEvans](https://discourse.processing.org/u/BenEvans)\
**Replies:** 6\
**Last updated:** [March 30, 2020, 3:15pm UTC](https://discourse.processing.org/t/load-different-svg-files-based-on-table-data-simple-beginner/19186 "2020-03-30T15:15:46Z")

</div>

Hey community - thanks for being there. I have looked elsewhere, but haven’t found a solution to what ought to be extremely simple - apologies if my research was insufficient. FYI I already can: Load a table, get ints …

---

## [Year Error in Date Calculation](https://discourse.processing.org/t/year-error-in-date-calculation/19154)

<div class="topic-metadata">

**Author:** [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Replies:** 4\
**Last updated:** [March 30, 2020, 8:47am UTC](https://discourse.processing.org/t/year-error-in-date-calculation/19154 "2020-03-30T08:47:34Z")

</div>

I was printing dates along the x axis of a graph, and saw a year error. I’ve reduced the program to a minimum demo of the problem. It’s supposed to print the date for each day. The number of days in error varies from y…

---

## [Most efficient way to draw hyperbola?](https://discourse.processing.org/t/most-efficient-way-to-draw-hyperbola/17713)

<div class="topic-metadata">

**Author:** [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Replies:** 8\
**Last updated:** [March 29, 2020, 9:54pm UTC](https://discourse.processing.org/t/most-efficient-way-to-draw-hyperbola/17713 "2020-03-29T21:54:23Z")

</div>

TLDR: What’s easier for a computer: making a curve out of a polygon with a bunch of regular vertices, or making it out of a shape with a couple of quadratic vertices? So, as the title suggests, I need to generate a hype…

---

## [Create boundaries for tank](https://discourse.processing.org/t/create-boundaries-for-tank/6521)

<div class="topic-metadata">

**Author:** [@ari\_y](https://discourse.processing.org/u/ari_y)\
**Replies:** 2\
**Last updated:** [March 29, 2020, 9:32pm UTC](https://discourse.processing.org/t/create-boundaries-for-tank/6521 "2020-03-29T21:32:58Z")

</div>

My assignment is to create a program that allows the user to drive a tank around the screen. It needs to have walls on at the edges of the screen and 2 boundaries that are each larger than the tank. When a tank is moved …

---

## [Need help with code for school](https://discourse.processing.org/t/need-help-with-code-for-school/19062)

<div class="topic-metadata">

**Author:** [@comrade](https://discourse.processing.org/u/comrade)\
**Replies:** 3\
**Last updated:** [March 29, 2020, 8:44pm UTC](https://discourse.processing.org/t/need-help-with-code-for-school/19062 "2020-03-29T20:44:11Z")

</div>

int x; int y; int wx; int wy; int s = 0; PImage sunf; PImage bee; void setup(){ size(1920,1080); x = (int)random(200,1700); y = (int)random(200, 800); bee = loadImage(“bee.png”); sunf = loadImage(“sunf.jpg”); …

---

## [Trying to get all objects in array to have collision](https://discourse.processing.org/t/trying-to-get-all-objects-in-array-to-have-collision/19137)

<div class="topic-metadata">

**Author:** [@Banana132](https://discourse.processing.org/u/Banana132)\
**Replies:** 2\
**Last updated:** [March 29, 2020, 7:20pm UTC](https://discourse.processing.org/t/trying-to-get-all-objects-in-array-to-have-collision/19137 "2020-03-29T19:20:30Z")

</div>

For the past few days, I have been struggling to get all the objects in my arraylist to be able to collide with the player object, but I am just struggling to get it to work. Im just not sure how to reference the array i…

---

## [Help with assignment](https://discourse.processing.org/t/help-with-assignment/18573)

<div class="topic-metadata">

**Author:** [@Burgs](https://discourse.processing.org/u/Burgs)\
**Replies:** 10\
**Last updated:** [March 29, 2020, 5:42pm UTC](https://discourse.processing.org/t/help-with-assignment/18573 "2020-03-29T17:42:54Z")

</div>

In this programming assignment, you will write an active Processing program that uses nested loops to display a grid of balls that follows the mouse. The number of columns of balls will increase each time the mouse is c…

---

## [Minesweeper coding help](https://discourse.processing.org/t/minesweeper-coding-help/19027)

<div class="topic-metadata">

**Author:** [@quadri](https://discourse.processing.org/u/quadri)\
**Replies:** 1\
**Last updated:** [March 26, 2020, 10:01am UTC](https://discourse.processing.org/t/minesweeper-coding-help/19027 "2020-03-26T10:01:16Z")

</div>

Write a function called check\_surrounds with 4 inputs:  dim (a positive integer)  grid (a 2D numerical array containing only 1s and 0s of size dimxdim).  i (a positive integer between 1 and dim)  j (a positive in…

---

## [Coding a hole using PShape](https://discourse.processing.org/t/coding-a-hole-using-pshape/19135)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [March 29, 2020, 5:26pm UTC](https://discourse.processing.org/t/coding-a-hole-using-pshape/19135 "2020-03-29T17:26:15Z")

</div>

Here is the code from the processing example /\*\* \* BeginEndContour \* \* How to cut a shape out of another using beginContour() and endContour() \*/ PShape s; void setup() { size(640, 360, P2D); // Make a shap…

---

## [Missing Something Basic about if statements](https://discourse.processing.org/t/missing-something-basic-about-if-statements/19147)

<div class="topic-metadata">

**Author:** [@VytautasTheGreat](https://discourse.processing.org/u/VytautasTheGreat)\
**Replies:** 4\
**Last updated:** [March 29, 2020, 4:32pm UTC](https://discourse.processing.org/t/missing-something-basic-about-if-statements/19147 "2020-03-29T16:32:39Z")

</div>

Hi everyone. I’m a complete beginner so please forgive what is probably an obvious question. In the code below, I am creating two global booleans. I want one to toggle after each mouse click, and one to permanently fl…

---

## [Gioco da definire](https://discourse.processing.org/t/gioco-da-definire/18681)

<div class="topic-metadata">

**Author:** [@marika20](https://discourse.processing.org/u/marika20)\
**Replies:** 28\
**Last updated:** [March 29, 2020, 12:41am UTC](https://discourse.processing.org/t/gioco-da-definire/18681 "2020-03-29T00:41:56Z")

</div>

Ciao a tutti! Sto lavorando su un nuovo gioco o comunque una sorta di intrattenimento interattivo, il progetto su cui sto lavorando è basato sul fare qualcosa che attiri l’attenzione del giocatore. Vorrei renderlo più …

---

## ["ammo" cannot be resolved to a variable \[total beginner\], please help!](https://discourse.processing.org/t/ammo-cannot-be-resolved-to-a-variable-total-beginner-please-help/19123)

<div class="topic-metadata">

**Author:** [@CodeNewbie123](https://discourse.processing.org/u/CodeNewbie123)\
**Replies:** 3\
**Last updated:** [March 28, 2020, 10:26pm UTC](https://discourse.processing.org/t/ammo-cannot-be-resolved-to-a-variable-total-beginner-please-help/19123 "2020-03-28T22:26:07Z")

</div>

I’m a little bit desperate. Why does Processing say “ammo cannot be resolved to a variable” (Row 52), although i declared the array already in setup? (Row 29) https://pastebin.com/T8M2T6Np I’ve tried my best, but I’m y…

---

## [Delay on first collision, but not subsequent ones](https://discourse.processing.org/t/delay-on-first-collision-but-not-subsequent-ones/18989)

<div class="topic-metadata">

**Author:** [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)\
**Replies:** 5\
**Last updated:** [March 28, 2020, 3:12pm UTC](https://discourse.processing.org/t/delay-on-first-collision-but-not-subsequent-ones/18989 "2020-03-28T15:12:42Z")

</div>

Hi all, I’m wondering if anyone can let me know why I get a considerable delay (a few seconds) when one object collides with another for the first time, but then after that there’s no delay. Here’s my code: PImage\[\] pl…

---

## [Adjusting window size AND shape size](https://discourse.processing.org/t/adjusting-window-size-and-shape-size/19025)

<div class="topic-metadata">

**Author:** [@Tina](https://discourse.processing.org/u/Tina)\
**Replies:** 3\
**Last updated:** [March 28, 2020, 12:28pm UTC](https://discourse.processing.org/t/adjusting-window-size-and-shape-size/19025 "2020-03-28T12:28:51Z")

</div>

I want to code my program so that regardless of what the window size is modified to, the shape (rectangle) will also change according to the new size. In other words, the rectangle size and position should adjust if the …

---

## [Looping through JSON properties](https://discourse.processing.org/t/looping-through-json-properties/19090)

<div class="topic-metadata">

**Author:** [@Odermonicon](https://discourse.processing.org/u/Odermonicon)\
**Replies:** 16\
**Last updated:** [March 28, 2020, 11:23am UTC](https://discourse.processing.org/t/looping-through-json-properties/19090 "2020-03-28T11:23:28Z")

</div>

I need to loop through a JSON file that looks like this: JSON"blocks":{ "vJb19r)WPw88AL7K#^ZI":{ "opcode":"control\_incr\_counter", "next":"IV.E7vBXTcdK0jZYX}…

---

## [Flow Field (Perlin noise)"Array Index Out Of Bounds Exception" Error](https://discourse.processing.org/t/flow-field-perlin-noise-array-index-out-of-bounds-exception-error/19098)

<div class="topic-metadata">

**Author:** [@niuuin](https://discourse.processing.org/u/niuuin)\
**Replies:** 2\
**Last updated:** [March 28, 2020, 9:16am UTC](https://discourse.processing.org/t/flow-field-perlin-noise-array-index-out-of-bounds-exception-error/19098 "2020-03-28T09:16:45Z")

</div>

Hi everyone, I try to convert Coding Challenge #24: Perlin Noise Flow Field to processing，But encountered “ArrayIndexOutOfBoundsException” Error,This is my code: float inc = 0.1; int scl = 20; int cols, rows; float …

---

## [Verbose code (how to shorten)](https://discourse.processing.org/t/verbose-code-how-to-shorten/19018)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 4\
**Last updated:** [March 28, 2020, 1:37am UTC](https://discourse.processing.org/t/verbose-code-how-to-shorten/19018 "2020-03-28T01:37:43Z")

</div>

I have this sketch (see below). Everything works, the green balls are healthy, the red balls are sick, if a green ball and a red ball collide the red ball infects the green ball and they both end up sick. After a while a…

---

## [Rotating images without interfering with translation (new to coding!)](https://discourse.processing.org/t/rotating-images-without-interfering-with-translation-new-to-coding/19003)

<div class="topic-metadata">

**Author:** [@semi\_cologne](https://discourse.processing.org/u/semi_cologne)\
**Replies:** 4\
**Last updated:** [March 27, 2020, 11:13pm UTC](https://discourse.processing.org/t/rotating-images-without-interfering-with-translation-new-to-coding/19003 "2020-03-27T23:13:14Z")

</div>

Hey coders, I’m working on a clock using a png image. every second the image moves vertically, but every minute I am trying to make the image rotate. That said even with experimenting with push and pop matrixes, I still …

---

## [Trying to write a simple snake game with arrays but I run into an error](https://discourse.processing.org/t/trying-to-write-a-simple-snake-game-with-arrays-but-i-run-into-an-error/19065)

<div class="topic-metadata">

**Author:** [@creedin](https://discourse.processing.org/u/creedin)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 8:25pm UTC](https://discourse.processing.org/t/trying-to-write-a-simple-snake-game-with-arrays-but-i-run-into-an-error/19065 "2020-03-27T20:25:11Z")

</div>

float\[\] xpos; float\[\] ypos; void setup() { size(500,500); } void draw() { background(255); for (int i = 0; i \< xpos.length - 1; i++) { xpos\[i\] = xpos\[i + 1\]; ypos\[i\] = ypos\[i + 1\]; } xpos\[xpos.lengt…

---

## [Square with resizeable rectangles inside](https://discourse.processing.org/t/square-with-resizeable-rectangles-inside/14482)

<div class="topic-metadata">

**Author:** [@BooWseR](https://discourse.processing.org/u/BooWseR)\
**Replies:** 8\
**Last updated:** [March 27, 2020, 8:21pm UTC](https://discourse.processing.org/t/square-with-resizeable-rectangles-inside/14482 "2020-03-27T20:21:27Z")

</div>

Hi Guys, i’m pretty new with processing and have a problem: I need a square with different squares in it. These should be changeable in size, but not smaller than a certain minimum size. I have tried different approach…

---

## [How to delete an object in a class?](https://discourse.processing.org/t/how-to-delete-an-object-in-a-class/19067)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 7\
**Last updated:** [March 27, 2020, 5:32pm UTC](https://discourse.processing.org/t/how-to-delete-an-object-in-a-class/19067 "2020-03-27T17:32:15Z")

</div>

So I have a class that is a bullet. And if the bullet is out of bound, then it will delete the object. But how do I do this? Here is my code. class Bullet { if (xpos \> 500 || ypos \> 500) delete object // how…

---

## [Switching from keypressed to using an array](https://discourse.processing.org/t/switching-from-keypressed-to-using-an-array/19053)

<div class="topic-metadata">

**Author:** [@MichelO](https://discourse.processing.org/u/MichelO)\
**Replies:** 1\
**Last updated:** [March 26, 2020, 8:39pm UTC](https://discourse.processing.org/t/switching-from-keypressed-to-using-an-array/19053 "2020-03-26T20:39:54Z")

</div>

I have code that draws a multi-colored spiral pattern with different line lengths and colors depending on which number keys are pressed. I would like to change this to reading the numbers from an array, but I am having s…

---

## [Processing 3 : two windows at time , one 2d and one 3d](https://discourse.processing.org/t/processing-3-two-windows-at-time-one-2d-and-one-3d/19019)

<div class="topic-metadata">

**Author:** [@Bob63](https://discourse.processing.org/u/Bob63)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 2:17am UTC](https://discourse.processing.org/t/processing-3-two-windows-at-time-one-2d-and-one-3d/19019 "2020-03-27T02:17:26Z")

</div>

Hi, I’m quite new of Processing 3,and is my first post in the forum. I’m working on a project that require two windows , one 2D and one 3d. The 2D window will be used to display a series of fata coming from a serial por…

---

## [Plotting Parametric Equations](https://discourse.processing.org/t/plotting-parametric-equations/18947)

<div class="topic-metadata">

**Author:** [@rubbs](https://discourse.processing.org/u/rubbs)\
**Replies:** 3\
**Last updated:** [March 26, 2020, 11:04pm UTC](https://discourse.processing.org/t/plotting-parametric-equations/18947 "2020-03-26T23:04:06Z")

</div>

Hello, I believe that I have almost correctly drawn-out a hyperbolic helicoid: (https://mathworld.wolfram.com/HyperbolicHelicoid.html). But there is some odd behavior, I think it’s because I am not calculating torsion…

---

## [Game speed after certain score is reached](https://discourse.processing.org/t/game-speed-after-certain-score-is-reached/19043)

<div class="topic-metadata">

**Author:** [@Banana132](https://discourse.processing.org/u/Banana132)\
**Replies:** 4\
**Last updated:** [March 26, 2020, 10:16pm UTC](https://discourse.processing.org/t/game-speed-after-certain-score-is-reached/19043 "2020-03-26T22:16:28Z")

</div>

Hi there, I am creating a game where the player has to avoid some asteriods, and gain a good score. After going past a certain score, the game speed increases. At the moment i have this playerScore.countUp(); textAl…

---

## [Circles that will disappear when the mouse hovers](https://discourse.processing.org/t/circles-that-will-disappear-when-the-mouse-hovers/19035)

<div class="topic-metadata">

**Author:** [@lozozo](https://discourse.processing.org/u/lozozo)\
**Replies:** 1\
**Last updated:** [March 26, 2020, 1:31pm UTC](https://discourse.processing.org/t/circles-that-will-disappear-when-the-mouse-hovers/19035 "2020-03-26T13:31:16Z")

</div>

Hi, I am new to coding, I’ve only just starting being taught it. I need to create a project - I have an idea for it but am unsure how to create it. Essentially I want to create a line of circles going vertically down t…

---

## [Fade Effect - What's with the ghost?](https://discourse.processing.org/t/fade-effect-whats-with-the-ghost/18891)

<div class="topic-metadata">

**Author:** [@Tomfoolery](https://discourse.processing.org/u/Tomfoolery)\
**Replies:** 14\
**Last updated:** [March 26, 2020, 8:57am UTC](https://discourse.processing.org/t/fade-effect-whats-with-the-ghost/18891 "2020-03-26T08:57:21Z")

</div>

My intention is to create a fade effect for thousands of shapes on the canvas (They appear, and then fade into blackness). This is the solution I came up with, and have found other people using. void draw() { fill(…

---

## [Is there a way to set an "internal" timer?](https://discourse.processing.org/t/is-there-a-way-to-set-an-internal-timer/19022)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 1\
**Last updated:** [March 26, 2020, 1:47am UTC](https://discourse.processing.org/t/is-there-a-way-to-set-an-internal-timer/19022 "2020-03-26T01:47:57Z")

</div>

So I’m making a game where a character shoots. And I need a delay between bullet shots. However, I don’t want to use delay(x) since that will affect the entire game. Can I set a delay inside my void ShootBullet() functi…

---

## [How do I make mouse controlled paddle stop glitching](https://discourse.processing.org/t/how-do-i-make-mouse-controlled-paddle-stop-glitching/18922)

<div class="topic-metadata">

**Author:** [@WeeBoEtte](https://discourse.processing.org/u/WeeBoEtte)\
**Replies:** 4\
**Last updated:** [March 25, 2020, 1:12am UTC](https://discourse.processing.org/t/how-do-i-make-mouse-controlled-paddle-stop-glitching/18922 "2020-03-25T01:12:55Z")

</div>

I’m am trying to make a pong game where one player controls with the mouse and the other controls with the keyboard. I got my mouse to move the paddle, but it keeps glitching to different places on the screen. Any ideas? …

---

## [Trigger animation effect after object collision](https://discourse.processing.org/t/trigger-animation-effect-after-object-collision/18811)

<div class="topic-metadata">

**Author:** [@codingcomplexity](https://discourse.processing.org/u/codingcomplexity)\
**Replies:** 14\
**Last updated:** [March 24, 2020, 11:42pm UTC](https://discourse.processing.org/t/trigger-animation-effect-after-object-collision/18811 "2020-03-24T23:42:36Z")

</div>

I want to create a “pulse” effect after objects collide with each other. The intended effect in this example is that when the particles collide (come within a certain distance from each other) an ellipse appears, grows t…

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

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