# Coding Questions

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

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

**Page:** 186

---

## [Stroke won't change colour when clicked](https://discourse.processing.org/t/stroke-wont-change-colour-when-clicked/793)

<div class="topic-metadata">

**Author:** [@alessandrajoy](https://discourse.processing.org/u/alessandrajoy)\
**Replies:** 11\
**Last updated:** [June 16, 2018, 4:30am UTC](https://discourse.processing.org/t/stroke-wont-change-colour-when-clicked/793 "2018-06-16T04:30:43Z")

</div>

This is my painting program. It has a frame and colours at the bottom. I want the stroke to change to the colour of the image at the bottom when clicked. But it is not working. any suggestions? here is my code and images…

---

## [Problem while I learning Arrray](https://discourse.processing.org/t/problem-while-i-learning-arrray/991)

<div class="topic-metadata">

**Author:** [@KangYunJae](https://discourse.processing.org/u/KangYunJae)\
**Replies:** 4\
**Last updated:** [June 16, 2018, 1:50am UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991 "2018-06-16T01:50:11Z")

</div>

This Is Working Version of What I learn. float\[\] x = new float\[5\]; void setup() { size(1080,720); noStroke(); } void draw() { background(0); x\[0\] += 0.5; x\[1\] += 0.5; x\[2\] += 0.5; x\[3\] += 0.5; x\[4\] +=…

---

## [Display data in window from Arduino serial port](https://discourse.processing.org/t/display-data-in-window-from-arduino-serial-port/955)

<div class="topic-metadata">

**Author:** [@albertoG1](https://discourse.processing.org/u/albertoG1)\
**Replies:** 1\
**Last updated:** [June 15, 2018, 7:18am UTC](https://discourse.processing.org/t/display-data-in-window-from-arduino-serial-port/955 "2018-06-15T07:18:00Z")

</div>

Hi, I have a very simple program made with a Nano Arduino and a humidity sensor. The sensor obtains a data per second and shows it in the serial port with two values, the first with values from zero to 1023 of the senso…

---

## [Error trying to add super class objects to subclass arraylist](https://discourse.processing.org/t/error-trying-to-add-super-class-objects-to-subclass-arraylist/964)

<div class="topic-metadata">

**Author:** [@RafeArnold](https://discourse.processing.org/u/RafeArnold)\
**Replies:** 4\
**Last updated:** [June 14, 2018, 7:43pm UTC](https://discourse.processing.org/t/error-trying-to-add-super-class-objects-to-subclass-arraylist/964 "2018-06-14T19:43:05Z")

</div>

I have an ArrayList that stores instances of the subclass (SubClass) of another class (SupClass). I have already defined the classes, SupClass and SubClass (with SubClass extending SupClass) and there is already a SupCla…

---

## [How to overlay an image over another in P3D](https://discourse.processing.org/t/how-to-overlay-an-image-over-another-in-p3d/959)

<div class="topic-metadata">

**Author:** [@rainfox](https://discourse.processing.org/u/rainfox)\
**Replies:** 7\
**Last updated:** [June 14, 2018, 7:17pm UTC](https://discourse.processing.org/t/how-to-overlay-an-image-over-another-in-p3d/959 "2018-06-14T19:17:11Z")

</div>

In processing.js, how would you overlay an image over another one in P3D mode? Here is my code: /\* @pjs preload="duck.jpg"; \*/ /\* @pjs preload="a.png"; \*/ PImage imageDuck; PImage imageA; void…

---

## [Troubles making a model of solarsail](https://discourse.processing.org/t/troubles-making-a-model-of-solarsail/950)

<div class="topic-metadata">

**Author:** [@MAXimum\_effort](https://discourse.processing.org/u/MAXimum_effort)\
**Replies:** 2\
**Last updated:** [June 14, 2018, 3:25pm UTC](https://discourse.processing.org/t/troubles-making-a-model-of-solarsail/950 "2018-06-14T15:25:13Z")

</div>

I am currently working on a model to visualize/calculate the flight path of a solar sail (a type of spacecraft). But I have troubles with making the orbit of the spacecraft dependent on physics calculations. Whenever I …

---

## [Using a part of the computer screen for computer vision](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902)

<div class="topic-metadata">

**Author:** [@jan-jelle](https://discourse.processing.org/u/jan-jelle)\
**Replies:** 2\
**Last updated:** [June 14, 2018, 12:01am UTC](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902 "2018-06-14T00:01:25Z")

</div>

Hello everybody, I am trying to manipulate a video input with data from a software program that is running on the PC itself. basically, i try to implement information from the PC screen into the live video screen. howev…

---

## [Minim, Song starts in the middle?](https://discourse.processing.org/t/minim-song-starts-in-the-middle/928)

<div class="topic-metadata">

**Author:** [@Seraphinit](https://discourse.processing.org/u/Seraphinit)\
**Replies:** 0\
**Last updated:** [June 13, 2018, 7:52pm UTC](https://discourse.processing.org/t/minim-song-starts-in-the-middle/928 "2018-06-13T19:52:16Z")

</div>

Hey there, I’m trying to make a simple music player with a selfdrawn animation in the background. Animation and everything works fine, but the song keeps starting in the middle of it? Is there a limit to the lenght of…

---

## [Need help changing background with mouse!](https://discourse.processing.org/t/need-help-changing-background-with-mouse/904)

<div class="topic-metadata">

**Author:** [@QuazArxx](https://discourse.processing.org/u/QuazArxx)\
**Replies:** 8\
**Last updated:** [June 13, 2018, 1:32pm UTC](https://discourse.processing.org/t/need-help-changing-background-with-mouse/904 "2018-06-13T13:32:14Z")

</div>

i understand coding it is as simple as background(mouseX) or anything in those variations. My concern is getting the top left corner in a 250x250 window to be background(255) and the bottom right corner to be background(…

---

## [Crashing a lot after updates](https://discourse.processing.org/t/crashing-a-lot-after-updates/702)

<div class="topic-metadata">

**Author:** [@barryalen1992](https://discourse.processing.org/u/barryalen1992)\
**Replies:** 4\
**Last updated:** [June 13, 2018, 11:19am UTC](https://discourse.processing.org/t/crashing-a-lot-after-updates/702 "2018-06-13T11:19:14Z")

</div>

After recent Windows 10 updates all of my coding crashes instantly when I opened them. What is happening with those updates. Does anyone suffer the same problem? Help me please!

---

## [How to scale text and image to responsive canvas?](https://discourse.processing.org/t/how-to-scale-text-and-image-to-responsive-canvas/909)

<div class="topic-metadata">

**Author:** [@LoCamillo](https://discourse.processing.org/u/LoCamillo)\
**Replies:** 1\
**Last updated:** [June 13, 2018, 10:45am UTC](https://discourse.processing.org/t/how-to-scale-text-and-image-to-responsive-canvas/909 "2018-06-13T10:45:35Z")

</div>

Hi! I’m trying to do a big project, but I’m stuck in a part of it. The canvas I’m working on is responsive, but the text and image aren’t. Here’s a simple code that make what i’m needing. function setup(){ createCanva…

---

## [NullPointedException](https://discourse.processing.org/t/nullpointedexception/911)

<div class="topic-metadata">

**Author:** [@inesacsaraiva](https://discourse.processing.org/u/inesacsaraiva)\
**Replies:** 3\
**Last updated:** [June 13, 2018, 1:10am UTC](https://discourse.processing.org/t/nullpointedexception/911 "2018-06-13T01:10:00Z")

</div>

When I run the program it says NullPointedException… could someone help me see what’s wrong? Sorry if it’s a bit disorganised… import processing.video.\*; Capture video; PImage prev; ArrayList\<Circle\> circles; ArrayList\<…

---

## [Drawing Heart,problem with class](https://discourse.processing.org/t/drawing-heart-problem-with-class/890)

<div class="topic-metadata">

**Author:** [@AbuYazid](https://discourse.processing.org/u/AbuYazid)\
**Replies:** 2\
**Last updated:** [June 12, 2018, 10:06am UTC](https://discourse.processing.org/t/drawing-heart-problem-with-class/890 "2018-06-12T10:06:38Z")

</div>

Hi all coders out there, i have drawn a heart shape using points and it is working , for drawing multiple hearts i have made a object “heart” with a constructor of passing 3 variable (size,x position and y position ) and…

---

## [Scrollable list to Bang](https://discourse.processing.org/t/scrollable-list-to-bang/857)

<div class="topic-metadata">

**Author:** [@GarethWilkins](https://discourse.processing.org/u/GarethWilkins)\
**Replies:** 4\
**Last updated:** [June 12, 2018, 9:17am UTC](https://discourse.processing.org/t/scrollable-list-to-bang/857 "2018-06-12T09:17:19Z")

</div>

I have scrollable list and i want to use the picked items in these to feed into 4 bangs which will then play different sets of sounds. I am struggling working out how to get this info to the bangs. Any help will be grea…

---

## [Multiple windows - clone one to another with pgraphics obj](https://discourse.processing.org/t/multiple-windows-clone-one-to-another-with-pgraphics-obj/869)

<div class="topic-metadata">

**Author:** [@bitCrasher](https://discourse.processing.org/u/bitCrasher)\
**Replies:** 7\
**Last updated:** [June 11, 2018, 4:28pm UTC](https://discourse.processing.org/t/multiple-windows-clone-one-to-another-with-pgraphics-obj/869 "2018-06-11T16:28:52Z")

</div>

hi to all! i want clone one windows into another: if i use this code: PWindow win; PGraphics pg; public void settings() { size(640, 480); } void setup() { win = new PWindow(); pg = createGraphics(width, hei…

---

## [Array Isn't Detected In Parameter](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862)

<div class="topic-metadata">

**Author:** [@Avid\_Coder](https://discourse.processing.org/u/Avid_Coder)\
**Replies:** 3\
**Last updated:** [June 11, 2018, 3:40pm UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862 "2018-06-11T15:40:28Z")

</div>

I am trying to make an animation system to display images with a certain frame rate. While attempting to pass the function an array, it said I had not created an array or variable with that name. I tried adding square br…

---

## [Inserting a variable into a 2D array](https://discourse.processing.org/t/inserting-a-variable-into-a-2d-array/866)

<div class="topic-metadata">

**Author:** [@JaKa](https://discourse.processing.org/u/JaKa)\
**Replies:** 1\
**Last updated:** [June 11, 2018, 8:15am UTC](https://discourse.processing.org/t/inserting-a-variable-into-a-2d-array/866 "2018-06-11T08:15:41Z")

</div>

Im unsure of how i can put either the x or an o into my 2d array for my 7x7 naughts and crosses type game? class cell{ String player; int turnNum; char shape; cell(int row, int col){ } } cell\[\]\[\] grid=new c…

---

## [Inaccuracy in exponential pow() function](https://discourse.processing.org/t/inaccuracy-in-exponential-pow-function/817)

<div class="topic-metadata">

**Author:** [@neoumlaut](https://discourse.processing.org/u/neoumlaut)\
**Replies:** 4\
**Last updated:** [June 10, 2018, 2:50pm UTC](https://discourse.processing.org/t/inaccuracy-in-exponential-pow-function/817 "2018-06-10T14:50:58Z")

</div>

I’m working on a program that displays data from an oscilloscope over a serial connection and have run into a problem converting from scientific notation. If I receive a number, for example, 5.72E-1, I then convert it us…

---

## [Wave displaced circle](https://discourse.processing.org/t/wave-displaced-circle/808)

<div class="topic-metadata">

**Author:** [@josephh](https://discourse.processing.org/u/josephh)\
**Replies:** 4\
**Last updated:** [June 10, 2018, 11:08am UTC](https://discourse.processing.org/t/wave-displaced-circle/808 "2018-06-10T11:08:31Z")

</div>

Hi guys, I’m trying to replicate this animation in processing : But I can’t figure out how to do it, this is my code : Circle c1,c2; void setup() { size(800, 800); c1 = new Circle(0,0,200,0); c…

---

## [How do I get the keyCode?](https://discourse.processing.org/t/how-do-i-get-the-keycode/794)

<div class="topic-metadata">

**Author:** [@Grimtin10](https://discourse.processing.org/u/Grimtin10)\
**Replies:** 14\
**Last updated:** [June 8, 2018, 4:19pm UTC](https://discourse.processing.org/t/how-do-i-get-the-keycode/794 "2018-06-08T16:19:11Z")

</div>

I want to make a KeyHandler class to make it so I can press multiple keys, but I don’t know how to get the ASCII integer value for every key, how do I do this?

---

## [Processing 2.0 error on New GLabel](https://discourse.processing.org/t/processing-2-0-error-on-new-glabel/724)

<div class="topic-metadata">

**Author:** [@piscvau](https://discourse.processing.org/u/piscvau)\
**Replies:** 3\
**Last updated:** [June 8, 2018, 9:44am UTC](https://discourse.processing.org/t/processing-2-0-error-on-new-glabel/724 "2018-06-08T09:44:07Z")

</div>

Hello I am trying to run a code from Github which was written in october 2015. I do not knwo which version of processing was used. The code is using the G4P and Sdrop librairies. I installed processing 3 but ran into an…

---

## [Fix code to make spaceship blaster shoot](https://discourse.processing.org/t/fix-code-to-make-spaceship-blaster-shoot/789)

<div class="topic-metadata">

**Author:** [@the-junk](https://discourse.processing.org/u/the-junk)\
**Replies:** 3\
**Last updated:** [June 8, 2018, 8:17am UTC](https://discourse.processing.org/t/fix-code-to-make-spaceship-blaster-shoot/789 "2018-06-08T08:17:46Z")

</div>

Why won’t my code work to make my spaceship blaster shoot? float shipX; // player spaceship float shipY; // player spaceship float enemyX; //enemy UFO float enemyY; //enemy UFO float enemySpeed = 2; float blastX; floa…

---

## [For Loop with Text Array](https://discourse.processing.org/t/for-loop-with-text-array/787)

<div class="topic-metadata">

**Author:** [@deanomite](https://discourse.processing.org/u/deanomite)\
**Replies:** 3\
**Last updated:** [June 7, 2018, 10:28pm UTC](https://discourse.processing.org/t/for-loop-with-text-array/787 "2018-06-07T22:28:15Z")

</div>

Hi there, Am having some trouble figuring this exercise out. It’s a basic grid of text but I want the letters spread out across the rows and columns. Right now all text from the array appears one on top of each other a…

---

## [Keyboard buttons](https://discourse.processing.org/t/keyboard-buttons/717)

<div class="topic-metadata">

**Author:** [@nethaniel](https://discourse.processing.org/u/nethaniel)\
**Replies:** 4\
**Last updated:** [June 7, 2018, 7:34pm UTC](https://discourse.processing.org/t/keyboard-buttons/717 "2018-06-07T19:34:43Z")

</div>

i am trying to make a program that has a two shapes that move around with keyboard buttons i am somewhat new to coding and do not know how to make the keyboard recognize two different keys at the same time this is what i…

---

## [Can't Find NullPointerException](https://discourse.processing.org/t/cant-find-nullpointerexception/778)

<div class="topic-metadata">

**Author:** [@PeachAlmond9077](https://discourse.processing.org/u/PeachAlmond9077)\
**Replies:** 3\
**Last updated:** [June 7, 2018, 7:17pm UTC](https://discourse.processing.org/t/cant-find-nullpointerexception/778 "2018-06-07T19:17:47Z")

</div>

I am trying to code a Snake Game in which the snake eats square orbs When I was running the program a couple of days ago, the program throws a NullPointerException, which is saying that Line 14 in my Snake class is caus…

---

## [Collision and Boundaries help(Mario)?](https://discourse.processing.org/t/collision-and-boundaries-help-mario/716)

<div class="topic-metadata">

**Author:** [@tokyo](https://discourse.processing.org/u/tokyo)\
**Replies:** 14\
**Last updated:** [June 7, 2018, 5:10pm UTC](https://discourse.processing.org/t/collision-and-boundaries-help-mario/716 "2018-06-07T17:10:30Z")

</div>

Hi, I was working on a game and I had a couple questions. First, can you make a boundary by color? For example, I have a Mario and some pipes for him to jump over. The pipes are green so is there any code that prevents M…

---

## [Shooting ball from a moving object](https://discourse.processing.org/t/shooting-ball-from-a-moving-object/730)

<div class="topic-metadata">

**Author:** [@ProcessingNoob](https://discourse.processing.org/u/ProcessingNoob)\
**Replies:** 1\
**Last updated:** [June 7, 2018, 4:58am UTC](https://discourse.processing.org/t/shooting-ball-from-a-moving-object/730 "2018-06-07T04:58:57Z")

</div>

Complete noob to processing here. Writing in Java and doing a uni project on shooting aliens with a cannon. I want the cannonball to fire from a cannon, which is moving up and down based on a spaceship’s coordinates. Th…

---

## [How to pace the appearance of recursion objects?](https://discourse.processing.org/t/how-to-pace-the-appearance-of-recursion-objects/748)

<div class="topic-metadata">

**Author:** [@rolando](https://discourse.processing.org/u/rolando)\
**Replies:** 6\
**Last updated:** [June 6, 2018, 8:37pm UTC](https://discourse.processing.org/t/how-to-pace-the-appearance-of-recursion-objects/748 "2018-06-06T20:37:20Z")

</div>

Hello all, This follows up on my previous post still associated with a fractal project Im currently working on. I am aware that the following question may involve arraylists of which Im not yet familiar with, Im hoping…

---

## [Help! Struggling with an IF statement to change color](https://discourse.processing.org/t/help-struggling-with-an-if-statement-to-change-color/687)

<div class="topic-metadata">

**Author:** [@rolando](https://discourse.processing.org/u/rolando)\
**Replies:** 4\
**Last updated:** [June 6, 2018, 6:30am UTC](https://discourse.processing.org/t/help-struggling-with-an-if-statement-to-change-color/687 "2018-06-06T06:30:54Z")

</div>

Hello! I am writing a sketch to animate the drawing of a circle (arc); what I would like to do is to change to a random color every time the full arc is drawn, I have so far gotten to change it once only, how to continue…

---

## [Mario game help! Move background screen when image is moved?](https://discourse.processing.org/t/mario-game-help-move-background-screen-when-image-is-moved/659)

<div class="topic-metadata">

**Author:** [@tokyo](https://discourse.processing.org/u/tokyo)\
**Replies:** 6\
**Last updated:** [June 6, 2018, 6:30am UTC](https://discourse.processing.org/t/mario-game-help-move-background-screen-when-image-is-moved/659 "2018-06-06T06:30:40Z")

</div>

Hi I’m trying to code my own Mario game as a beginner but I’m having a lot of difficulty without a mentor. I needed help moving the background screen so when Mario moves too much to the right or left i want the screen to…

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

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