# Coding Questions

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

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

**Page:** 80

---

## [Pick up object on random coordinates inside of 2D-array](https://discourse.processing.org/t/pick-up-object-on-random-coordinates-inside-of-2d-array/24219)

<div class="topic-metadata">

**Author:** [@Reynaert98](https://discourse.processing.org/u/Reynaert98)\
**Replies:** 1\
**Last updated:** [September 30, 2020, 10:36am UTC](https://discourse.processing.org/t/pick-up-object-on-random-coordinates-inside-of-2d-array/24219 "2020-09-30T10:36:10Z")

</div>

I have a game in which a moving player has to collect ellipses in order to gain points. The ellipses are randomly distributed on a grid by using the following code: int rows = 40; int cols = 60; int objectOffset = 25; f…

---

## [Collision Detection (Game Design)](https://discourse.processing.org/t/collision-detection-game-design/24142)

<div class="topic-metadata">

**Author:** [@Aoyanco](https://discourse.processing.org/u/Aoyanco)\
**Replies:** 3\
**Last updated:** [September 30, 2020, 8:53am UTC](https://discourse.processing.org/t/collision-detection-game-design/24142 "2020-09-30T08:53:51Z")

</div>

Hi! I’m trying to make a platformer style game. I already have most of the physics done, but I’m now trying to do the collision detection and I’m stumped. I can think of ways to do it, but in my game, the levels will be …

---

## [Question about the correct usage of the thread() method and it's application to my code](https://discourse.processing.org/t/question-about-the-correct-usage-of-the-thread-method-and-its-application-to-my-code/24228)

<div class="topic-metadata">

**Author:** [@Thecido](https://discourse.processing.org/u/Thecido)\
**Replies:** 1\
**Last updated:** [September 29, 2020, 7:58pm UTC](https://discourse.processing.org/t/question-about-the-correct-usage-of-the-thread-method-and-its-application-to-my-code/24228 "2020-09-29T19:58:40Z")

</div>

Hi, I am rather new to processing and I was trying out the thread() method to speed up my code and run multiple instances of different sorting algorithms I’ve been developing lately, please note that I have just a basic …

---

## [Making increments change direction?](https://discourse.processing.org/t/making-increments-change-direction/24202)

<div class="topic-metadata">

**Author:** [@AlexW](https://discourse.processing.org/u/AlexW)\
**Replies:** 4\
**Last updated:** [September 29, 2020, 12:08pm UTC](https://discourse.processing.org/t/making-increments-change-direction/24202 "2020-09-29T12:08:30Z")

</div>

Hello, I’m taking a processing class at university and I’m working on our first project which is to make a reproduction of a piece of artwork and add some interaction and animation to it. So far I’ve come up with a ne…

---

## [Creating and then accessing sets of possible pixel sequences (Markov?)](https://discourse.processing.org/t/creating-and-then-accessing-sets-of-possible-pixel-sequences-markov/24209)

<div class="topic-metadata">

**Author:** [@jl33](https://discourse.processing.org/u/jl33)\
**Replies:** 1\
**Last updated:** [September 28, 2020, 11:58pm UTC](https://discourse.processing.org/t/creating-and-then-accessing-sets-of-possible-pixel-sequences-markov/24209 "2020-09-28T23:58:30Z")

</div>

Keep thinking different ways to go about this but I don’t quite have the experience to fully wrap my head around. I want to analyze an img to create (and then access/manipulate) basically a Markov model of the set of co…

---

## [Redrawing Pimage with point() after rotate() creates weird pixel patterns](https://discourse.processing.org/t/redrawing-pimage-with-point-after-rotate-creates-weird-pixel-patterns/24034)

<div class="topic-metadata">

**Author:** [@erk](https://discourse.processing.org/u/erk)\
**Replies:** 6\
**Last updated:** [September 28, 2020, 11:55am UTC](https://discourse.processing.org/t/redrawing-pimage-with-point-after-rotate-creates-weird-pixel-patterns/24034 "2020-09-28T11:55:12Z")

</div>

I try to mirror a PImage, using parts of the code found here: https://thecodingtrain.com/CodingChallenges/155-kaleidoscope-snowflake.html The difference is, that i use point() to draw the single pixels of the picture. I…

---

## [Rectangle not moving](https://discourse.processing.org/t/rectangle-not-moving/24161)

<div class="topic-metadata">

**Author:** [@Tobias](https://discourse.processing.org/u/Tobias)\
**Replies:** 9\
**Last updated:** [September 28, 2020, 11:10am UTC](https://discourse.processing.org/t/rectangle-not-moving/24161 "2020-09-28T11:10:02Z")

</div>

Hi. I am new to processing and I am trying to make Pong. I want both the paddles to be able to move at once. Since keyPressed only allows for one button press at a time, i tried to add a boolean for each button press in…

---

## [Surface.setSize() error](https://discourse.processing.org/t/surface-setsize-error/24144)

<div class="topic-metadata">

**Author:** [@mrbbp](https://discourse.processing.org/u/mrbbp)\
**Replies:** 6\
**Last updated:** [September 28, 2020, 1:20am UTC](https://discourse.processing.org/t/surface-setsize-error/24144 "2020-09-28T01:20:26Z")

</div>

Hello, i’m trying to setSize of my window and discover a strange behaviour. try this code. On my MacOS 10.14.6 and Processing 3.5.3 It’s suppose to open a window with 10px in height… It does not! it open a window w…

---

## [Nested for loops---help please!](https://discourse.processing.org/t/nested-for-loops-help-please/24129)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 17\
**Last updated:** [September 27, 2020, 8:49pm UTC](https://discourse.processing.org/t/nested-for-loops-help-please/24129 "2020-09-27T20:49:01Z")

</div>

I have an assignment that states the following–Create a program using nested for statements that will produce 5 rows, 7 in each column of diagonals as shown. You will need to size the frame 450 x 450. Determine your coo…

---

## [Juggling Game Bug](https://discourse.processing.org/t/juggling-game-bug/24172)

<div class="topic-metadata">

**Author:** [@FloorBean](https://discourse.processing.org/u/FloorBean)\
**Replies:** 3\
**Last updated:** [September 27, 2020, 8:47pm UTC](https://discourse.processing.org/t/juggling-game-bug/24172 "2020-09-27T20:47:39Z")

</div>

Hello, I am experiencing a weird bug in my game where the ball seems to get caught in a conditional that throws it out of my display screen. I am not really sure why this is happening because my logic seems to be correct…

---

## [Multiple levels](https://discourse.processing.org/t/multiple-levels/24164)

<div class="topic-metadata">

**Author:** [@koenterheegde57](https://discourse.processing.org/u/koenterheegde57)\
**Replies:** 0\
**Last updated:** [September 27, 2020, 6:20pm UTC](https://discourse.processing.org/t/multiple-levels/24164 "2020-09-27T18:20:50Z")

</div>

Hi guys, I’m making a fun game in which you have to get a rocket as high as possible. I have made the first ‘level’ and I now want to add more levels. The transition from level 1 to level 2 works fine, but backwards is…

---

## [How to create a function out of a shape](https://discourse.processing.org/t/how-to-create-a-function-out-of-a-shape/23911)

<div class="topic-metadata">

**Author:** [@eco.pm2](https://discourse.processing.org/u/eco.pm2)\
**Replies:** 14\
**Last updated:** [September 27, 2020, 3:12am UTC](https://discourse.processing.org/t/how-to-create-a-function-out-of-a-shape/23911 "2020-09-27T03:12:20Z")

</div>

Hi I would like to move the ‘shuttle’ over and under the ellipses with a mouse command at first. Where could I find a tutorial video for that please? I was wondering if the 'shuttle could become a ‘shuttleShape’, as …

---

## [To go beyond the limit of your screen](https://discourse.processing.org/t/to-go-beyond-the-limit-of-your-screen/24136)

<div class="topic-metadata">

**Author:** [@yanze03](https://discourse.processing.org/u/yanze03)\
**Replies:** 9\
**Last updated:** [September 26, 2020, 5:21pm UTC](https://discourse.processing.org/t/to-go-beyond-the-limit-of-your-screen/24136 "2020-09-26T17:21:52Z")

</div>

Hi, I am trying to make a program where the size of my screen is a bit to small. I am trying to make it so that when I pusch a button or scroll a scrollbar the X coordinate of the canvas moves. This would mean that the…

---

## [Creating a Simple class with a circle](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066)

<div class="topic-metadata">

**Author:** [@FloorBean](https://discourse.processing.org/u/FloorBean)\
**Replies:** 3\
**Last updated:** [September 25, 2020, 12:34pm UTC](https://discourse.processing.org/t/creating-a-simple-class-with-a-circle/24066 "2020-09-25T12:34:40Z")

</div>

Hello, I am trying to make a class with just a simple circle. I am planning to eventually have more circles too, but I think that I am running into a syntax/logic error. Any help would be greatly appreciated. bubble b1; …

---

## [Transformations issues](https://discourse.processing.org/t/transformations-issues/24079)

<div class="topic-metadata">

**Author:** [@bernat\_ratpenat](https://discourse.processing.org/u/bernat_ratpenat)\
**Replies:** 6\
**Last updated:** [September 25, 2020, 8:23am UTC](https://discourse.processing.org/t/transformations-issues/24079 "2020-09-25T08:23:56Z")

</div>

Hi there! I’ve been trying to code a torus and, while I have found valid examples, I still don’t understand why my code does not work. I’m sure it’s related to transformations and must’ve misunderstood something about th…

---

## [Computational expense question (2)](https://discourse.processing.org/t/computational-expense-question-2/24105)

<div class="topic-metadata">

**Author:** [@Tsskyx](https://discourse.processing.org/u/Tsskyx)\
**Replies:** 1\
**Last updated:** [September 25, 2020, 3:27am UTC](https://discourse.processing.org/t/computational-expense-question-2/24105 "2020-09-25T03:27:25Z")

</div>

I have a very simple and small image, easily generatable with code alone (it’s essentially just 4 differently colored squares and the image alone is 32x32 px), and I wish to know what is more expensive: using textures …

---

## [Applying filter to a specific region of a window](https://discourse.processing.org/t/applying-filter-to-a-specific-region-of-a-window/24014)

<div class="topic-metadata">

**Author:** [@clamonni](https://discourse.processing.org/u/clamonni)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 8:38pm UTC](https://discourse.processing.org/t/applying-filter-to-a-specific-region-of-a-window/24014 "2020-09-24T20:38:49Z")

</div>

Hi to everyone, I’m trying to make a panel to add filters to an image by clicking over four buttons below the image itself. Another feature I’m trying to develop return the hexadecimal color values of a mouse position w…

---

## [Changing size of my bubbles separately](https://discourse.processing.org/t/changing-size-of-my-bubbles-separately/24089)

<div class="topic-metadata">

**Author:** [@FloorBean](https://discourse.processing.org/u/FloorBean)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 8:27am UTC](https://discourse.processing.org/t/changing-size-of-my-bubbles-separately/24089 "2020-09-24T08:27:04Z")

</div>

Hello, I am using classes to make bubbles come up the screen and I was wondering why when I pop the bubbles or if the bubbles go out of the screen they all change at the same time. I want them to respawn with their own s…

---

## [Help with shaders](https://discourse.processing.org/t/help-with-shaders/24070)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [September 24, 2020, 1:34am UTC](https://discourse.processing.org/t/help-with-shaders/24070 "2020-09-24T01:34:27Z")

</div>

I’m trying to code a simple shader which will take the mouse position to assign the color of the shader. #ifdef GL\_ES precision mediump float; #endif uniform vec2 u\_resolution; uniform vec2 u\_mouse; uniform float u\_time…

---

## [Is this the best way to do this?](https://discourse.processing.org/t/is-this-the-best-way-to-do-this/24085)

<div class="topic-metadata">

**Author:** [@Captiosus](https://discourse.processing.org/u/Captiosus)\
**Replies:** 3\
**Last updated:** [September 24, 2020, 1:24am UTC](https://discourse.processing.org/t/is-this-the-best-way-to-do-this/24085 "2020-09-24T01:24:41Z")

</div>

Hey everyone! I have just started learning Processing and I wanted to know, are the expressions I am using for the parameters (x,y,w,h) in this code the best way to do them, or is there a much more efficient way. void s…

---

## [Produce a pattern](https://discourse.processing.org/t/produce-a-pattern/23980)

<div class="topic-metadata">

**Author:** [@Val1](https://discourse.processing.org/u/Val1)\
**Replies:** 6\
**Last updated:** [September 23, 2020, 1:50pm UTC](https://discourse.processing.org/t/produce-a-pattern/23980 "2020-09-23T13:50:50Z")

</div>

How to produce a pattern from draw quad coding

---

## [Make window snap in to the borders](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729)

<div class="topic-metadata">

**Author:** [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Replies:** 8\
**Last updated:** [September 22, 2020, 4:19pm UTC](https://discourse.processing.org/t/make-window-snap-in-to-the-borders/23729 "2020-09-22T16:19:04Z")

</div>

Is there a way to make the window snap in, so being fullscreen basically except for the taskbar?

---

## [Moving a ellipse on a grid with arrow keys](https://discourse.processing.org/t/moving-a-ellipse-on-a-grid-with-arrow-keys/23987)

<div class="topic-metadata">

**Author:** [@Reynaert98](https://discourse.processing.org/u/Reynaert98)\
**Replies:** 3\
**Last updated:** [September 21, 2020, 9:56am UTC](https://discourse.processing.org/t/moving-a-ellipse-on-a-grid-with-arrow-keys/23987 "2020-09-21T09:56:32Z")

</div>

I have an ellipse that can move on a grid by using the arrow keys. I can move the ellipse but since it’s a function called within draw it keeps creating circles after moving with it. I know using background() in draw can…

---

## [How to Can I turn a flat drawing into 3D?](https://discourse.processing.org/t/how-to-can-i-turn-a-flat-drawing-into-3d/23930)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 6\
**Last updated:** [September 20, 2020, 8:37am UTC](https://discourse.processing.org/t/how-to-can-i-turn-a-flat-drawing-into-3d/23930 "2020-09-20T08:37:10Z")

</div>

Can I turn a flat drawing into 3D? I want to change it like a slanted picture like a 3D feel. Is there any way?

---

## [Loading large amount of image files](https://discourse.processing.org/t/loading-large-amount-of-image-files/23971)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 1\
**Last updated:** [September 20, 2020, 5:16am UTC](https://discourse.processing.org/t/loading-large-amount-of-image-files/23971 "2020-09-20T05:16:49Z")

</div>

I have made an image viewer unfortunately it isn’t really efficient. I can only load a maximum of around 60 medium resolution images, anything high rez or in larger volumes and the program suffers from memory errors. My…

---

## [How to initialize CLASS by it's own function?](https://discourse.processing.org/t/how-to-initialize-class-by-its-own-function/23946)

<div class="topic-metadata">

**Author:** [@IpNeNaEcRe](https://discourse.processing.org/u/IpNeNaEcRe)\
**Replies:** 2\
**Last updated:** [September 19, 2020, 9:34pm UTC](https://discourse.processing.org/t/how-to-initialize-class-by-its-own-function/23946 "2020-09-19T21:34:30Z")

</div>

I can assign a new value to the variables. But I can’t use constructor to initialize the variables in the object function. int nums = 20; Drop\[\] drops = new Drop\[nums\]; void setup() { size(800, 800); smooth(); …

---

## [Rect Overlap error](https://discourse.processing.org/t/rect-overlap-error/23871)

<div class="topic-metadata">

**Author:** [@tribblesontoast](https://discourse.processing.org/u/tribblesontoast)\
**Replies:** 5\
**Last updated:** [September 19, 2020, 5:38pm UTC](https://discourse.processing.org/t/rect-overlap-error/23871 "2020-09-19T17:38:08Z")

</div>

Hi, I’m building a program to add rectangles in random locations that don’t overlap. My issue is that for some reason I can’t see, the checking of the rectangles is happening incorrectly and then adding them with overl…

---

## [How to draw a "three-quarter circle"?](https://discourse.processing.org/t/how-to-draw-a-three-quarter-circle/23448)

<div class="topic-metadata">

**Author:** [@Schred](https://discourse.processing.org/u/Schred)\
**Replies:** 8\
**Last updated:** [September 19, 2020, 8:21am UTC](https://discourse.processing.org/t/how-to-draw-a-three-quarter-circle/23448 "2020-09-19T08:21:21Z")

</div>

I am trying to draw the following in a Processing sketch: The lines are no problem, but I am searching for a way to implement the curves by also just using vertexes. Ideally, I would just have to tell the code the pos…

---

## [How can I create a SVG shape from a svg code?](https://discourse.processing.org/t/how-can-i-create-a-svg-shape-from-a-svg-code/23948)

<div class="topic-metadata">

**Author:** [@Timi](https://discourse.processing.org/u/Timi)\
**Replies:** 1\
**Last updated:** [September 19, 2020, 7:14am UTC](https://discourse.processing.org/t/how-can-i-create-a-svg-shape-from-a-svg-code/23948 "2020-09-19T07:14:06Z")

</div>

Hi everyone, I have a svg code: path class=“st0” d=“M39.28,4.19c0,0-40,19-36,61s26,72,55,82S39.28,4.19,39.28,4.19z”/\> I want to use this code to generate svg shapes, is there any function or library can I use? Current…

---

## [Null pointer error in thread](https://discourse.processing.org/t/null-pointer-error-in-thread/21499)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 49\
**Last updated:** [September 19, 2020, 2:53am UTC](https://discourse.processing.org/t/null-pointer-error-in-thread/21499 "2020-09-19T02:53:57Z")

</div>

I’m trying to implement threading, however anything that is called on the canvas results in a nullpointer error. String \[\] messages = {"Test string for secondary thread", "Here's another message.",…

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

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