# Coding Questions

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

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

**Page:** 76

---

## [I need help with my snake game](https://discourse.processing.org/t/i-need-help-with-my-snake-game/24986)

<div class="topic-metadata">

**Author:** [@umar](https://discourse.processing.org/u/umar)\
**Replies:** 2\
**Last updated:** [October 28, 2020, 9:40pm UTC](https://discourse.processing.org/t/i-need-help-with-my-snake-game/24986 "2020-10-28T21:40:33Z")

</div>

but with 16 by 8 blocks window size, where yellow is for banana(+10 points), red is for apple(+5 points) and green block is for cameleon(-5 points). The problem I’m facing is that my fruits are never in the same coordina…

---

## [How to use for loop to draw a 9-sided polygon](https://discourse.processing.org/t/how-to-use-for-loop-to-draw-a-9-sided-polygon/24968)

<div class="topic-metadata">

**Author:** [@mengtong](https://discourse.processing.org/u/mengtong)\
**Replies:** 8\
**Last updated:** [October 28, 2020, 9:42pm UTC](https://discourse.processing.org/t/how-to-use-for-loop-to-draw-a-9-sided-polygon/24968 "2020-10-28T21:42:12Z")

</div>

I am trying to draw a 9-sided polygon, only use for loop, here is my code, but I don’t know what’s wrong with it. int points=9;//9-sided polygon size(600,600);//no setup and draw function float angle=0;//angle start f…

---

## [Calculate something written in a string](https://discourse.processing.org/t/calculate-something-written-in-a-string/24977)

<div class="topic-metadata">

**Author:** [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Replies:** 2\
**Last updated:** [October 28, 2020, 4:29pm UTC](https://discourse.processing.org/t/calculate-something-written-in-a-string/24977 "2020-10-28T16:29:02Z")

</div>

I’m currently writing a programm to solve equations. I have the following Problem: My equation will be in the form of a string. What I need is some kind of method to do something like. String calculation="5×(4+1\*3)";…

---

## [Color Gradient in Stroke](https://discourse.processing.org/t/color-gradient-in-stroke/24910)

<div class="topic-metadata">

**Author:** [@Ladan](https://discourse.processing.org/u/Ladan)\
**Replies:** 4\
**Last updated:** [October 28, 2020, 1:05pm UTC](https://discourse.processing.org/t/color-gradient-in-stroke/24910 "2020-10-28T13:05:46Z")

</div>

Hello! Is there any way, I can make a color gradient in the stroke of a button?

---

## [Need help with these codes! (array)](https://discourse.processing.org/t/need-help-with-these-codes-array/24940)

<div class="topic-metadata">

**Author:** [@BettyBai](https://discourse.processing.org/u/BettyBai)\
**Replies:** 2\
**Last updated:** [October 28, 2020, 4:59am UTC](https://discourse.processing.org/t/need-help-with-these-codes-array/24940 "2020-10-28T04:59:53Z")

</div>

please format code with \</\> button \* homework policy \* asking questions My teacher is asking us to use Array and for loop functions to draw the same image many times. I tried to create new arrays for different variab…

---

## [Cant get sequence of images to save](https://discourse.processing.org/t/cant-get-sequence-of-images-to-save/24630)

<div class="topic-metadata">

**Author:** [@DeadMusik](https://discourse.processing.org/u/DeadMusik)\
**Replies:** 7\
**Last updated:** [October 28, 2020, 4:26am UTC](https://discourse.processing.org/t/cant-get-sequence-of-images-to-save/24630 "2020-10-28T04:26:07Z")

</div>

Hello, so I picked this code up off the net, its not mine but after doing some tweaks I was trying to get it to save images so I could upload into after effects, can you please tell me where I need to put my if statement…

---

## [Smooothing out Z height with sin()?](https://discourse.processing.org/t/smooothing-out-z-height-with-sin/24959)

<div class="topic-metadata">

**Author:** [@DeadMusik](https://discourse.processing.org/u/DeadMusik)\
**Replies:** 0\
**Last updated:** [October 28, 2020, 3:47am UTC](https://discourse.processing.org/t/smooothing-out-z-height-with-sin/24959 "2020-10-28T03:47:14Z")

</div>

Hello I have a sketch here I got watching the great Dan S. , I altered his Perlin noise terrain with some color now I want to be able to get the terrain to smooth out after going into the more extreme levels of z height.…

---

## [Different Paint tools for color picker](https://discourse.processing.org/t/different-paint-tools-for-color-picker/24931)

<div class="topic-metadata">

**Author:** [@kasper1](https://discourse.processing.org/u/kasper1)\
**Replies:** 6\
**Last updated:** [October 27, 2020, 10:44pm UTC](https://discourse.processing.org/t/different-paint-tools-for-color-picker/24931 "2020-10-27T22:44:02Z")

</div>

Hello everyone I am a beginner and I am trying to make four different drawing tools (one of them is a simple draw tool, i.e. dragging the mouse pointer draws pixels in the selected color; the other three tools could be, …

---

## [Random position of class objects](https://discourse.processing.org/t/random-position-of-class-objects/24950)

<div class="topic-metadata">

**Author:** [@MaxMax](https://discourse.processing.org/u/MaxMax)\
**Replies:** 3\
**Last updated:** [October 27, 2020, 9:13pm UTC](https://discourse.processing.org/t/random-position-of-class-objects/24950 "2020-10-27T21:13:39Z")

</div>

Hi, I managed to make my player ( the car ) collide with the obstacles that are falling down. I tried to make a class so I would be able to make the position, speed, and size of each obstacle random. But it doesn’t work …

---

## [Get non sketch active focused window size and position possible?](https://discourse.processing.org/t/get-non-sketch-active-focused-window-size-and-position-possible/24944)

<div class="topic-metadata">

**Author:** [@mrmatthewfelton](https://discourse.processing.org/u/mrmatthewfelton)\
**Replies:** 2\
**Last updated:** [October 27, 2020, 2:25pm UTC](https://discourse.processing.org/t/get-non-sketch-active-focused-window-size-and-position-possible/24944 "2020-10-27T14:25:53Z")

</div>

Hi. I’m super new to processing 3. is it possible to find the the size and position of an active window. by that I mean whatever window is currently the main focused and active window ? just need to know if its possible …

---

## [Initial state of vector (or array?), I do not understand](https://discourse.processing.org/t/initial-state-of-vector-or-array-i-do-not-understand/24897)

<div class="topic-metadata">

**Author:** [@raboytniksings](https://discourse.processing.org/u/raboytniksings)\
**Replies:** 7\
**Last updated:** [October 26, 2020, 11:33pm UTC](https://discourse.processing.org/t/initial-state-of-vector-or-array-i-do-not-understand/24897 "2020-10-26T23:33:10Z")

</div>

I have just discovered Processing and so far it is extremely addictive and fun! I want to create two “droplets” of points, one near the top and one near the bottom of the visible space, but for some reason I do not unde…

---

## [Cursor clipping mask](https://discourse.processing.org/t/cursor-clipping-mask/24934)

<div class="topic-metadata">

**Author:** [@pescemc](https://discourse.processing.org/u/pescemc)\
**Replies:** 0\
**Last updated:** [October 26, 2020, 8:44pm UTC](https://discourse.processing.org/t/cursor-clipping-mask/24934 "2020-10-26T20:44:51Z")

</div>

Hello, I need to create a program like the one in the video that I leave below, it is about 2 overlapping images, with a clipping mask in a circular shape handled by the mouse, which shows the outside of one image, and i…

---

## [Collisions on moving objects](https://discourse.processing.org/t/collisions-on-moving-objects/24912)

<div class="topic-metadata">

**Author:** [@MaxMax](https://discourse.processing.org/u/MaxMax)\
**Replies:** 15\
**Last updated:** [October 26, 2020, 4:31pm UTC](https://discourse.processing.org/t/collisions-on-moving-objects/24912 "2020-10-26T16:31:09Z")

</div>

Hello, I am new to processing and I have to work on a school project. For my project, I need objects that are falling down to collide with my own moving character. I have been searching quite a bit but I can’t find how t…

---

## [How can I place the dates of my data inside my ellipses?](https://discourse.processing.org/t/how-can-i-place-the-dates-of-my-data-inside-my-ellipses/24853)

<div class="topic-metadata">

**Author:** [@JennyMcCreadie](https://discourse.processing.org/u/JennyMcCreadie)\
**Replies:** 3\
**Last updated:** [October 26, 2020, 1:39pm UTC](https://discourse.processing.org/t/how-can-i-place-the-dates-of-my-data-inside-my-ellipses/24853 "2020-10-26T13:39:18Z")

</div>

Hello, I’m writing the code so the ellipses fall in to a grid according to the data of my steps. This code has them all bunched up, but it’s in the works so I’m leaving it as I write the data so that’s okay! So my questi…

---

## [Select only one shape](https://discourse.processing.org/t/select-only-one-shape/24646)

<div class="topic-metadata">

**Author:** [@karbon](https://discourse.processing.org/u/karbon)\
**Replies:** 1\
**Last updated:** [October 26, 2020, 1:12pm UTC](https://discourse.processing.org/t/select-only-one-shape/24646 "2020-10-26T13:12:13Z")

</div>

My code needs some minor adjustments. I couldn’t find any tutorials to only select one shape. I have a 3 button system. The dragging element (still trying to figure out how to make it visible) is slightly under my desire…

---

## [Probabilistic based drawing working for single object, breaking for \>1 objects](https://discourse.processing.org/t/probabilistic-based-drawing-working-for-single-object-breaking-for-1-objects/24876)

<div class="topic-metadata">

**Author:** [@watershed](https://discourse.processing.org/u/watershed)\
**Replies:** 7\
**Last updated:** [October 26, 2020, 12:31pm UTC](https://discourse.processing.org/t/probabilistic-based-drawing-working-for-single-object-breaking-for-1-objects/24876 "2020-10-26T12:31:11Z")

</div>

Hi, I am trying to write a program to render a brick-wall like pattern. At a high level, fixed length paths will be created as the wall ‘grows,’ which new paths being added as the current ones become ‘filled’ with the p…

---

## [Processing Memory Game](https://discourse.processing.org/t/processing-memory-game/24855)

<div class="topic-metadata">

**Author:** [@Itekai](https://discourse.processing.org/u/Itekai)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 12:08pm UTC](https://discourse.processing.org/t/processing-memory-game/24855 "2020-10-26T12:08:32Z")

</div>

Hi, I’m a little stuck in my code. I’m trying to shuffle my deck, but it’s taking ages, to draw them. I waited for like 15 min and there is still no results. Does anyone has an idea how I can fix this? :frowning:

---

## [Rotate Snake Head](https://discourse.processing.org/t/rotate-snake-head/24903)

<div class="topic-metadata">

**Author:** [@Mischief-Managed](https://discourse.processing.org/u/Mischief-Managed)\
**Replies:** 1\
**Last updated:** [October 26, 2020, 10:05am UTC](https://discourse.processing.org/t/rotate-snake-head/24903 "2020-10-26T10:05:24Z")

</div>

Hello! I am making the game snake and I am trying to rotate the snakehead, but I am stuck. Should I use the rotate function or should I redraw each eye under each conditional? Right now I have a class that consists of bo…

---

## [Filling a curveVertex shape](https://discourse.processing.org/t/filling-a-curvevertex-shape/24871)

<div class="topic-metadata">

**Author:** [@travis.stdenis](https://discourse.processing.org/u/travis.stdenis)\
**Replies:** 6\
**Last updated:** [October 25, 2020, 8:01pm UTC](https://discourse.processing.org/t/filling-a-curvevertex-shape/24871 "2020-10-25T20:01:14Z")

</div>

Hoping to get some help on a problem that has been baffling me for hours. There are two parts to the problem which may or may not be connected. The code below will execute, but only after a length pause which I believe …

---

## [How to delay part of the code in draw()?](https://discourse.processing.org/t/how-to-delay-part-of-the-code-in-draw/24872)

<div class="topic-metadata">

**Author:** [@IpNeNaEcRe](https://discourse.processing.org/u/IpNeNaEcRe)\
**Replies:** 3\
**Last updated:** [October 25, 2020, 8:31pm UTC](https://discourse.processing.org/t/how-to-delay-part-of-the-code-in-draw/24872 "2020-10-25T20:31:35Z")

</div>

I code a polarline function and use a Slider class to control the number of the lines. When I use delay() to make the image change slowly, the Slider gets slowly and hard to drag. So how can I slowly the image changing r…

---

## [Hello. I am just a beginner. I want to know how to complete a jump](https://discourse.processing.org/t/hello-i-am-just-a-beginner-i-want-to-know-how-to-complete-a-jump/24754)

<div class="topic-metadata">

**Author:** [@mengtong](https://discourse.processing.org/u/mengtong)\
**Replies:** 13\
**Last updated:** [October 25, 2020, 6:45pm UTC](https://discourse.processing.org/t/hello-i-am-just-a-beginner-i-want-to-know-how-to-complete-a-jump/24754 "2020-10-25T18:45:49Z")

</div>

please format code with \</\> button \* homework policy \* asking questions My current code, when I press another keycode in the middle of a jump, it changes the direction of the jump, instead of waiting for a jump to end …

---

## [Scatter Rectangles From the Center - No Overlap](https://discourse.processing.org/t/scatter-rectangles-from-the-center-no-overlap/24867)

<div class="topic-metadata">

**Author:** [@DonaldZhu](https://discourse.processing.org/u/DonaldZhu)\
**Replies:** 2\
**Last updated:** [October 24, 2020, 10:55pm UTC](https://discourse.processing.org/t/scatter-rectangles-from-the-center-no-overlap/24867 "2020-10-24T22:55:57Z")

</div>

Hi, I have seen codes that scatter circles all over the canvas without overlaps (https://www.youtube.com/watch?v=XATr\_jdh-44&feature=youtu.be), but if the total number of circles is low, then there’s a chance that the cl…

---

## [2d array movement help](https://discourse.processing.org/t/2d-array-movement-help/24851)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.processing.org/u/Lilith)\
**Replies:** 4\
**Last updated:** [October 24, 2020, 8:36am UTC](https://discourse.processing.org/t/2d-array-movement-help/24851 "2020-10-24T08:36:03Z")

</div>

Hello guys, I’m trying to create a game using an 2d array to create a grid of (invisible) squares to put items in them. I’m having trouble moving the grid of squares down because I don’t want them to fit the screen. Le…

---

## [Posterize question-What does this statement mean(set the pixel at the current index to r,g,b.)?](https://discourse.processing.org/t/posterize-question-what-does-this-statement-mean-set-the-pixel-at-the-current-index-to-r-g-b/24862)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 3\
**Last updated:** [October 24, 2020, 1:40am UTC](https://discourse.processing.org/t/posterize-question-what-does-this-statement-mean-set-the-pixel-at-the-current-index-to-r-g-b/24862 "2020-10-24T01:40:14Z")

</div>

I am supposed to posterize an image with purple and green. This is the code I am working with. I am trying to set the pixel at the current index to r,g,b. What exactly does it mean to::: set the pixel at the current i…

---

## [Need help coding with coding SNAKE](https://discourse.processing.org/t/need-help-coding-with-coding-snake/24848)

<div class="topic-metadata">

**Author:** [@JohnnyTesto](https://discourse.processing.org/u/JohnnyTesto)\
**Replies:** 1\
**Last updated:** [October 23, 2020, 12:31pm UTC](https://discourse.processing.org/t/need-help-coding-with-coding-snake/24848 "2020-10-23T12:31:51Z")

</div>

Hello, I really need help. I have to code snake but I have no clue anymore what to do. I currently have the snake coded and an apple which spawns at the start randomly. I need help in the following: Snake should be ab…

---

## [Spawn one sprite when another sprite exits](https://discourse.processing.org/t/spawn-one-sprite-when-another-sprite-exits/24811)

<div class="topic-metadata">

**Author:** [@jxjohn](https://discourse.processing.org/u/jxjohn)\
**Replies:** 14\
**Last updated:** [October 23, 2020, 12:19pm UTC](https://discourse.processing.org/t/spawn-one-sprite-when-another-sprite-exits/24811 "2020-10-23T12:19:25Z")

</div>

Hi I’m trying to say that whenever the enemy sprite leaves the screen a mini sprite will be spawned. I already managed to ensure that mini sprites are spawn when enemy leaves the screen but it spawns all eight mini sprit…

---

## [Boolean / if statement help](https://discourse.processing.org/t/boolean-if-statement-help/24809)

<div class="topic-metadata">

**Author:** [@kimchi](https://discourse.processing.org/u/kimchi)\
**Replies:** 9\
**Last updated:** [October 23, 2020, 8:13am UTC](https://discourse.processing.org/t/boolean-if-statement-help/24809 "2020-10-23T08:13:20Z")

</div>

Hi there, I’m trying to make a program that has a “fly” that jumps around the 4 dots of the clock. I have to use if statements in order to make the fly to move and I think I have a good idea of how to do it, but now I’m …

---

## [Multplying each element in an array](https://discourse.processing.org/t/multplying-each-element-in-an-array/24827)

<div class="topic-metadata">

**Author:** [@Mischief-Managed](https://discourse.processing.org/u/Mischief-Managed)\
**Replies:** 7\
**Last updated:** [October 23, 2020, 1:13am UTC](https://discourse.processing.org/t/multplying-each-element-in-an-array/24827 "2020-10-23T01:13:44Z")

</div>

Hi, I wanted to make an array where each element is simply being multiplied by 2. Here is what I have so far. Help would be greatly appreciated int expo(int\[\] array\[\]){ int mult = 2; for (int i=0;i\<array.length;i++)…

---

## [Could somebody proof-read my curve Class?](https://discourse.processing.org/t/could-somebody-proof-read-my-curve-class/24828)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 4\
**Last updated:** [October 22, 2020, 11:25pm UTC](https://discourse.processing.org/t/could-somebody-proof-read-my-curve-class/24828 "2020-10-22T23:25:35Z")

</div>

Hello all! I just wrote a class for curve. Could somebody check / proofread my code? I am surprised why the curve goes UP when my the control point goes down. my understanding of https://www.processing.org/reference/…

---

## [Is it possible to dim the entire screen in Processing?](https://discourse.processing.org/t/is-it-possible-to-dim-the-entire-screen-in-processing/24786)

<div class="topic-metadata">

**Author:** [@tea](https://discourse.processing.org/u/tea)\
**Replies:** 2\
**Last updated:** [October 21, 2020, 11:56am UTC](https://discourse.processing.org/t/is-it-possible-to-dim-the-entire-screen-in-processing/24786 "2020-10-21T11:56:22Z")

</div>

So I’m trying to make a 2D Platformer game that goes like this: A boy (the player) is trying to get home from the starting point before dawn, and he has a companion of a little flame sprite to keep his surrounding illum…

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

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