# Coding Questions

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

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

**Page:** 56

---

## [Help with Scale and Mouse Coordinates Mismatch](https://discourse.processing.org/t/help-with-scale-and-mouse-coordinates-mismatch/29512)

<div class="topic-metadata">

**Author:** [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Replies:** 3\
**Last updated:** [April 20, 2021, 6:02pm UTC](https://discourse.processing.org/t/help-with-scale-and-mouse-coordinates-mismatch/29512 "2021-04-20T18:02:41Z")

</div>

Hello fellow programmers! I’ve been working on a small space game, and have run into an issue with the ‘solar system map’ system. I’m using translations and scale effects to give the illusion of a full, traversable map…

---

## [Algorithm of an arc based on the midpoint algorithm](https://discourse.processing.org/t/algorithm-of-an-arc-based-on-the-midpoint-algorithm/29502)

<div class="topic-metadata">

**Author:** [@S1993](https://discourse.processing.org/u/S1993)\
**Replies:** 2\
**Last updated:** [April 20, 2021, 10:24am UTC](https://discourse.processing.org/t/algorithm-of-an-arc-based-on-the-midpoint-algorithm/29502 "2021-04-20T10:24:54Z")

</div>

I have to create an algorithm to produce a circular segment, so I have to give the radius, the center, and the initial and final angle. I have been working on the midpoint circle algorithm but I don know how to change i…

---

## [Need help adding two player to our snake project](https://discourse.processing.org/t/need-help-adding-two-player-to-our-snake-project/29492)

<div class="topic-metadata">

**Author:** [@Sentaun](https://discourse.processing.org/u/Sentaun)\
**Replies:** 5\
**Last updated:** [April 20, 2021, 7:40am UTC](https://discourse.processing.org/t/need-help-adding-two-player-to-our-snake-project/29492 "2021-04-20T07:40:44Z")

</div>

me and my friend have a assignment to edit a code to make it different in our own way. we decided to edit a code made by the coding train to add two player. the idea is that two snakes fight it out by trying to get the …

---

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

<div class="topic-metadata">

**Author:** [@PARINAZ129](https://discourse.processing.org/u/PARINAZ129)\
**Replies:** 3\
**Last updated:** [April 19, 2021, 9:25pm UTC](https://discourse.processing.org/t/multiple-shapes/29472 "2021-04-19T21:25:20Z")

</div>

Dear As a beginner, I have rendered a car via rectangles and circles. Actually, I want to move this car via mouse but I cant movie multiple shapes which created the car at the same time. I would be grateful If you che…

---

## [Optimization of Lissajous table](https://discourse.processing.org/t/optimization-of-lissajous-table/29481)

<div class="topic-metadata">

**Author:** [@Rafsing](https://discourse.processing.org/u/Rafsing)\
**Replies:** 6\
**Last updated:** [April 19, 2021, 2:10pm UTC](https://discourse.processing.org/t/optimization-of-lissajous-table/29481 "2021-04-19T14:10:04Z")

</div>

I created code, that animates creation of lissajous table. It works properly, but sometimes, when the first circle travels almost entire lap it slows down dramatically. How can I optimize this code: void calculations() …

---

## [Overwriting pixels\[\] Manually](https://discourse.processing.org/t/overwriting-pixels-manually/29306)

<div class="topic-metadata">

**Author:** [@what42](https://discourse.processing.org/u/what42)\
**Replies:** 3\
**Last updated:** [April 18, 2021, 10:32pm UTC](https://discourse.processing.org/t/overwriting-pixels-manually/29306 "2021-04-18T22:32:06Z")

</div>

I just wanted to know if there’s any way I can bypass loadPixels() and just do pixels = new int \[width \* height\];. I have a function that renders a tilemap to an int array, and load&updatePixels() is slowing it down quit…

---

## [Resize event for sketch without draw() loop](https://discourse.processing.org/t/resize-event-for-sketch-without-draw-loop/29462)

<div class="topic-metadata">

**Author:** [@TechnicJelle](https://discourse.processing.org/u/TechnicJelle)\
**Replies:** 7\
**Last updated:** [April 18, 2021, 10:05pm UTC](https://discourse.processing.org/t/resize-event-for-sketch-without-draw-loop/29462 "2021-04-18T22:05:19Z")

</div>

Hi there! A few friends and me have been working on a small spreadsheet-like software program lately and of course, we made it resizeable by using surface.setResizable(true). The thing of this software is that, because…

---

## [How can I create a sphere (or other shape) with cubes? (3D)](https://discourse.processing.org/t/how-can-i-create-a-sphere-or-other-shape-with-cubes-3d/28047)

<div class="topic-metadata">

**Author:** [@vassilakosaggelos](https://discourse.processing.org/u/vassilakosaggelos)\
**Replies:** 6\
**Last updated:** [April 15, 2021, 7:46pm UTC](https://discourse.processing.org/t/how-can-i-create-a-sphere-or-other-shape-with-cubes-3d/28047 "2021-04-15T19:46:07Z")

</div>

Hi everyone I am new generally in coding ( not only in Processing) so I need your help if you can. What I want to do is to design 10 types of cubes with different color shades ( from white to totally black) without havin…

---

## [Create a new object of a subclass with a String](https://discourse.processing.org/t/create-a-new-object-of-a-subclass-with-a-string/29467)

<div class="topic-metadata">

**Author:** [@TimeLex](https://discourse.processing.org/u/TimeLex)\
**Replies:** 2\
**Last updated:** [April 18, 2021, 6:28pm UTC](https://discourse.processing.org/t/create-a-new-object-of-a-subclass-with-a-string/29467 "2021-04-18T18:28:05Z")

</div>

My friend and I are working on a game. There is an abstract item class and some specific items: abstract class Item{ PVector Start; PVector End; float Progress; boolean delete; boolean flammable; int B…

---

## [How can I connect balls to each other with a line?](https://discourse.processing.org/t/how-can-i-connect-balls-to-each-other-with-a-line/29470)

<div class="topic-metadata">

**Author:** [@iox007](https://discourse.processing.org/u/iox007)\
**Replies:** 5\
**Last updated:** [April 18, 2021, 3:33pm UTC](https://discourse.processing.org/t/how-can-i-connect-balls-to-each-other-with-a-line/29470 "2021-04-18T15:33:11Z")

</div>

Im trying to connect the balls to each other by lines but for some reason, im failing at it. What am i doing wrong? int anz = 10; int r = 8; int speed = 3; boolean show = true; float tmp; float…

---

## [Instantiate one class inside another using a third](https://discourse.processing.org/t/instantiate-one-class-inside-another-using-a-third/29414)

<div class="topic-metadata">

**Author:** [@Aleksi](https://discourse.processing.org/u/Aleksi)\
**Replies:** 9\
**Last updated:** [April 16, 2021, 10:24pm UTC](https://discourse.processing.org/t/instantiate-one-class-inside-another-using-a-third/29414 "2021-04-16T22:24:11Z")

</div>

Hello again! I can’t figure out how to use reflection to instantiate one class inside another using a third class. I feel like I’m close… The goal in this example is to instantiate A.b inside C. import java.lang.refle…

---

## [Music is not stopping](https://discourse.processing.org/t/music-is-not-stopping/29415)

<div class="topic-metadata">

**Author:** [@Mert](https://discourse.processing.org/u/Mert)\
**Replies:** 1\
**Last updated:** [April 16, 2021, 6:18pm UTC](https://discourse.processing.org/t/music-is-not-stopping/29415 "2021-04-16T18:18:38Z")

</div>

Hello everyone I added to music on my code but even if I stop playing music continue to play just wtf how can I solve that problem here is my alllllll code: int rad = 200; // Boyut float xpos, ypos; // Başlay…

---

## [How to replace Shape with an image ? PShape to PImage](https://discourse.processing.org/t/how-to-replace-shape-with-an-image-pshape-to-pimage/29386)

<div class="topic-metadata">

**Author:** [@carolina\_moreira](https://discourse.processing.org/u/carolina_moreira)\
**Replies:** 4\
**Last updated:** [April 16, 2021, 12:08pm UTC](https://discourse.processing.org/t/how-to-replace-shape-with-an-image-pshape-to-pimage/29386 "2021-04-16T12:08:12Z")

</div>

I am trying to exchange all forms for images What is the correct way to do it? The game opens and no error appears The image just does not appear when I press the Y key hope someone can help me thank you in advance …

---

## [Errors in SpaceShip Game](https://discourse.processing.org/t/errors-in-spaceship-game/29389)

<div class="topic-metadata">

**Author:** [@spamelim](https://discourse.processing.org/u/spamelim)\
**Replies:** 3\
**Last updated:** [April 16, 2021, 11:50am UTC](https://discourse.processing.org/t/errors-in-spaceship-game/29389 "2021-04-16T11:50:12Z")

</div>

I’ve been programming a 3D game where a ship avoids spikes on a terrain of triangle sectors. I’ve been having two major problems with the game so far. 1) the triangle sector terrain seems to be moving slowly downwards an…

---

## [White background white text when ellipse moves to text. Text not appear](https://discourse.processing.org/t/white-background-white-text-when-ellipse-moves-to-text-text-not-appear/29398)

<div class="topic-metadata">

**Author:** [@Mert](https://discourse.processing.org/u/Mert)\
**Replies:** 3\
**Last updated:** [April 16, 2021, 9:49am UTC](https://discourse.processing.org/t/white-background-white-text-when-ellipse-moves-to-text-text-not-appear/29398 "2021-04-16T09:49:19Z")

</div>

https://www.behance.net/gallery/75113211/Interactive-Posters?tracking\_source=search\_projects\_recommended|Processing%20Poster%20Design Guys if u check this project there is video check the 1.42. Guys, in the video there…

---

## [Projecting a circle](https://discourse.processing.org/t/projecting-a-circle/29379)

<div class="topic-metadata">

**Author:** [@rosaria](https://discourse.processing.org/u/rosaria)\
**Replies:** 1\
**Last updated:** [April 15, 2021, 2:02pm UTC](https://discourse.processing.org/t/projecting-a-circle/29379 "2021-04-15T14:02:53Z")

</div>

Hello, i’m trying to create code for when mouse is clicked, a ball is projected (upwards), but as it moves it gradually slows down. So far all i’ve manage to figure out is make it move up and down. I’m a complete beginne…

---

## [Object changing colour over time](https://discourse.processing.org/t/object-changing-colour-over-time/29377)

<div class="topic-metadata">

**Author:** [@hwahwa](https://discourse.processing.org/u/hwahwa)\
**Replies:** 1\
**Last updated:** [April 15, 2021, 1:56pm UTC](https://discourse.processing.org/t/object-changing-colour-over-time/29377 "2021-04-15T13:56:57Z")

</div>

Hello, I’ve created some code that moves a grey arrow from left to right. What i want to do is that when the mouse is pressed, the arrow stops and the colour of the arrow increased from a green to yellow to red colour. W…

---

## [Random Shape generator](https://discourse.processing.org/t/random-shape-generator/28843)

<div class="topic-metadata">

**Author:** [@Flolo](https://discourse.processing.org/u/Flolo)\
**Replies:** 12\
**Last updated:** [April 14, 2021, 9:13pm UTC](https://discourse.processing.org/t/random-shape-generator/28843 "2021-04-14T21:13:26Z")

</div>

Hey, I want to write a program that randomly draws dots on the window and then connects them. The special thing about it is: the lines are not allowed to cross each other. What the result should look like: What the …

---

## [Implement the noise function (with midpoint displacement) to create noisy circle](https://discourse.processing.org/t/implement-the-noise-function-with-midpoint-displacement-to-create-noisy-circle/29320)

<div class="topic-metadata">

**Author:** [@Lolita](https://discourse.processing.org/u/Lolita)\
**Replies:** 6\
**Last updated:** [April 14, 2021, 6:27pm UTC](https://discourse.processing.org/t/implement-the-noise-function-with-midpoint-displacement-to-create-noisy-circle/29320 "2021-04-14T18:27:55Z")

</div>

Hi, here is code to create noise circle using begin and end shape function, if you could help to resolve this question and implement the noise function (with midpoint displacement) to create this circle, and we should no…

---

## [How to fix the code belowed in order to delete the leftmost ellipse when keyPressed](https://discourse.processing.org/t/how-to-fix-the-code-belowed-in-order-to-delete-the-leftmost-ellipse-when-keypressed/29353)

<div class="topic-metadata">

**Author:** [@batmm](https://discourse.processing.org/u/batmm)\
**Replies:** 6\
**Last updated:** [April 14, 2021, 4:44pm UTC](https://discourse.processing.org/t/how-to-fix-the-code-belowed-in-order-to-delete-the-leftmost-ellipse-when-keypressed/29353 "2021-04-14T16:44:52Z")

</div>

please format code with \</\> button \* homework policy \* asking questions \<final int SIZE = 20; int x;//x-coordinates int y;//y-coordinates int mousePos;//keep track void setup() { size(500, 500); x = new int\[1000…

---

## [Can't open .bat file!](https://discourse.processing.org/t/cant-open-bat-file/29299)

<div class="topic-metadata">

**Author:** [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Replies:** 5\
**Last updated:** [April 14, 2021, 2:45am UTC](https://discourse.processing.org/t/cant-open-bat-file/29299 "2021-04-14T02:45:51Z")

</div>

Hi guys, I’m here again. This time the question confuses me. I want to use processing to open the bat file to open Google Chrome, and use launch(sketchPath("")+“data/9.bat”); to solve it. The problem is, but when I chang…

---

## [Gradient does not work](https://discourse.processing.org/t/gradient-does-not-work/29347)

<div class="topic-metadata">

**Author:** [@jaspervb](https://discourse.processing.org/u/jaspervb)\
**Replies:** 2\
**Last updated:** [April 13, 2021, 7:40pm UTC](https://discourse.processing.org/t/gradient-does-not-work/29347 "2021-04-13T19:40:43Z")

</div>

Hi There, I want to make a gradient in processing with a for loop. I can not figure out how i can solve this. void setup() { color from = color(255, 165, 32); color to = color(72, 61, 139); int steps = 100; in…

---

## [The Centipedes Game](https://discourse.processing.org/t/the-centipedes-game/29163)

<div class="topic-metadata">

**Author:** [@GijsfromAmsterdam](https://discourse.processing.org/u/GijsfromAmsterdam)\
**Replies:** 8\
**Last updated:** [April 13, 2021, 5:42pm UTC](https://discourse.processing.org/t/the-centipedes-game/29163 "2021-04-13T17:42:54Z")

</div>

Hello all, For school i have to make a kind of snake game. The game has the following rules: Rules of game: 1 player needs to make as many points before all particles of body dissapeared. game should be a field of 16…

---

## [Collision detection & collision response](https://discourse.processing.org/t/collision-detection-collision-response/29321)

<div class="topic-metadata">

**Author:** [@Lolita](https://discourse.processing.org/u/Lolita)\
**Replies:** 3\
**Last updated:** [April 13, 2021, 5:35pm UTC](https://discourse.processing.org/t/collision-detection-collision-response/29321 "2021-04-13T17:35:27Z")

</div>

I just created ball with line , and I want to make this ball hit this line with collision and response please any suggestion! float x = 150; float y = 100; float xSpeed = 9; float ySpeed = 7; void setup() { size(500, …

---

## [Displaying an image in a cascade of pixels](https://discourse.processing.org/t/displaying-an-image-in-a-cascade-of-pixels/29304)

<div class="topic-metadata">

**Author:** [@ilalande](https://discourse.processing.org/u/ilalande)\
**Replies:** 2\
**Last updated:** [April 13, 2021, 4:07pm UTC](https://discourse.processing.org/t/displaying-an-image-in-a-cascade-of-pixels/29304 "2021-04-13T16:07:51Z")

</div>

Hello, I’m new to processing and working with Daniel Shiffman’s book. I fisrt wanted to display an image pixel by pixel, from top left to bottom right.I think I succeded in what I wanted (making appear an image pixel b…

---

## [Recursive tree painting problem](https://discourse.processing.org/t/recursive-tree-painting-problem/29303)

<div class="topic-metadata">

**Author:** [@xXvladosXx](https://discourse.processing.org/u/xXvladosXx)\
**Replies:** 8\
**Last updated:** [April 13, 2021, 1:27pm UTC](https://discourse.processing.org/t/recursive-tree-painting-problem/29303 "2021-04-13T13:27:56Z")

</div>

Hi guys, I have a problem with understanding how to work with Recursive Tree. I have to built something like a tree with green leaves (photo below), however I have only a default recursive tree. Task: Make a green like…

---

## [Apply wind force on this code](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322)

<div class="topic-metadata">

**Author:** [@Lolita](https://discourse.processing.org/u/Lolita)\
**Replies:** 5\
**Last updated:** [April 13, 2021, 12:23pm UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322 "2021-04-13T12:23:19Z")

</div>

Here is the code and Id apply wind force instead of friction, int NrDisks = 120; float Gravity = 0.03; float Fri = -0.9; Disk\[\] disks = new Disk\[NrDisks\]; void setup() { size(700, 700); for (int i = 0; i \< …

---

## [How to add objects to ArrayList one at a time at timed intervals](https://discourse.processing.org/t/how-to-add-objects-to-arraylist-one-at-a-time-at-timed-intervals/29305)

<div class="topic-metadata">

**Author:** [@spamelim](https://discourse.processing.org/u/spamelim)\
**Replies:** 4\
**Last updated:** [April 12, 2021, 10:05pm UTC](https://discourse.processing.org/t/how-to-add-objects-to-arraylist-one-at-a-time-at-timed-intervals/29305 "2021-04-12T22:05:20Z")

</div>

I’m trying to make a 3D space shooter-type game, where spikes come at the ship and must be avoided. I’m currently coding for adding spikes one at a time at different intervals in the user’s score using an ArrayList. My e…

---

## [Displaying an image pixel by pixel](https://discourse.processing.org/t/displaying-an-image-pixel-by-pixel/28839)

<div class="topic-metadata">

**Author:** [@ilalande](https://discourse.processing.org/u/ilalande)\
**Replies:** 3\
**Last updated:** [March 26, 2021, 1:52pm UTC](https://discourse.processing.org/t/displaying-an-image-pixel-by-pixel/28839 "2021-03-26T13:52:01Z")

</div>

Hi, I’m new to processing and working with Daniel Shiffman’s book. I’d like to display an image pixel by pixel, from top left to bottom right. I tried this code but it does what I ask : it draws a diagonal line (I can …

---

## [Measuring Reaction Time When A Box Changes Color](https://discourse.processing.org/t/measuring-reaction-time-when-a-box-changes-color/29298)

<div class="topic-metadata">

**Author:** [@lestacos](https://discourse.processing.org/u/lestacos)\
**Replies:** 0\
**Last updated:** [April 12, 2021, 9:51am UTC](https://discourse.processing.org/t/measuring-reaction-time-when-a-box-changes-color/29298 "2021-04-12T09:51:52Z")

</div>

We are tasked with creating a Processing program which measures reaction time of a person. The program should be able to: The user can start the experiment by pressing the SPACE key. At a random time (between 2 and 6 …

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

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