# Coding Questions

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

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

**Page:** 91

---

## [I need help to keep score](https://discourse.processing.org/t/i-need-help-to-keep-score/21724)

<div class="topic-metadata">

**Author:** [@mrporcessing](https://discourse.processing.org/u/mrporcessing)\
**Replies:** 2\
**Last updated:** [June 10, 2020, 10:11am UTC](https://discourse.processing.org/t/i-need-help-to-keep-score/21724 "2020-06-10T10:11:58Z")

</div>

Hi, I just need help adding the score to my game. Its doing random things. I need the score to be added separately when the ball touches each individual paddle. heres my code; //Screem int screenX = 600; int screenY = …

---

## [Block the PApplet(Processing) closing action when ESC is pressed](https://discourse.processing.org/t/block-the-papplet-processing-closing-action-when-esc-is-pressed/21657)

<div class="topic-metadata">

**Author:** [@Moritz](https://discourse.processing.org/u/Moritz)\
**Replies:** 4\
**Last updated:** [June 10, 2020, 4:49am UTC](https://discourse.processing.org/t/block-the-papplet-processing-closing-action-when-esc-is-pressed/21657 "2020-06-10T04:49:51Z")

</div>

Hey Guys, How can i block the closing action when ESC is pressed? The only way i found by myself was to overwrite the original closing method and creating a new one @Override public void exit(){ } public void exitPr…

---

## [How to create a slider locked to an axis](https://discourse.processing.org/t/how-to-create-a-slider-locked-to-an-axis/21693)

<div class="topic-metadata">

**Author:** [@rkdnson](https://discourse.processing.org/u/rkdnson)\
**Replies:** 4\
**Last updated:** [June 9, 2020, 3:04pm UTC](https://discourse.processing.org/t/how-to-create-a-slider-locked-to-an-axis/21693 "2020-06-09T15:04:15Z")

</div>

Hello, I am trying to figure out how to lock the position of a slider to a specific axis. The slider starts at a point on the edge of a circle and needs to end in the center. The user should be able to move the slider (…

---

## [Encoding 2 integers into RGBA without bitwise](https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718)

<div class="topic-metadata">

**Author:** [@zenglenn](https://discourse.processing.org/u/zenglenn)\
**Replies:** 1\
**Last updated:** [June 9, 2020, 9:16pm UTC](https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718 "2020-06-09T21:16:35Z")

</div>

I’m using Processing(Java) to write shaders that do lots of fancy code art. In my shader code I’m trying to get 2 integers (x,y positions) into an RGBA so I can send this colored pixel back to my Java program - and from …

---

## [Sabattier effect in processing](https://discourse.processing.org/t/sabattier-effect-in-processing/21553)

<div class="topic-metadata">

**Author:** [@gatz\_gaz](https://discourse.processing.org/u/gatz_gaz)\
**Replies:** 9\
**Last updated:** [June 9, 2020, 5:05pm UTC](https://discourse.processing.org/t/sabattier-effect-in-processing/21553 "2020-06-09T17:05:43Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi, does anyone know how to do the Sabattier effect in processing? Example:

---

## [Triangular buttons](https://discourse.processing.org/t/triangular-buttons/21666)

<div class="topic-metadata">

**Author:** [@Kiciak](https://discourse.processing.org/u/Kiciak)\
**Replies:** 3\
**Last updated:** [June 8, 2020, 3:34am UTC](https://discourse.processing.org/t/triangular-buttons/21666 "2020-06-08T03:34:25Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi, I know it might be quite a trivial topic but I really don’t have an idea of how to create a triangular button. I thought about using trigono…

---

## [Can anyone help with Hangman Code?](https://discourse.processing.org/t/can-anyone-help-with-hangman-code/21611)

<div class="topic-metadata">

**Author:** [@cammy](https://discourse.processing.org/u/cammy)\
**Replies:** 11\
**Last updated:** [June 7, 2020, 11:30pm UTC](https://discourse.processing.org/t/can-anyone-help-with-hangman-code/21611 "2020-06-07T23:30:32Z")

</div>

boolean newWord = true ; String w; char letter = '?'; char a, b, c; int currentScreen=0; void keyTyped() { letter = key; } void intro() { fill(0); textSize(26); text("HANGMAN", 195,50); strokeWeight(3); …

---

## [Unexpected strokes are shown on P2D PGraphics](https://discourse.processing.org/t/unexpected-strokes-are-shown-on-p2d-pgraphics/21660)

<div class="topic-metadata">

**Author:** [@Reva](https://discourse.processing.org/u/Reva)\
**Replies:** 6\
**Last updated:** [June 7, 2020, 4:51pm UTC](https://discourse.processing.org/t/unexpected-strokes-are-shown-on-p2d-pgraphics/21660 "2020-06-07T16:51:32Z")

</div>

Hi~I tried to draw custom shapes(hexagon) on a transparent P2D PGraphics for later I would change the background color. I don’t want any strokes, but there are unexpected outlines of the shapes shown on the P2D PGraphic. …

---

## [Move with keyboard arrows](https://discourse.processing.org/t/move-with-keyboard-arrows/21637)

<div class="topic-metadata">

**Author:** [@bismarck](https://discourse.processing.org/u/bismarck)\
**Replies:** 2\
**Last updated:** [June 7, 2020, 12:37pm UTC](https://discourse.processing.org/t/move-with-keyboard-arrows/21637 "2020-06-07T12:37:46Z")

</div>

hello i am new here,i need help with this code because the thing that i try to move don’t do that, but if i leave one of the if/else statement the code run without problems. can you help me? (sorry for the bad english) …

---

## [Blinking images are too fast](https://discourse.processing.org/t/blinking-images-are-too-fast/21632)

<div class="topic-metadata">

**Author:** [@SaltyBoy](https://discourse.processing.org/u/SaltyBoy)\
**Replies:** 4\
**Last updated:** [June 7, 2020, 5:21am UTC](https://discourse.processing.org/t/blinking-images-are-too-fast/21632 "2020-06-07T05:21:34Z")

</div>

I want to blink some images in my Simon game, but they are blinking very short. You can hardly see that a light (image) is turned on. boolean isPlayerReady = false; ArrayList\<Integer\> gameList; ArrayList\<Integer\> player…

---

## [Center to mouseX,Y with storing](https://discourse.processing.org/t/center-to-mousex-y-with-storing/21533)

<div class="topic-metadata">

**Author:** [@mrbro](https://discourse.processing.org/u/mrbro)\
**Replies:** 11\
**Last updated:** [June 6, 2020, 11:35pm UTC](https://discourse.processing.org/t/center-to-mousex-y-with-storing/21533 "2020-06-06T23:35:32Z")

</div>

Hi there! I am trying to draw a shape which starts from the center and expands the radius untill the mouse coursore. I am also storing the valuse so I can have it fading into the infinity. I managed to do everything, ex…

---

## [Why can't I access this array within my constructor?](https://discourse.processing.org/t/why-cant-i-access-this-array-within-my-constructor/21576)

<div class="topic-metadata">

**Author:** [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Replies:** 13\
**Last updated:** [June 6, 2020, 8:54pm UTC](https://discourse.processing.org/t/why-cant-i-access-this-array-within-my-constructor/21576 "2020-06-06T20:54:38Z")

</div>

So, I’ve been looking at this code for the past couple hours, and I can’t for the life of me figure out what’s going on. Please note: For the sake of keeping things simple, I didn’t list the contents of the array sizein…

---

## [Quest for setTexture](https://discourse.processing.org/t/quest-for-settexture/21564)

<div class="topic-metadata">

**Author:** [@MartinGo](https://discourse.processing.org/u/MartinGo)\
**Replies:** 6\
**Last updated:** [June 6, 2020, 7:07pm UTC](https://discourse.processing.org/t/quest-for-settexture/21564 "2020-06-06T19:07:07Z")

</div>

Hi. I want to make an hexagonal tile using the setTexture method of PShape, the problem is I want to run the following example PImage img; PShape globe; void setup() { // Load an image img = loadImage("earth.jpg")…

---

## [Using Values from a Class as Arguments for Another Class](https://discourse.processing.org/t/using-values-from-a-class-as-arguments-for-another-class/21601)

<div class="topic-metadata">

**Author:** [@brent](https://discourse.processing.org/u/brent)\
**Replies:** 3\
**Last updated:** [June 6, 2020, 3:42pm UTC](https://discourse.processing.org/t/using-values-from-a-class-as-arguments-for-another-class/21601 "2020-06-06T15:42:00Z")

</div>

I’m trying to make the code I have for a basic painting sketch more efficient, so I made classes for the color sliders and the brush. I’m trying to set the arguments for Brush() using the values from each colorSlider\[\]. …

---

## [Map() value to fit screen](https://discourse.processing.org/t/map-value-to-fit-screen/21558)

<div class="topic-metadata">

**Author:** [@mockingjay](https://discourse.processing.org/u/mockingjay)\
**Replies:** 11\
**Last updated:** [June 5, 2020, 6:13pm UTC](https://discourse.processing.org/t/map-value-to-fit-screen/21558 "2020-06-05T18:13:48Z")

</div>

void setup() { size(1280,720); background(0); } float currentVal = 0; float reading = 0; float value = -150; void draw() { reading = getData(); map(reading, -150,height,0,height/2); currentVal += (reading - cu…

---

## [Custom mouse cursor](https://discourse.processing.org/t/custom-mouse-cursor/21549)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 6\
**Last updated:** [June 5, 2020, 4:48am UTC](https://discourse.processing.org/t/custom-mouse-cursor/21549 "2020-06-05T04:48:16Z")

</div>

how can i customize the cursor that is displayed inside Processing 3, for example, make it appear as a custom png image instead of the OS’s cursor image

---

## [Simple way to create this diagram using pythagoras theorem](https://discourse.processing.org/t/simple-way-to-create-this-diagram-using-pythagoras-theorem/21583)

<div class="topic-metadata">

**Author:** [@leronix](https://discourse.processing.org/u/leronix)\
**Replies:** 2\
**Last updated:** [June 5, 2020, 11:00am UTC](https://discourse.processing.org/t/simple-way-to-create-this-diagram-using-pythagoras-theorem/21583 "2020-06-05T11:00:28Z")

</div>

int a; int c; int b = sqrt(aa+cc);

---

## [Per-vertex color gradient fill](https://discourse.processing.org/t/per-vertex-color-gradient-fill/9679)

<div class="topic-metadata">

**Author:** [@cdaein](https://discourse.processing.org/u/cdaein)\
**Replies:** 14\
**Last updated:** [June 5, 2020, 9:18am UTC](https://discourse.processing.org/t/per-vertex-color-gradient-fill/9679 "2020-06-05T09:18:44Z")

</div>

I’m trying to color each vertex of a rectangle differently to create a nice, smooth gradient fill inside. But when I run the sketch below, it looks like the shapes are broken into triangles and I see a clear band - is th…

---

## [Processing match 3](https://discourse.processing.org/t/processing-match-3/21507)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 16\
**Last updated:** [June 5, 2020, 12:13am UTC](https://discourse.processing.org/t/processing-match-3/21507 "2020-06-05T00:13:10Z")

</div>

I’m making a match 3 game or at least I think it still called match 3. Anyways you click on a block and all the blocks touching that one of the same type vanish too. My problem is diagonal blocks are being chosen instead…

---

## [I need help please! Mario](https://discourse.processing.org/t/i-need-help-please-mario/21409)

<div class="topic-metadata">

**Author:** [@jasmine](https://discourse.processing.org/u/jasmine)\
**Replies:** 13\
**Last updated:** [June 4, 2020, 11:57pm UTC](https://discourse.processing.org/t/i-need-help-please-mario/21409 "2020-06-04T23:57:07Z")

</div>

int gameMode=0;//0 - menu, 1 - play game, 2 - instructions, 3 - character selection int selChar=1;//default character is "character 1" int level=1; color red=color(255, 0, 0); color green=color(0, 255, 0); color blue=col…

---

## [Calculating spin physics](https://discourse.processing.org/t/calculating-spin-physics/21289)

<div class="topic-metadata">

**Author:** [@markcosmic](https://discourse.processing.org/u/markcosmic)\
**Replies:** 10\
**Last updated:** [June 4, 2020, 7:36pm UTC](https://discourse.processing.org/t/calculating-spin-physics/21289 "2020-06-04T19:36:58Z")

</div>

Greetings all, Without using one of the physics engine libraries, I’d like to calculate the spin of a ball bouncing off a boundary. As I understand it, the algorithm has to do with the ball’s velocity and the angle betw…

---

## [PGraphics recreation safely](https://discourse.processing.org/t/pgraphics-recreation-safely/21468)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 13\
**Last updated:** [June 4, 2020, 12:45pm UTC](https://discourse.processing.org/t/pgraphics-recreation-safely/21468 "2020-06-04T12:45:07Z")

</div>

if a PGraphics object is recreated with a different size, does the user need to invoke setup() again or is it safe to just keep calling draw()

---

## [Quiz with XML need help](https://discourse.processing.org/t/quiz-with-xml-need-help/21514)

<div class="topic-metadata">

**Author:** [@s.k9](https://discourse.processing.org/u/s.k9)\
**Replies:** 19\
**Last updated:** [June 3, 2020, 9:16pm UTC](https://discourse.processing.org/t/quiz-with-xml-need-help/21514 "2020-06-03T21:16:44Z")

</div>

Hi all, I am new to both coding and this forum so sorry in advance for whatever errors I am probably already making. For context, for this project, we were provided with a code skeleton. Right now I am having trouble fig…

---

## [Is there an easier way to get the updated Pixels](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485)

<div class="topic-metadata">

**Author:** [@Moritz](https://discourse.processing.org/u/Moritz)\
**Replies:** 6\
**Last updated:** [June 3, 2020, 3:15pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485 "2020-06-03T15:15:46Z")

</div>

I want to get the pixels that were updated in code between a and b without comparing loadPixels () at a with loadPixels() at b. Is that possible? (-\> and how is that possible?)

---

## [Problems with this code (Help please)](https://discourse.processing.org/t/problems-with-this-code-help-please/21517)

<div class="topic-metadata">

**Author:** [@panic](https://discourse.processing.org/u/panic)\
**Replies:** 2\
**Last updated:** [June 3, 2020, 5:12am UTC](https://discourse.processing.org/t/problems-with-this-code-help-please/21517 "2020-06-03T05:12:58Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I am new to processing and am having trouble creating code. I’m using a face detector, but instead of a square I want the face to pixel that are…

---

## [Making a light inside the room](https://discourse.processing.org/t/making-a-light-inside-the-room/21164)

<div class="topic-metadata">

**Author:** [@alkyonemis](https://discourse.processing.org/u/alkyonemis)\
**Replies:** 14\
**Last updated:** [June 3, 2020, 7:00am UTC](https://discourse.processing.org/t/making-a-light-inside-the-room/21164 "2020-06-03T07:00:03Z")

</div>

Hi, I am a new coder on processing. Normally, my code is 1000 lines.However, I prepared for you a simple code that I can modify on my code. The project last date is very soon. So, please be poilte and gentle. The code wh…

---

## [Save drawn Constructs](https://discourse.processing.org/t/save-drawn-constructs/21473)

<div class="topic-metadata">

**Author:** [@Moritz](https://discourse.processing.org/u/Moritz)\
**Replies:** 9\
**Last updated:** [June 2, 2020, 3:20pm UTC](https://discourse.processing.org/t/save-drawn-constructs/21473 "2020-06-02T15:20:00Z")

</div>

Hello. I want to save drawn constructs, if they are too big to recalculate every tick. I don’t know exactly how it works, but I think it works with PMatrix. My Idea was: ConstructXY x; void setup(){ x = new ConstructXY…

---

## [Size() Bug in Processing 3.5.4](https://discourse.processing.org/t/size-bug-in-processing-3-5-4/21431)

<div class="topic-metadata">

**Author:** [@brent](https://discourse.processing.org/u/brent)\
**Replies:** 5\
**Last updated:** [June 2, 2020, 3:13pm UTC](https://discourse.processing.org/t/size-bug-in-processing-3-5-4/21431 "2020-06-02T15:13:38Z")

</div>

I’m trying to position rectangles for the UI of a basic painting program in relation to the Width and Height of the window. I’ve looked elsewhere and found I should introduce ‘size()’ in ‘settings()’ as opposed to ‘setup…

---

## [Why doesn't this code work? (Noob question)](https://discourse.processing.org/t/why-doesnt-this-code-work-noob-question/21483)

<div class="topic-metadata">

**Author:** [@panic](https://discourse.processing.org/u/panic)\
**Replies:** 2\
**Last updated:** [June 2, 2020, 12:57pm UTC](https://discourse.processing.org/t/why-doesnt-this-code-work-noob-question/21483 "2020-06-02T12:57:45Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I am new to processing and I had doubts when creating a code for a project. I want that detecting the face with the camera produces changes in …

---

## [Passing a parameter through a thread](https://discourse.processing.org/t/passing-a-parameter-through-a-thread/21498)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 1\
**Last updated:** [June 2, 2020, 8:06am UTC](https://discourse.processing.org/t/passing-a-parameter-through-a-thread/21498 "2020-06-02T08:06:33Z")

</div>

Hi again everyone, currently stuck on a problem, I wish to create multiple threads to maximize cpu usage as I understand processing only uses the one thread by default, (perhaps this is java by default). I have done some…

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

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