# Coding Questions

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

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

**Page:** 72

---

## [This ball goes through the rectangle rather than hitting it or bouncing it](https://discourse.processing.org/t/this-ball-goes-through-the-rectangle-rather-than-hitting-it-or-bouncing-it/25783)

<div class="topic-metadata">

**Author:** [@Waka](https://discourse.processing.org/u/Waka)\
**Replies:** 66\
**Last updated:** [November 29, 2020, 5:05pm UTC](https://discourse.processing.org/t/this-ball-goes-through-the-rectangle-rather-than-hitting-it-or-bouncing-it/25783 "2020-11-29T17:05:50Z")

</div>

Hi, Can you please help to make the ball hit the rectangle rather than go through the rectangle float ballx,bally,xspeed=5,yspeed=8; void setup() { size(displayWidth,displayHeight); stroke(255); strokeWeight(100); } v…

---

## [Save when app close, exit() ... stop()](https://discourse.processing.org/t/save-when-app-close-exit-stop/25754)

<div class="topic-metadata">

**Author:** [@matheplica](https://discourse.processing.org/u/matheplica)\
**Replies:** 7\
**Last updated:** [November 29, 2020, 12:25pm UTC](https://discourse.processing.org/t/save-when-app-close-exit-stop/25754 "2020-11-29T12:25:32Z")

</div>

Hi, I’m trying to save data when my app close either with mouse or ESC button. I try with exit() and stop() with any result. this is my code void stop(){ saveSlides(); exit(); } Thanks

---

## [Generative Patterns Processing Poster](https://discourse.processing.org/t/generative-patterns-processing-poster/25721)

<div class="topic-metadata">

**Author:** [@angela1811](https://discourse.processing.org/u/angela1811)\
**Replies:** 14\
**Last updated:** [November 29, 2020, 11:43am UTC](https://discourse.processing.org/t/generative-patterns-processing-poster/25721 "2020-11-29T11:43:28Z")

</div>

Hello everyone, I am a newbie in Processing! I have to submit a project very soon for the final exam at university T^T But it’s so sad I’m stuck with my project. I have to create a programming poster but I’m don’t have…

---

## [How do I change the size of the display window?](https://discourse.processing.org/t/how-do-i-change-the-size-of-the-display-window/25384)

<div class="topic-metadata">

**Author:** [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Replies:** 27\
**Last updated:** [November 29, 2020, 12:57am UTC](https://discourse.processing.org/t/how-do-i-change-the-size-of-the-display-window/25384 "2020-11-29T00:57:34Z")

</div>

So, I was tampering around with the “setResizable” feature in Processing. I was pretty satisfied with the results, when combined with the “scale” function and the “PMatrix” class, I can basically resize the entire sketc…

---

## [Random() seems to be very biased towards positive numbers. how to mitigate?](https://discourse.processing.org/t/random-seems-to-be-very-biased-towards-positive-numbers-how-to-mitigate/25749)

<div class="topic-metadata">

**Author:** [@exe](https://discourse.processing.org/u/exe)\
**Replies:** 10\
**Last updated:** [November 29, 2020, 12:19am UTC](https://discourse.processing.org/t/random-seems-to-be-very-biased-towards-positive-numbers-how-to-mitigate/25749 "2020-11-29T00:19:09Z")

</div>

My level of expertise is pretty low, I have some mild background in Java and QBasic way back when, and otherwise have learned most of the little I know via Daniel’s YT tuts (of which I’ve still many to go through). But …

---

## [How to make a rectangle spawn when mouseclicked and will bounce](https://discourse.processing.org/t/how-to-make-a-rectangle-spawn-when-mouseclicked-and-will-bounce/25742)

<div class="topic-metadata">

**Author:** [@0w3n928](https://discourse.processing.org/u/0w3n928)\
**Replies:** 2\
**Last updated:** [November 28, 2020, 6:51pm UTC](https://discourse.processing.org/t/how-to-make-a-rectangle-spawn-when-mouseclicked-and-will-bounce/25742 "2020-11-28T18:51:13Z")

</div>

I’m trying to make another rectangle spawn when mouse is clicked once and it will collide to my first bouncing rectangle and I can add however many i want but my code doesn’t even need me to click and it doesn’t really w…

---

## [Random elements different positions](https://discourse.processing.org/t/random-elements-different-positions/16984)

<div class="topic-metadata">

**Author:** [@San](https://discourse.processing.org/u/San)\
**Replies:** 4\
**Last updated:** [November 28, 2020, 6:33pm UTC](https://discourse.processing.org/t/random-elements-different-positions/16984 "2020-11-28T18:33:17Z")

</div>

Hi I want to draw squares on random positions on a grid, but I don’t want to have them on the same position. If I run the code sometimes there are two squares on the same position. I know that it has something to do wit…

---

## [Food Drop from an Airplane](https://discourse.processing.org/t/food-drop-from-an-airplane/25782)

<div class="topic-metadata">

**Author:** [@Elo](https://discourse.processing.org/u/Elo)\
**Replies:** 1\
**Last updated:** [November 28, 2020, 5:36pm UTC](https://discourse.processing.org/t/food-drop-from-an-airplane/25782 "2020-11-28T17:36:43Z")

</div>

I don’t know what I’m doing wrong and I don’t understand processing that well; Can Someone help me fix the issues and bugs in my program \[details=“Summary”\] This text will be hidden //plane coordinates int planeX…

---

## [I am going to do a roll dice game](https://discourse.processing.org/t/i-am-going-to-do-a-roll-dice-game/25780)

<div class="topic-metadata">

**Author:** [@mengtong](https://discourse.processing.org/u/mengtong)\
**Replies:** 2\
**Last updated:** [November 28, 2020, 12:26pm UTC](https://discourse.processing.org/t/i-am-going-to-do-a-roll-dice-game/25780 "2020-11-28T12:26:52Z")

</div>

Here is my code, now I can roll my dice. But I want the only dice or dices I choose to re-roll, others ignore. I didt finish reroll function. I dont know how to do it. Can someone give me some suggest? final int NUM\_SID…

---

## [Transparency in save() function](https://discourse.processing.org/t/transparency-in-save-function/25699)

<div class="topic-metadata">

**Author:** [@yanze03](https://discourse.processing.org/u/yanze03)\
**Replies:** 14\
**Last updated:** [November 28, 2020, 9:22am UTC](https://discourse.processing.org/t/transparency-in-save-function/25699 "2020-11-28T09:22:35Z")

</div>

So I made this code where you can draw and create an image. This works just fine but is it possible to get an image with a transparant background? Is there like a function to remove everything with RGB code white in a ce…

---

## [How to capture an area of pixels ? - Pro3 - Fr/En](https://discourse.processing.org/t/how-to-capture-an-area-of-pixels-pro3-fr-en/25747)

<div class="topic-metadata">

**Author:** [@Eli0kYd](https://discourse.processing.org/u/Eli0kYd)\
**Replies:** 4\
**Last updated:** [November 27, 2020, 3:33pm UTC](https://discourse.processing.org/t/how-to-capture-an-area-of-pixels-pro3-fr-en/25747 "2020-11-27T15:33:16Z")

</div>

Hello ! I’m still new to processing and code in general. I might ask a lot so I take everything you could give to me ! I’m here to ask you what title already announces : How to capture an area of pixel and to transpose…

---

## [Unexpected token: void](https://discourse.processing.org/t/unexpected-token-void/25757)

<div class="topic-metadata">

**Author:** [@muffininwinter](https://discourse.processing.org/u/muffininwinter)\
**Replies:** 3\
**Last updated:** [November 27, 2020, 2:48pm UTC](https://discourse.processing.org/t/unexpected-token-void/25757 "2020-11-27T14:48:02Z")

</div>

boolean running = false; PImage imgbk; PImage imgm; PImage albert; PImage imgnote; PImage\[\] img = new PImage\[2\]; int totalNum = 4; int dx, dy; int score; int startTime; int albertX, albertY, albertW, albertH; …

---

## [How do i add colour to each one of the 10 boxes i made](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739)

<div class="topic-metadata">

**Author:** [@DijaAngel](https://discourse.processing.org/u/DijaAngel)\
**Replies:** 3\
**Last updated:** [November 27, 2020, 2:25pm UTC](https://discourse.processing.org/t/how-do-i-add-colour-to-each-one-of-the-10-boxes-i-made/25739 "2020-11-27T14:25:27Z")

</div>

please format code with \</\> button \* homework policy \* asking questions void setup(){ size(500,500); } void draw(){ for(int i=0;i\<=450;i+=50){ rect(0,i,50,50); } }

---

## [I have a rectangle that will bounce but i want it to change colour whenever it hits a side](https://discourse.processing.org/t/i-have-a-rectangle-that-will-bounce-but-i-want-it-to-change-colour-whenever-it-hits-a-side/25745)

<div class="topic-metadata">

**Author:** [@0w3n928](https://discourse.processing.org/u/0w3n928)\
**Replies:** 2\
**Last updated:** [November 27, 2020, 6:45am UTC](https://discourse.processing.org/t/i-have-a-rectangle-that-will-bounce-but-i-want-it-to-change-colour-whenever-it-hits-a-side/25745 "2020-11-27T06:45:31Z")

</div>

I cant seem to make this work but it changes colour but breaks the thing float rectx,recty,xspeed=7,yspeed=7; color bg = color(random(255),random(255),random(255)); void setup() { fullScreen(); } void draw() { bac…

---

## [I want to make a rectangle that will spawn when mouseclicked and bounce back and collide with another rectangle](https://discourse.processing.org/t/i-want-to-make-a-rectangle-that-will-spawn-when-mouseclicked-and-bounce-back-and-collide-with-another-rectangle/25743)

<div class="topic-metadata">

**Author:** [@0w3n928](https://discourse.processing.org/u/0w3n928)\
**Replies:** 0\
**Last updated:** [November 27, 2020, 1:02am UTC](https://discourse.processing.org/t/i-want-to-make-a-rectangle-that-will-spawn-when-mouseclicked-and-bounce-back-and-collide-with-another-rectangle/25743 "2020-11-27T01:02:43Z")

</div>

I’m trying to make another rectangle spawn when mouse is clicked once and it will collide to my first bouncing rectangle and I can add however many i want but my code doesn’t even need me to click and it doesn’t really w…

---

## [A game where there are circles and you press on them and they dissapear in processing](https://discourse.processing.org/t/a-game-where-there-are-circles-and-you-press-on-them-and-they-dissapear-in-processing/25729)

<div class="topic-metadata">

**Author:** [@JakeTheFake](https://discourse.processing.org/u/JakeTheFake)\
**Replies:** 6\
**Last updated:** [November 26, 2020, 7:11pm UTC](https://discourse.processing.org/t/a-game-where-there-are-circles-and-you-press-on-them-and-they-dissapear-in-processing/25729 "2020-11-26T19:11:38Z")

</div>

I need help, could someone give me code for processing not j5.js for a game that has circles where you press on them and they dissapear please. I really need an example asap and it would be amazing if you could give me o…

---

## [Drawing a second instance of a ball class in a game](https://discourse.processing.org/t/drawing-a-second-instance-of-a-ball-class-in-a-game/25713)

<div class="topic-metadata">

**Author:** [@Manoplo](https://discourse.processing.org/u/Manoplo)\
**Replies:** 8\
**Last updated:** [November 26, 2020, 11:27am UTC](https://discourse.processing.org/t/drawing-a-second-instance-of-a-ball-class-in-a-game/25713 "2020-11-26T11:27:52Z")

</div>

Hello everyone! Pretty new into processing and into programming as well! So first of all, I´d like to apologize if the format is wrong or if my doubt has been solved before (I´ve been trying to find a solution for two d…

---

## [Help to make a radio button class](https://discourse.processing.org/t/help-to-make-a-radio-button-class/25716)

<div class="topic-metadata">

**Author:** [@datacolor](https://discourse.processing.org/u/datacolor)\
**Replies:** 3\
**Last updated:** [November 25, 2020, 11:38pm UTC](https://discourse.processing.org/t/help-to-make-a-radio-button-class/25716 "2020-11-25T23:38:09Z")

</div>

I found the code for a button class and I managed to make a sketch that makes a check button, but now I need help to make a sketch of several option or radio buttons using this button class, since the controlP5 library i…

---

## [Solar system with multiple planets](https://discourse.processing.org/t/solar-system-with-multiple-planets/25671)

<div class="topic-metadata">

**Author:** [@N\_G](https://discourse.processing.org/u/N_G)\
**Replies:** 2\
**Last updated:** [November 25, 2020, 8:21pm UTC](https://discourse.processing.org/t/solar-system-with-multiple-planets/25671 "2020-11-25T20:21:33Z")

</div>

Hi, I’m just starting out with processing and I’m trying to build a little solar system. My problem is that I don’t know how to add another planet (like mars or venus). Because if I just ad the planet to my code it wil…

---

## [Need help making background transparent](https://discourse.processing.org/t/need-help-making-background-transparent/25700)

<div class="topic-metadata">

**Author:** [@Sijht](https://discourse.processing.org/u/Sijht)\
**Replies:** 2\
**Last updated:** [November 25, 2020, 4:51pm UTC](https://discourse.processing.org/t/need-help-making-background-transparent/25700 "2020-11-25T16:51:49Z")

</div>

I tried a lot of methods i saw, but none of them seem to work. I am trying to take an image, save it and when I paste it into my canvas turn the white pixels into transparent. here is some code that I have written so f…

---

## [Colour Change Of Ellipse](https://discourse.processing.org/t/colour-change-of-ellipse/25697)

<div class="topic-metadata">

**Author:** [@Tyler](https://discourse.processing.org/u/Tyler)\
**Replies:** 1\
**Last updated:** [November 25, 2020, 1:11pm UTC](https://discourse.processing.org/t/colour-change-of-ellipse/25697 "2020-11-25T13:11:01Z")

</div>

I’ve been trying to make a code where if I press a specific box it will change the colour of the pen (that I’m using ellipse to make). I was able to make it change to red when I press a certain box but I can’t make it do…

---

## [Counter that increases with mouse click](https://discourse.processing.org/t/counter-that-increases-with-mouse-click/25342)

<div class="topic-metadata">

**Author:** [@thedarklord](https://discourse.processing.org/u/thedarklord)\
**Replies:** 9\
**Last updated:** [November 25, 2020, 10:41am UTC](https://discourse.processing.org/t/counter-that-increases-with-mouse-click/25342 "2020-11-25T10:41:53Z")

</div>

I’m making a simple game in which I want a counter which invreases every time an object is clicked.

---

## [URGENT: How to repeat an image movement per second](https://discourse.processing.org/t/urgent-how-to-repeat-an-image-movement-per-second/25683)

<div class="topic-metadata">

**Author:** [@tank](https://discourse.processing.org/u/tank)\
**Replies:** 16\
**Last updated:** [November 25, 2020, 10:24am UTC](https://discourse.processing.org/t/urgent-how-to-repeat-an-image-movement-per-second/25683 "2020-11-25T10:24:00Z")

</div>

I would like drop either 2 imageA or 1 imageB from the y = 0 border / upper border by using a coin to decide which to fall. I am using Processing 2.2.1. if (millis() - startTime \>= 1000) { float coin = random(1, 100…

---

## [ArrayList - having different images when moving using arrow keys](https://discourse.processing.org/t/arraylist-having-different-images-when-moving-using-arrow-keys/25669)

<div class="topic-metadata">

**Author:** [@TheGullible1](https://discourse.processing.org/u/TheGullible1)\
**Replies:** 15\
**Last updated:** [November 24, 2020, 8:59pm UTC](https://discourse.processing.org/t/arraylist-having-different-images-when-moving-using-arrow-keys/25669 "2020-11-24T20:59:47Z")

</div>

Hi, I’m using ArrayList to store the multiple amounts of images I have. i want to do is if I move left by using arrow keys, the images that pointing towards left move etc. this goes for up, down and right as well. code …

---

## [2D, Changing sprite set based on direction of movement](https://discourse.processing.org/t/2d-changing-sprite-set-based-on-direction-of-movement/25672)

<div class="topic-metadata">

**Author:** [@Myth](https://discourse.processing.org/u/Myth)\
**Replies:** 3\
**Last updated:** [November 24, 2020, 8:28pm UTC](https://discourse.processing.org/t/2d-changing-sprite-set-based-on-direction-of-movement/25672 "2020-11-24T20:28:19Z")

</div>

Hello everybody. I’m trying to make a simple “game” if it could even be called that, in which i have a character moving in the 4 main directions (up/down/left/right) with the WASD keys, using the following code void mo…

---

## [Remove the first character from a string when keyPressed is equal to the character](https://discourse.processing.org/t/remove-the-first-character-from-a-string-when-keypressed-is-equal-to-the-character/25598)

<div class="topic-metadata">

**Author:** [@vestergaard12](https://discourse.processing.org/u/vestergaard12)\
**Replies:** 3\
**Last updated:** [November 24, 2020, 6:31pm UTC](https://discourse.processing.org/t/remove-the-first-character-from-a-string-when-keypressed-is-equal-to-the-character/25598 "2020-11-24T18:31:56Z")

</div>

Hello processing foundation. I want to remove the first character from a string when the key pressed is equal to the first character. For example if the string word is “hello”, when I want the “h” in the word to be remo…

---

## [Remove Trail, can't figure out how (bot follows a random walker)](https://discourse.processing.org/t/remove-trail-cant-figure-out-how-bot-follows-a-random-walker/25616)

<div class="topic-metadata">

**Author:** [@noobcoder](https://discourse.processing.org/u/noobcoder)\
**Replies:** 6\
**Last updated:** [November 24, 2020, 3:42pm UTC](https://discourse.processing.org/t/remove-trail-cant-figure-out-how-bot-follows-a-random-walker/25616 "2020-11-24T15:42:27Z")

</div>

Hello, I have two random walkers. One of them(AntC) leaves a trail and the other one(AntD) is suppose to pick it up. How can i do this. AntC \[\] armyC = new AntC\[1\]; AntD \[\] armyD = new AntD\[1\]; void setup() { size(90…

---

## [How to make: if timer is finished end game](https://discourse.processing.org/t/how-to-make-if-timer-is-finished-end-game/25661)

<div class="topic-metadata">

**Author:** [@TheGullible1](https://discourse.processing.org/u/TheGullible1)\
**Replies:** 2\
**Last updated:** [November 24, 2020, 11:39am UTC](https://discourse.processing.org/t/how-to-make-if-timer-is-finished-end-game/25661 "2020-11-24T11:39:17Z")

</div>

Hi, I’m tryna make an if statement consisting of my timer and how to end the game after my countdown of 60 seconds has finished. i have a class called countdown: class CountDown //start of CountDown class { private …

---

## [How to make particles with tails on the picture](https://discourse.processing.org/t/how-to-make-particles-with-tails-on-the-picture/24941)

<div class="topic-metadata">

**Author:** [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Replies:** 5\
**Last updated:** [November 24, 2020, 8:46am UTC](https://discourse.processing.org/t/how-to-make-particles-with-tails-on-the-picture/24941 "2020-11-24T08:46:22Z")

</div>

Hi. I want to know how to make particles with tails on the picture? I try to do this. But it not work. :confounded:

---

## [Curved Vertex Drawing Dilemma](https://discourse.processing.org/t/curved-vertex-drawing-dilemma/25653)

<div class="topic-metadata">

**Author:** [@lkalotihos](https://discourse.processing.org/u/lkalotihos)\
**Replies:** 1\
**Last updated:** [November 24, 2020, 8:42am UTC](https://discourse.processing.org/t/curved-vertex-drawing-dilemma/25653 "2020-11-24T08:42:37Z")

</div>

I’m having some issues with my curved vertex drawing. I’ve set it up so the x/y coordinates display as my mouse moves, so it would be easier to get the exact sketch I want. Except for some reason, it’s still not displayi…

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

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