# Coding Questions

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

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

**Page:** 122

---

## [Rotation and Easing](https://discourse.processing.org/t/rotation-and-easing/5704)

<div class="topic-metadata">

**Author:** [@phoebus](https://discourse.processing.org/u/phoebus)\
**Replies:** 18\
**Last updated:** [November 3, 2019, 11:09pm UTC](https://discourse.processing.org/t/rotation-and-easing/5704 "2019-11-03T23:09:14Z")

</div>

Hello In my sketch I want to controle the rotation of a wheel and add a bit of easing to the rotation to give some feeling of weight to the wheel. I have it doing what I want but, the easing is messed up by the gap bet…

---

## [Rotate on Command](https://discourse.processing.org/t/rotate-on-command/14865)

<div class="topic-metadata">

**Author:** [@hahayes](https://discourse.processing.org/u/hahayes)\
**Replies:** 16\
**Last updated:** [November 3, 2019, 9:02pm UTC](https://discourse.processing.org/t/rotate-on-command/14865 "2019-11-03T21:02:46Z")

</div>

I am attempting to make a cube that can rotate in any direction on command. I am currently trying to see if I can make it rotate at all on command, and I think that it does rotate, but I am trying to think about how to a…

---

## [Event flow (Boolean values)](https://discourse.processing.org/t/event-flow-boolean-values/15142)

<div class="topic-metadata">

**Author:** [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Replies:** 13\
**Last updated:** [November 3, 2019, 8:17pm UTC](https://discourse.processing.org/t/event-flow-boolean-values/15142 "2019-11-03T20:17:46Z")

</div>

The following code works exactly as it should, but I want to understand the event flow. The change to varH should happen when the key is pressed and only happen once. Under void keyPressed() When the H or h key is pres…

---

## [Collision rect - ellipse : Multiple questions - More info in Body](https://discourse.processing.org/t/collision-rect-ellipse-multiple-questions-more-info-in-body/15155)

<div class="topic-metadata">

**Author:** [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Replies:** 18\
**Last updated:** [November 3, 2019, 8:05pm UTC](https://discourse.processing.org/t/collision-rect-ellipse-multiple-questions-more-info-in-body/15155 "2019-11-03T20:05:48Z")

</div>

How can I make that when the laser hits the rectangle that randomly spawns, the laser will just stop? Like it will not go any further but will stop? How can I make collision so my player (ellipse) will be not able t…

---

## [Marquee selection in P3D( and P2D) using offscreen PGraphicsbuffer](https://discourse.processing.org/t/marquee-selection-in-p3d-and-p2d-using-offscreen-pgraphicsbuffer/14749)

<div class="topic-metadata">

**Author:** [@mala](https://discourse.processing.org/u/mala)\
**Replies:** 4\
**Last updated:** [November 3, 2019, 5:18pm UTC](https://discourse.processing.org/t/marquee-selection-in-p3d-and-p2d-using-offscreen-pgraphicsbuffer/14749 "2019-11-03T17:18:03Z")

</div>

I’m currently using an offscreen buffer in a 3D view and also a 2D view to help select objects in a UI when the mouse is clicked. The method is basically similar to what @Quark has built for shapes3D i.e. assigning a un…

---

## [How to connect nodes and relocate them to the nearest grid location](https://discourse.processing.org/t/how-to-connect-nodes-and-relocate-them-to-the-nearest-grid-location/15131)

<div class="topic-metadata">

**Author:** [@oliviabertrum](https://discourse.processing.org/u/oliviabertrum)\
**Replies:** 17\
**Last updated:** [November 3, 2019, 4:32pm UTC](https://discourse.processing.org/t/how-to-connect-nodes-and-relocate-them-to-the-nearest-grid-location/15131 "2019-11-03T16:32:33Z")

</div>

hi everyone, i have a grid and have put nodes into my code, however i need the nodes to be connected to create a full shape like below. Also, i need help getting the nodes to move to the nearest grid location when the u…

---

## [Array of Circle-Buttons do not work!](https://discourse.processing.org/t/array-of-circle-buttons-do-not-work/15118)

<div class="topic-metadata">

**Author:** [@Noerre](https://discourse.processing.org/u/Noerre)\
**Replies:** 4\
**Last updated:** [November 3, 2019, 1:41pm UTC](https://discourse.processing.org/t/array-of-circle-buttons-do-not-work/15118 "2019-11-03T13:41:45Z")

</div>

Hello, the following program creates four circle-buttons in an array. The first three buttons are unvisible and they won’t work. I can not find the mistake! The code: color myColor = color(102); int myCircleSize = 100…

---

## [Drag shape with mouse / Pre-last thread in this week](https://discourse.processing.org/t/drag-shape-with-mouse-pre-last-thread-in-this-week/15176)

<div class="topic-metadata">

**Author:** [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Replies:** 16\
**Last updated:** [November 3, 2019, 12:31pm UTC](https://discourse.processing.org/t/drag-shape-with-mouse-pre-last-thread-in-this-week/15176 "2019-11-03T12:31:50Z")

</div>

Hello! I just want to ask, how can I make that if I drag ANY of the geometric shapes will be where my mouse, and when I release my mouse, it will stay in the place where I dragged it to? Thank you! Also, when I will ge…

---

## [Using arrays to create a node and edge connector](https://discourse.processing.org/t/using-arrays-to-create-a-node-and-edge-connector/14464)

<div class="topic-metadata">

**Author:** [@johnsmith17](https://discourse.processing.org/u/johnsmith17)\
**Replies:** 17\
**Last updated:** [November 3, 2019, 3:05am UTC](https://discourse.processing.org/t/using-arrays-to-create-a-node-and-edge-connector/14464 "2019-11-03T03:05:24Z")

</div>

hi im trying to create a program that adds balls with mousePressed on the sketch and connects each of the balls with lines. ive managed to create an array of length 5 that adds a value(mouseX and mouseY), each time i mou…

---

## [Multiple help beginner completely new](https://discourse.processing.org/t/multiple-help-beginner-completely-new/15153)

<div class="topic-metadata">

**Author:** [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 4:44pm UTC](https://discourse.processing.org/t/multiple-help-beginner-completely-new/15153 "2019-11-02T16:44:43Z")

</div>

please help me, I am making a project and I want a rectangle be at a random position but will stay here until the game closes, not that it will still generate everywhere. help. I will insert the code I need to fix. Than…

---

## [Memory Game Code](https://discourse.processing.org/t/memory-game-code/15097)

<div class="topic-metadata">

**Author:** [@San](https://discourse.processing.org/u/San)\
**Replies:** 8\
**Last updated:** [November 1, 2019, 8:17pm UTC](https://discourse.processing.org/t/memory-game-code/15097 "2019-11-01T20:17:52Z")

</div>

Im not so good with Processing. But I’m trying to make the Memory game. so far this is what I got: I can print 6 sets of cards. (12 cards in total) I have to match color with color. But I have been thinking all day and…

---

## [Game, hitbox (if condition) ignored for number of loops](https://discourse.processing.org/t/game-hitbox-if-condition-ignored-for-number-of-loops/15133)

<div class="topic-metadata">

**Author:** [@D.Signer](https://discourse.processing.org/u/D.Signer)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 10:24am UTC](https://discourse.processing.org/t/game-hitbox-if-condition-ignored-for-number-of-loops/15133 "2019-11-02T10:24:43Z")

</div>

While running the code, it spawns 6 targets in front of you when you press right mousebutton. You move the 3d camera towards the objects, and if one is within a certain distance of the camera position on the x axis, you …

---

## [Changing Boolean to Int in a custom function](https://discourse.processing.org/t/changing-boolean-to-int-in-a-custom-function/15140)

<div class="topic-metadata">

**Author:** [@nathanchun](https://discourse.processing.org/u/nathanchun)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 9:53am UTC](https://discourse.processing.org/t/changing-boolean-to-int-in-a-custom-function/15140 "2019-11-02T09:53:46Z")

</div>

Hi! I am trying to create a bunch of random circles to appear and then bounce around the edges of the screen. I got everything I wanted so far except the “checkEdge” function. I keep getting the error that says “The oper…

---

## [SuperShape formula working abruptly in processing](https://discourse.processing.org/t/supershape-formula-working-abruptly-in-processing/15104)

<div class="topic-metadata">

**Author:** [@Ruchi](https://discourse.processing.org/u/Ruchi)\
**Replies:** 10\
**Last updated:** [November 2, 2019, 6:43am UTC](https://discourse.processing.org/t/supershape-formula-working-abruptly-in-processing/15104 "2019-11-02T06:43:21Z")

</div>

float n1, n2, n3; float m; float a, b; float r; float total; float increment; void setup() { size(900, 900); n1 = 60; n2 = 55; n3 = 30; m = 7; a=b=2; total=700; increment=TWO\_PI/total; } float s…

---

## [Shape has weird behavior with 4 parameters](https://discourse.processing.org/t/shape-has-weird-behavior-with-4-parameters/15129)

<div class="topic-metadata">

**Author:** [@Dregni](https://discourse.processing.org/u/Dregni)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 1:07am UTC](https://discourse.processing.org/t/shape-has-weird-behavior-with-4-parameters/15129 "2019-11-02T01:07:07Z")

</div>

Hoï ! So I was trying to have a generic body class so it could represent the body of all my objects for some simulation but then this happened : void display() { shapeMode(CENTER); shape(body, 50, 50, 100, …

---

## [P3D hint() with 2D depth sort not working](https://discourse.processing.org/t/p3d-hint-with-2d-depth-sort-not-working/15080)

<div class="topic-metadata">

**Author:** [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Replies:** 1\
**Last updated:** [November 1, 2019, 8:19pm UTC](https://discourse.processing.org/t/p3d-hint-with-2d-depth-sort-not-working/15080 "2019-11-01T20:19:40Z")

</div>

Hello i want to create layer system and i cant ENABLE\_DEPTH\_SORT in a hint… Its resizing… yeah one of two objects gets before and after when i moving mouse, but i want to make it without sizing… :confused: can you help …

---

## [PVectors - Help new beginner follow](https://discourse.processing.org/t/pvectors-help-new-beginner-follow/15122)

<div class="topic-metadata">

**Author:** [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Replies:** 2\
**Last updated:** [November 1, 2019, 4:39pm UTC](https://discourse.processing.org/t/pvectors-help-new-beginner-follow/15122 "2019-11-01T16:39:24Z")

</div>

need help, how can a rectangle (or something) follow a next rectangle that is at different position?

---

## [Help shoot ellipse beginner complete new](https://discourse.processing.org/t/help-shoot-ellipse-beginner-complete-new/15121)

<div class="topic-metadata">

**Author:** [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Replies:** 2\
**Last updated:** [November 1, 2019, 4:36pm UTC](https://discourse.processing.org/t/help-shoot-ellipse-beginner-complete-new/15121 "2019-11-01T16:36:48Z")

</div>

How can I shoot ellipses? Example \> https://youtu.be/v1kqMxsvElM?t=514

---

## [Zigzag path through 2D array](https://discourse.processing.org/t/zigzag-path-through-2d-array/15093)

<div class="topic-metadata">

**Author:** [@dangerousclive](https://discourse.processing.org/u/dangerousclive)\
**Replies:** 2\
**Last updated:** [November 1, 2019, 12:03pm UTC](https://discourse.processing.org/t/zigzag-path-through-2d-array/15093 "2019-11-01T12:03:32Z")

</div>

Hi, I’m attempting to reorder a 2D array to follow a zigzag path. This image illustrates the path I wish to follow: https://en.wikipedia.org/wiki/JPEG#/media/File:JPEG\_ZigZag.svg I’m having a bit of a problem moving b…

---

## [Solution for repeating keyPressed while holding key](https://discourse.processing.org/t/solution-for-repeating-keypressed-while-holding-key/3989)

<div class="topic-metadata">

**Author:** [@tutantontut](https://discourse.processing.org/u/tutantontut)\
**Replies:** 10\
**Last updated:** [November 1, 2019, 11:39am UTC](https://discourse.processing.org/t/solution-for-repeating-keypressed-while-holding-key/3989 "2019-11-01T11:39:00Z")

</div>

I came up with a solution for a problem I’ve encountered regarding inputs. The problem: When you hold down a key, at least on my computer it registers as if you were repeatedly pressing that key very fast. In some case…

---

## [I need a working scoreboard!](https://discourse.processing.org/t/i-need-a-working-scoreboard/15100)

<div class="topic-metadata">

**Author:** [@Fluxy](https://discourse.processing.org/u/Fluxy)\
**Replies:** 8\
**Last updated:** [November 1, 2019, 10:42am UTC](https://discourse.processing.org/t/i-need-a-working-scoreboard/15100 "2019-11-01T10:42:46Z")

</div>

Hey there! I am busy with a schoolproject, but I can’t figure out how to configure the scoreboard. There is a grid with yellow rects. These are points and there is a purple rect that is the player. Don’t mind the red re…

---

## [I need random circles and rectangles in a grid, Stuck in a problem I can't solve!](https://discourse.processing.org/t/i-need-random-circles-and-rectangles-in-a-grid-stuck-in-a-problem-i-cant-solve/15061)

<div class="topic-metadata">

**Author:** [@Fluxy](https://discourse.processing.org/u/Fluxy)\
**Replies:** 10\
**Last updated:** [November 1, 2019, 9:36am UTC](https://discourse.processing.org/t/i-need-random-circles-and-rectangles-in-a-grid-stuck-in-a-problem-i-cant-solve/15061 "2019-11-01T09:36:53Z")

</div>

This is a big problem for me because I don’t know how to do it. I’ve got a small code, but the most important is that i have a grid. this grid is 60x40 and in this grid need to be random circles and rectangles about 10 o…

---

## [How do I make a random array interactive?](https://discourse.processing.org/t/how-do-i-make-a-random-array-interactive/15086)

<div class="topic-metadata">

**Author:** [@brandy22](https://discourse.processing.org/u/brandy22)\
**Replies:** 12\
**Last updated:** [November 1, 2019, 8:41am UTC](https://discourse.processing.org/t/how-do-i-make-a-random-array-interactive/15086 "2019-11-01T08:41:02Z")

</div>

I want to make random numbers in an array interactive. int\[\] numbers = new int\[500\]; void setup() { size(500, 500); for (int i = 0; i\< 450; i++) { numbers\[i\] = (int)random(0, 450); } } void draw() { backg…

---

## [Random pairs from an arrayList](https://discourse.processing.org/t/random-pairs-from-an-arraylist/15088)

<div class="topic-metadata">

**Author:** [@jeykech](https://discourse.processing.org/u/jeykech)\
**Replies:** 5\
**Last updated:** [October 31, 2019, 9:54pm UTC](https://discourse.processing.org/t/random-pairs-from-an-arraylist/15088 "2019-10-31T21:54:40Z")

</div>

hi all, I am a little bit stuck with this simple problem; I have an arrayList of let’s say PVectors and I would like to draw random lines between two different points.( or have any other connection rule ), the number of…

---

## [Random values from array](https://discourse.processing.org/t/random-values-from-array/15084)

<div class="topic-metadata">

**Author:** [@San](https://discourse.processing.org/u/San)\
**Replies:** 1\
**Last updated:** [October 31, 2019, 7:44pm UTC](https://discourse.processing.org/t/random-values-from-array/15084 "2019-10-31T19:44:08Z")

</div>

I want to select random values from this array. But if I run it, it sometimes has the same number in it twice. I want to have each number just one time but in a different order everytime I run it. image|690x188

---

## [How do I center a rect in a grid?](https://discourse.processing.org/t/how-do-i-center-a-rect-in-a-grid/15074)

<div class="topic-metadata">

**Author:** [@RubenF](https://discourse.processing.org/u/RubenF)\
**Replies:** 6\
**Last updated:** [October 31, 2019, 4:39pm UTC](https://discourse.processing.org/t/how-do-i-center-a-rect-in-a-grid/15074 "2019-10-31T16:39:09Z")

</div>

I’m making a snake game, where the user has to click at a position in the grid for it to move there. The problem is, how do I make this rect align in the center of the grid? Here’s my code: float mousePosX=100, mousePo…

---

## [Vanishing objects when using ortho()](https://discourse.processing.org/t/vanishing-objects-when-using-ortho/15056)

<div class="topic-metadata">

**Author:** [@pheelia](https://discourse.processing.org/u/pheelia)\
**Replies:** 2\
**Last updated:** [October 31, 2019, 3:46pm UTC](https://discourse.processing.org/t/vanishing-objects-when-using-ortho/15056 "2019-10-31T15:46:48Z")

</div>

Hey everyone, I’m creating a sketch using orthographic perspective and I get strange effects here. If I run the code the white rectangles in the background can’t be seen through the gaps left between the black ones. On…

---

## [Create random circles in a grid](https://discourse.processing.org/t/create-random-circles-in-a-grid/14976)

<div class="topic-metadata">

**Author:** [@Fantassy](https://discourse.processing.org/u/Fantassy)\
**Replies:** 15\
**Last updated:** [October 30, 2019, 3:25pm UTC](https://discourse.processing.org/t/create-random-circles-in-a-grid/14976 "2019-10-30T15:25:37Z")

</div>

Hello, I’m fairly new to this and for a game I’m trying to create red circles randomly in a grid with the amount that is given in the variable. For example I have made a grid with this: void setup() { size (1200, 80…

---

## [Generate random numbers in array and sort without predefined sort function](https://discourse.processing.org/t/generate-random-numbers-in-array-and-sort-without-predefined-sort-function/15055)

<div class="topic-metadata">

**Author:** [@NewbCoder](https://discourse.processing.org/u/NewbCoder)\
**Replies:** 4\
**Last updated:** [October 30, 2019, 6:56pm UTC](https://discourse.processing.org/t/generate-random-numbers-in-array-and-sort-without-predefined-sort-function/15055 "2019-10-30T18:56:51Z")

</div>

Help! I’m trying to generate random numbers in two arrays and then merge them without the predefined function. Any suggestions would be great. Having issues converting between int \[\] and int…This is what i have so far: v…

---

## [Water simulation updating asymetrically](https://discourse.processing.org/t/water-simulation-updating-asymetrically/10885)

<div class="topic-metadata">

**Author:** [@halsfasda](https://discourse.processing.org/u/halsfasda)\
**Replies:** 3\
**Last updated:** [October 30, 2019, 6:22pm UTC](https://discourse.processing.org/t/water-simulation-updating-asymetrically/10885 "2019-10-30T18:22:23Z")

</div>

Hey So I have been working on simulation of water in 2 dimensions. It is comprised of nodes that are attached by “springs” to their neighbors and to the “water level”. it works fine, but it behaves differently on either…

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

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