# Coding Questions

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

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

**Page:** 105

---

## [Could someone explain this code to me](https://discourse.processing.org/t/could-someone-explain-this-code-to-me/18767)

<div class="topic-metadata">

**Author:** [@vincentstrebelle](https://discourse.processing.org/u/vincentstrebelle)\
**Replies:** 18\
**Last updated:** [March 18, 2020, 3:50pm UTC](https://discourse.processing.org/t/could-someone-explain-this-code-to-me/18767 "2020-03-18T15:50:52Z")

</div>

Hi everyone, I wonder if someone can explaine to me how this code work : int locX, locY; int offsetX, offsetY; final int unit = 32; byte\[\]\[\] terrain = new byte\[10\]\[10\]; void setup() { size(321, 321); for (int …

---

## [Background appearing above array of images](https://discourse.processing.org/t/background-appearing-above-array-of-images/18746)

<div class="topic-metadata">

**Author:** [@jake\_b](https://discourse.processing.org/u/jake_b)\
**Replies:** 2\
**Last updated:** [March 18, 2020, 2:56pm UTC](https://discourse.processing.org/t/background-appearing-above-array-of-images/18746 "2020-03-18T14:56:58Z")

</div>

Hi everyone, I’ve got an issue whereby an array of images I’ve got loading as a grid is appearing behind the background. In the pen I’ve attached the images have been replaced with rectangles, but hopefully the issue can…

---

## [How to move a object, not in draw()](https://discourse.processing.org/t/how-to-move-a-object-not-in-draw/18761)

<div class="topic-metadata">

**Author:** [@Mike2020](https://discourse.processing.org/u/Mike2020)\
**Replies:** 4\
**Last updated:** [March 18, 2020, 12:57pm UTC](https://discourse.processing.org/t/how-to-move-a-object-not-in-draw/18761 "2020-03-18T12:57:31Z")

</div>

Hi folks, how to move a object, not in draw()? I make a function ship(), how can I make the ship() move from one point to another point slowly ? Is there any function relate to time, for example ship() can move from poi…

---

## [Trouble using mouse events to control movement of an object](https://discourse.processing.org/t/trouble-using-mouse-events-to-control-movement-of-an-object/18553)

<div class="topic-metadata">

**Author:** [@Irhutchi](https://discourse.processing.org/u/Irhutchi)\
**Replies:** 10\
**Last updated:** [March 17, 2020, 3:33pm UTC](https://discourse.processing.org/t/trouble-using-mouse-events-to-control-movement-of-an-object/18553 "2020-03-17T15:33:30Z")

</div>

Hi, I am working on a project and am relatively new to programming. I am have setup a ball class outside of main tab and am having trouble with using mouse events inside the ball class which are then called in the draw()…

---

## [Display text on image](https://discourse.processing.org/t/display-text-on-image/18731)

<div class="topic-metadata">

**Author:** [@ej8000](https://discourse.processing.org/u/ej8000)\
**Replies:** 3\
**Last updated:** [March 17, 2020, 1:50pm UTC](https://discourse.processing.org/t/display-text-on-image/18731 "2020-03-17T13:50:32Z")

</div>

how can I write text on Image or shape ,and become(the image and the text) one unit,so when i drag the image,also the text within it is dragged.

---

## [Closing only PApplet with exit() code](https://discourse.processing.org/t/closing-only-papplet-with-exit-code/18591)

<div class="topic-metadata">

**Author:** [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Replies:** 5\
**Last updated:** [March 17, 2020, 9:33am UTC](https://discourse.processing.org/t/closing-only-papplet-with-exit-code/18591 "2020-03-17T09:33:11Z")

</div>

Hello, i want to close only PApplet, with close button and with self exit() event when i do somethink, for exemple in this, i just click, and want to end only “AnotherWindow” applet, how to do it ? PApplet cf; void set…

---

## [Array true o false cambio colore](https://discourse.processing.org/t/array-true-o-false-cambio-colore/18700)

<div class="topic-metadata">

**Author:** [@marika20](https://discourse.processing.org/u/marika20)\
**Replies:** 4\
**Last updated:** [March 17, 2020, 9:03am UTC](https://discourse.processing.org/t/array-true-o-false-cambio-colore/18700 "2020-03-17T09:03:10Z")

</div>

Ciao a tutti! Ho un blocco per quanto riguarda un codice che sto scrivendo, il mio obbiettivo è quello di far in modo che nel momento in cui ho un valore true i rettangoli assumano un determinato colore e nel caso fosse…

---

## [Move an ellipse](https://discourse.processing.org/t/move-an-ellipse/18717)

<div class="topic-metadata">

**Author:** [@NotConsumable](https://discourse.processing.org/u/NotConsumable)\
**Replies:** 2\
**Last updated:** [March 17, 2020, 6:54am UTC](https://discourse.processing.org/t/move-an-ellipse/18717 "2020-03-17T06:54:31Z")

</div>

I was wondering how I would make an ellipse continuously move down a x axis while maintaining it’s Y position, in better terms I am trying to make an ellipse start at one end of the canvas and continue down to the other …

---

## [GUI Buttons - Need help](https://discourse.processing.org/t/gui-buttons-need-help/18705)

<div class="topic-metadata">

**Author:** [@The-Coder](https://discourse.processing.org/u/The-Coder)\
**Replies:** 3\
**Last updated:** [March 17, 2020, 5:51am UTC](https://discourse.processing.org/t/gui-buttons-need-help/18705 "2020-03-17T05:51:01Z")

</div>

I have been making a small video game that has buttons on the start screen to show the credits and start the game. The buttons don’t work and the credits screen displays without the credits button being pressed. I would …

---

## [Help creating pronunciation program](https://discourse.processing.org/t/help-creating-pronunciation-program/18453)

<div class="topic-metadata">

**Author:** [@Burgs](https://discourse.processing.org/u/Burgs)\
**Replies:** 11\
**Last updated:** [March 16, 2020, 4:38pm UTC](https://discourse.processing.org/t/help-creating-pronunciation-program/18453 "2020-03-16T16:38:42Z")

</div>

i need help finishing an assignment, it includes getting input from the user and scanning each letter/character to see where it corresponds to with my if statements and printing out the pronunciation of the word in the c…

---

## [Making game less laggy](https://discourse.processing.org/t/making-game-less-laggy/18685)

<div class="topic-metadata">

**Author:** [@Salttt](https://discourse.processing.org/u/Salttt)\
**Replies:** 14\
**Last updated:** [March 16, 2020, 2:41pm UTC](https://discourse.processing.org/t/making-game-less-laggy/18685 "2020-03-16T14:41:04Z")

</div>

I am working on a simple game (I’m a beginner) in which the player jumps up platforms. Currently, there is only one screen and a level creator. The way it works right now, I mean only the basics of creating levels, is in…

---

## [Rotating rectangles to face mouseX, mouseY](https://discourse.processing.org/t/rotating-rectangles-to-face-mousex-mousey/18690)

<div class="topic-metadata">

**Author:** [@spoke123](https://discourse.processing.org/u/spoke123)\
**Replies:** 3\
**Last updated:** [March 16, 2020, 1:34pm UTC](https://discourse.processing.org/t/rotating-rectangles-to-face-mousex-mousey/18690 "2020-03-16T13:34:07Z")

</div>

Hi everyone! I’ve taken a few years out from using processing so I’m sorry if I’m missing something pretty basic! I’m trying to individually rotate each rectangle generated from a nested for loop to face the mouse coord…

---

## [Trouble detecting the right position of the mouse for list of buttons](https://discourse.processing.org/t/trouble-detecting-the-right-position-of-the-mouse-for-list-of-buttons/18612)

<div class="topic-metadata">

**Author:** [@Rrwwvds](https://discourse.processing.org/u/Rrwwvds)\
**Replies:** 7\
**Last updated:** [March 16, 2020, 12:45pm UTC](https://discourse.processing.org/t/trouble-detecting-the-right-position-of-the-mouse-for-list-of-buttons/18612 "2020-03-16T12:45:33Z")

</div>

Hey guys, I’m fairly new to processing but i’m just starting to get the hang of it. I’ve been working on a program in which I can click checkboxes which results in a building up score. when trying to make the checkboxe…

---

## [Random probability (Customizing random function)](https://discourse.processing.org/t/random-probability-customizing-random-function/18571)

<div class="topic-metadata">

**Author:** [@noel](https://discourse.processing.org/u/noel)\
**Replies:** 7\
**Last updated:** [March 16, 2020, 10:44am UTC](https://discourse.processing.org/t/random-probability-customizing-random-function/18571 "2020-03-16T10:44:21Z")

</div>

My goal is to give a linear probability to the random function. That is, to give a higher probabiliy as lower the number\`in a linear way. However the code below gives a parabola like outcome… Where am I wrong in my lo…

---

## [Check if a field is true or false with reflections](https://discourse.processing.org/t/check-if-a-field-is-true-or-false-with-reflections/18692)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 1\
**Last updated:** [March 16, 2020, 7:43am UTC](https://discourse.processing.org/t/check-if-a-field-is-true-or-false-with-reflections/18692 "2020-03-16T07:43:32Z")

</div>

Currently trying to code some menu functionality and wondered if there’s a way to find out if a boolean field is true or false. This is the code I’m currently trying but I get an error try{ field = a.get…

---

## [Need help on processing game frogger](https://discourse.processing.org/t/need-help-on-processing-game-frogger/5808)

<div class="topic-metadata">

**Author:** [@Hunter\_noob](https://discourse.processing.org/u/Hunter_noob)\
**Replies:** 9\
**Last updated:** [November 23, 2018, 3:22pm UTC](https://discourse.processing.org/t/need-help-on-processing-game-frogger/5808 "2018-11-23T15:22:46Z")

</div>

Hi guys, I am creating a game called frogger, and I’m confused about why my codes not working. Hope get some help here. I created the hazards, but I can’t move them, tried many ways to fix but still failed :\< (move to…

---

## [Error with set texture when I increment my array index](https://discourse.processing.org/t/error-with-set-texture-when-i-increment-my-array-index/18672)

<div class="topic-metadata">

**Author:** [@Eyetoof](https://discourse.processing.org/u/Eyetoof)\
**Replies:** 2\
**Last updated:** [March 16, 2020, 2:18am UTC](https://discourse.processing.org/t/error-with-set-texture-when-i-increment-my-array-index/18672 "2020-03-16T02:18:37Z")

</div>

I am running into an issue when I try to set a texture to a PShape from an array in my project, and then increment the index to the array. This is my Array reference mndImg\[imgChsr\] I have a key press that just basical…

---

## [Scroll menu issues](https://discourse.processing.org/t/scroll-menu-issues/18561)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 3\
**Last updated:** [March 14, 2020, 9:48pm UTC](https://discourse.processing.org/t/scroll-menu-issues/18561 "2020-03-14T21:48:32Z")

</div>

How does one go about coding such a structure, I have an example however I’m not sure how to apply masks. The issue is that every list item has a particular height, and position, the scroll bar amends their position and …

---

## [Change text width or text height without changing size](https://discourse.processing.org/t/change-text-width-or-text-height-without-changing-size/18662)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [March 14, 2020, 9:45pm UTC](https://discourse.processing.org/t/change-text-width-or-text-height-without-changing-size/18662 "2020-03-14T21:45:46Z")

</div>

Is it possible in processing to change the text width or height without size?

---

## [Start position in "key pressed"](https://discourse.processing.org/t/start-position-in-key-pressed/18477)

<div class="topic-metadata">

**Author:** [@lemoskava](https://discourse.processing.org/u/lemoskava)\
**Replies:** 7\
**Last updated:** [March 14, 2020, 6:01pm UTC](https://discourse.processing.org/t/start-position-in-key-pressed/18477 "2020-03-14T18:01:55Z")

</div>

Hello! I am trying to create drawing letter, witch consist of ellipse. Every next letter type after key pressed. I can’t change fist position every next letter to create new letter after previous letter and gap space. e…

---

## [Using convolution to upscale an image](https://discourse.processing.org/t/using-convolution-to-upscale-an-image/18632)

<div class="topic-metadata">

**Author:** [@zcream](https://discourse.processing.org/u/zcream)\
**Replies:** 1\
**Last updated:** [March 13, 2020, 4:14am UTC](https://discourse.processing.org/t/using-convolution-to-upscale-an-image/18632 "2020-03-13T04:14:50Z")

</div>

I understand how write code to apply a convolution matrix to a pixel. :slight\_smile: Not that hard. Now each upscaling algorithm can be implemented using a convolution kernel. I am just not sure how to apply this to code…

---

## [Two elements crossing each other](https://discourse.processing.org/t/two-elements-crossing-each-other/18576)

<div class="topic-metadata">

**Author:** [@BallazX](https://discourse.processing.org/u/BallazX)\
**Replies:** 2\
**Last updated:** [March 13, 2020, 3:50am UTC](https://discourse.processing.org/t/two-elements-crossing-each-other/18576 "2020-03-13T03:50:47Z")

</div>

Hey guys, so I’ve faced a very simple issue but I cant get over it. I got a rect and a line crossing each other. I need the coordinate where they are crossing each other. How can I get this point? See me example below: …

---

## [Returning an object type from an arraylist](https://discourse.processing.org/t/returning-an-object-type-from-an-arraylist/16467)

<div class="topic-metadata">

**Author:** [@davidclue](https://discourse.processing.org/u/davidclue)\
**Replies:** 20\
**Last updated:** [March 13, 2020, 1:10am UTC](https://discourse.processing.org/t/returning-an-object-type-from-an-arraylist/16467 "2020-03-13T01:10:21Z")

</div>

Hi, I am trying to create a level editor for my game but I’ve encountered a problem where I want to select objects on the screen I tried to make an object called a Selector and change its value every time someone clicks …

---

## [setTexture() not working in PGraphics window](https://discourse.processing.org/t/settexture-not-working-in-pgraphics-window/18629)

<div class="topic-metadata">

**Author:** [@Java.SourceForger](https://discourse.processing.org/u/Java.SourceForger)\
**Replies:** 0\
**Last updated:** [March 12, 2020, 11:22pm UTC](https://discourse.processing.org/t/settexture-not-working-in-pgraphics-window/18629 "2020-03-12T23:22:49Z")

</div>

In my sketch, I have put my 3d rendering into a PGraphics object. But now, I have no way, whatsoever of drawing textures on PShape objects. The result is an invisible shape. Does anyone know what to do or has had this is…

---

## [Detecting edges in an array of coloured circles](https://discourse.processing.org/t/detecting-edges-in-an-array-of-coloured-circles/18534)

<div class="topic-metadata">

**Author:** [@Smuel](https://discourse.processing.org/u/Smuel)\
**Replies:** 17\
**Last updated:** [March 12, 2020, 10:11pm UTC](https://discourse.processing.org/t/detecting-edges-in-an-array-of-coloured-circles/18534 "2020-03-12T22:11:57Z")

</div>

Hi, I’m instantiating a grid of Circles and then using noise to fill each Circle with a perlin noise value based on an increment, if the brightness value of a circle exceeds an amount it will be filled green, if not it …

---

## [How to speed up texture() calls?](https://discourse.processing.org/t/how-to-speed-up-texture-calls/18414)

<div class="topic-metadata">

**Author:** [@George](https://discourse.processing.org/u/George)\
**Replies:** 2\
**Last updated:** [March 11, 2020, 9:29pm UTC](https://discourse.processing.org/t/how-to-speed-up-texture-calls/18414 "2020-03-11T21:29:49Z")

</div>

Hi, I’ve stumbled upon a weird issue on Windows I’m trying to get a workaround going. Here’s a basic sketch to replicate the issue: PImage texture; void setup(){ size(1280,720,P3D); texture = createImage(3840,…

---

## [Make an object variables change after interaction and change again after given amount of time](https://discourse.processing.org/t/make-an-object-variables-change-after-interaction-and-change-again-after-given-amount-of-time/18604)

<div class="topic-metadata">

**Author:** [@Nadiantara](https://discourse.processing.org/u/Nadiantara)\
**Replies:** 2\
**Last updated:** [March 11, 2020, 8:22pm UTC](https://discourse.processing.org/t/make-an-object-variables-change-after-interaction-and-change-again-after-given-amount-of-time/18604 "2020-03-11T20:22:46Z")

</div>

Let’s say I have two objects (b1 and b2) with different values of variables. When they are interacting, b2 has probability (let’s say 30%) to copying b1’s values. Then, after a given amount of time b2 will change its va…

---

## [Trying to change states using the dist function](https://discourse.processing.org/t/trying-to-change-states-using-the-dist-function/18606)

<div class="topic-metadata">

**Author:** [@Chriswolf378](https://discourse.processing.org/u/Chriswolf378)\
**Replies:** 13\
**Last updated:** [March 11, 2020, 7:12pm UTC](https://discourse.processing.org/t/trying-to-change-states-using-the-dist-function/18606 "2020-03-11T19:12:10Z")

</div>

Essentially what I want to happen is when the player hits a certain point the game will change to the next state at the moment I have this code: void checkWinLose(){ if (dist(x, y, 500.0 ,0.0) \< 45 ){ state …

---

## [Trying to rec a frame of my animation to SVG file](https://discourse.processing.org/t/trying-to-rec-a-frame-of-my-animation-to-svg-file/18516)

<div class="topic-metadata">

**Author:** [@JakeCodeNewbie](https://discourse.processing.org/u/JakeCodeNewbie)\
**Replies:** 1\
**Last updated:** [March 9, 2020, 8:01pm UTC](https://discourse.processing.org/t/trying-to-rec-a-frame-of-my-animation-to-svg-file/18516 "2020-03-09T20:01:56Z")

</div>

I am new to coding and I am working with this code to create a unique poster design using lines. I cannot successfully record a frame to an SVG file so I can use a pen plotter. I am sure I have a couple things out of ord…

---

## [Perplexity Boolean array](https://discourse.processing.org/t/perplexity-boolean-array/18594)

<div class="topic-metadata">

**Author:** [@marika20](https://discourse.processing.org/u/marika20)\
**Replies:** 2\
**Last updated:** [March 11, 2020, 2:38pm UTC](https://discourse.processing.org/t/perplexity-boolean-array/18594 "2020-03-11T14:38:39Z")

</div>

Hello everyone! I would like to ask for a hand: with this code that I wrote required uscrimi you must “true or false” values based on the randomNum values that I have assigned; instead I get only “false” values. Also I…

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

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