# Coding Questions

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

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

**Page:** 172

---

## [How to make ball not go through walls?](https://discourse.processing.org/t/how-to-make-ball-not-go-through-walls/4203)

<div class="topic-metadata">

**Author:** [@ant](https://discourse.processing.org/u/ant)\
**Replies:** 37\
**Last updated:** [October 10, 2018, 5:49pm UTC](https://discourse.processing.org/t/how-to-make-ball-not-go-through-walls/4203 "2018-10-10T17:49:24Z")

</div>

I’m working on a maze game and ran into a problem. I’m not sure how to make the circle, not through the walls. I know you can probably do it with Boolean but I’m not really familiar with that. Is there a different way su…

---

## [Circle will become larger when mouse moves on it (loop question)](https://discourse.processing.org/t/circle-will-become-larger-when-mouse-moves-on-it-loop-question/4231)

<div class="topic-metadata">

**Author:** [@xhqecho](https://discourse.processing.org/u/xhqecho)\
**Replies:** 6\
**Last updated:** [October 9, 2018, 1:31am UTC](https://discourse.processing.org/t/circle-will-become-larger-when-mouse-moves-on-it-loop-question/4231 "2018-10-09T01:31:08Z")

</div>

Hello, I want to create a project, when the mouse move on the circle, the circle will become larger. I can do it when it’s only one circle, but when I add a loop in it, it cannot work. int x=-45; int a; void setup() {…

---

## [Using inheritance with ArrayList](https://discourse.processing.org/t/using-inheritance-with-arraylist/4246)

<div class="topic-metadata">

**Author:** [@Sarah](https://discourse.processing.org/u/Sarah)\
**Replies:** 3\
**Last updated:** [October 8, 2018, 1:37pm UTC](https://discourse.processing.org/t/using-inheritance-with-arraylist/4246 "2018-10-08T13:37:30Z")

</div>

Hi, I’ve been using inheritance for some of my classes, but I’ve run into some troubles when trying to do the same things with ArrayList's. If I have 2 classes class ObjectType1 { }, class ObjectType2 extends ObjectTy…

---

## [Adding pop-up messages and pictures](https://discourse.processing.org/t/adding-pop-up-messages-and-pictures/4234)

<div class="topic-metadata">

**Author:** [@srishtiverma](https://discourse.processing.org/u/srishtiverma)\
**Replies:** 5\
**Last updated:** [October 8, 2018, 9:59am UTC](https://discourse.processing.org/t/adding-pop-up-messages-and-pictures/4234 "2018-10-08T09:59:10Z")

</div>

This one’s on a time crunch for a class, so I’d really appreciate help fast. Issue is, I’m a beginner trying to execute an idea overly ambitious for me, but now I really need to complete it for class. I’d appreciate any …

---

## [\[Updated\] Help output algorithms for complex numbers in Pascal Triangle](https://discourse.processing.org/t/updated-help-output-algorithms-for-complex-numbers-in-pascal-triangle/4074)

<div class="topic-metadata">

**Author:** [@ProsExplorer](https://discourse.processing.org/u/ProsExplorer)\
**Replies:** 5\
**Last updated:** [October 8, 2018, 12:55am UTC](https://discourse.processing.org/t/updated-help-output-algorithms-for-complex-numbers-in-pascal-triangle/4074 "2018-10-08T00:55:16Z")

</div>

I got this code example online for a Non-recursive version of Pascal’s Triangle and made modifications to it so that it limits the triangle size to an input n, prints the last line based on the int n=1+ 16 \[where +16 = t…

---

## [Spirals that get smaller for school project](https://discourse.processing.org/t/spirals-that-get-smaller-for-school-project/4199)

<div class="topic-metadata">

**Author:** [@DesperateOak48](https://discourse.processing.org/u/DesperateOak48)\
**Replies:** 7\
**Last updated:** [October 7, 2018, 5:46pm UTC](https://discourse.processing.org/t/spirals-that-get-smaller-for-school-project/4199 "2018-10-07T17:46:52Z")

</div>

I’m in a class, and the current assignment is to create a complex pattern. I want to make spirals that start in the middle and extend outward, getting smaller as they go out. I’ve looked around the class to no avail. I f…

---

## [Spiral with connecting lines between adjacent points](https://discourse.processing.org/t/spiral-with-connecting-lines-between-adjacent-points/4170)

<div class="topic-metadata">

**Author:** [@oscie24](https://discourse.processing.org/u/oscie24)\
**Replies:** 17\
**Last updated:** [October 7, 2018, 5:37pm UTC](https://discourse.processing.org/t/spiral-with-connecting-lines-between-adjacent-points/4170 "2018-10-07T17:37:47Z")

</div>

Hi, I’m a newbie on here. I was wondering if I could get some help, please. I’ve been set a task of drawing a spiral made up from squares with lines connecting adjacent points and stuck on how to approach it. Heres wha…

---

## [Put a void statement into a PGraphics layer](https://discourse.processing.org/t/put-a-void-statement-into-a-pgraphics-layer/4057)

<div class="topic-metadata">

**Author:** [@Lore](https://discourse.processing.org/u/Lore)\
**Replies:** 10\
**Last updated:** [October 7, 2018, 3:18pm UTC](https://discourse.processing.org/t/put-a-void-statement-into-a-pgraphics-layer/4057 "2018-10-07T15:18:01Z")

</div>

Hello, Is there anyway to put a void statement into a PGraphics layer? I mean something like this. circles.beginDraw(); circles.noStroke() circles.fill(col); circles.myArc(mouseX, mouseY); circles.e…

---

## [Arrays to draw lines](https://discourse.processing.org/t/arrays-to-draw-lines/4172)

<div class="topic-metadata">

**Author:** [@Merel](https://discourse.processing.org/u/Merel)\
**Replies:** 0\
**Last updated:** [October 5, 2018, 11:42pm UTC](https://discourse.processing.org/t/arrays-to-draw-lines/4172 "2018-10-05T23:42:58Z")

</div>

Hey there! I’ve got a question. I’m trying connect the flowers in my code with (curvy) lines behind them. In order to do that I have to determine the x and the y values of where my flowers are drawn, but since they are …

---

## [Using array's to animate shapes](https://discourse.processing.org/t/using-arrays-to-animate-shapes/4210)

<div class="topic-metadata">

**Author:** [@munixed](https://discourse.processing.org/u/munixed)\
**Replies:** 1\
**Last updated:** [October 7, 2018, 7:51am UTC](https://discourse.processing.org/t/using-arrays-to-animate-shapes/4210 "2018-10-07T07:51:36Z")

</div>

Hi, I’m trying to achieve a number based game where specific numbers move across a screen in a straight line (like invaders) and the user has to match the numbers with a “cannon”. A new invader spawns behind the first i…

---

## [Smooth edges on a surface](https://discourse.processing.org/t/smooth-edges-on-a-surface/4173)

<div class="topic-metadata">

**Author:** [@bryan](https://discourse.processing.org/u/bryan)\
**Replies:** 5\
**Last updated:** [October 7, 2018, 3:41am UTC](https://discourse.processing.org/t/smooth-edges-on-a-surface/4173 "2018-10-07T03:41:14Z")

</div>

Hi! i’m using the marching cubes algorithm for create surfaces. My goal is to create surfaces with a smooth looking. The algorithm creates a facet approximation of the surface following the explanation of Paul Bourke ( h…

---

## [Add mouseClicked moving to bicycle](https://discourse.processing.org/t/add-mouseclicked-moving-to-bicycle/4177)

<div class="topic-metadata">

**Author:** [@BigZi](https://discourse.processing.org/u/BigZi)\
**Replies:** 2\
**Last updated:** [October 7, 2018, 2:48am UTC](https://discourse.processing.org/t/add-mouseclicked-moving-to-bicycle/4177 "2018-10-07T02:48:13Z")

</div>

So i drew a bicycle with 2 ellipse and a few lines in my void body(). I also added a code whereby the bike is reduced size on the left and big on the right. All my code line were written using constant. I used mouseX and…

---

## [Need help with exporting as pdf](https://discourse.processing.org/t/need-help-with-exporting-as-pdf/4193)

<div class="topic-metadata">

**Author:** [@marto](https://discourse.processing.org/u/marto)\
**Replies:** 2\
**Last updated:** [October 6, 2018, 7:01pm UTC](https://discourse.processing.org/t/need-help-with-exporting-as-pdf/4193 "2018-10-06T19:01:24Z")

</div>

Hello guys, I am new to programming and processing and I have some issues with exporting my creation as pdf. I am using the PDF Files from 3D Geometry section of the article on exporting. My issue is that the pdf only sh…

---

## [Moving an ellipse in all four corners](https://discourse.processing.org/t/moving-an-ellipse-in-all-four-corners/4195)

<div class="topic-metadata">

**Author:** [@JeromeBatchoski](https://discourse.processing.org/u/JeromeBatchoski)\
**Replies:** 2\
**Last updated:** [October 6, 2018, 6:11pm UTC](https://discourse.processing.org/t/moving-an-ellipse-in-all-four-corners/4195 "2018-10-06T18:11:38Z")

</div>

Hello, so im kinda struggling with creating an ellipse that moves around in a square movement. It must start in the top-left corner, and move towards the top-right, then moves to the bottom, then to the bottom-left, and …

---

## [Change of the rotation origin of drawn object](https://discourse.processing.org/t/change-of-the-rotation-origin-of-drawn-object/4166)

<div class="topic-metadata">

**Author:** [@bugaj](https://discourse.processing.org/u/bugaj)\
**Replies:** 2\
**Last updated:** [October 6, 2018, 11:35am UTC](https://discourse.processing.org/t/change-of-the-rotation-origin-of-drawn-object/4166 "2018-10-06T11:35:25Z")

</div>

I’m learning about metods of moving objects in proccesing and I tried to make object to act like a tank. The problem is, in order to do so, i want it to rotate around one caterpillar while the other is working and vice v…

---

## [For loop doesnt work like I want](https://discourse.processing.org/t/for-loop-doesnt-work-like-i-want/4183)

<div class="topic-metadata">

**Author:** [@FreshlyChicken](https://discourse.processing.org/u/FreshlyChicken)\
**Replies:** 5\
**Last updated:** [October 6, 2018, 9:45am UTC](https://discourse.processing.org/t/for-loop-doesnt-work-like-i-want/4183 "2018-10-06T09:45:12Z")

</div>

Hello, First I show you my code. int\[\] randomZahl = {3,6,8,9,4}; void setup(){ size(500,500); } void draw(){ line(100,0,100,500); line(200,0,200,500); line(300,0,300,500); line(400,0,400,500); line(500,100,0,100);…

---

## [ArrayoutOfBoundsException](https://discourse.processing.org/t/arrayoutofboundsexception/4182)

<div class="topic-metadata">

**Author:** [@FreshlyChicken](https://discourse.processing.org/u/FreshlyChicken)\
**Replies:** 3\
**Last updated:** [October 6, 2018, 7:29am UTC](https://discourse.processing.org/t/arrayoutofboundsexception/4182 "2018-10-06T07:29:30Z")

</div>

Hello, First I show you my code. int\[\] randomZahl = {3,6,8,9,4}; void setup(){ size(500,500); } void draw(){ line(100,0,100,500); line(200,0,200,500); line(300,0,300,500); line(400,0,400,500); …

---

## [Accessing variables from PVector arraylist from draw()](https://discourse.processing.org/t/accessing-variables-from-pvector-arraylist-from-draw/4179)

<div class="topic-metadata">

**Author:** [@LRyuugaHideki](https://discourse.processing.org/u/LRyuugaHideki)\
**Replies:** 0\
**Last updated:** [October 6, 2018, 4:44am UTC](https://discourse.processing.org/t/accessing-variables-from-pvector-arraylist-from-draw/4179 "2018-10-06T04:44:30Z")

</div>

I’m coding for a two-player game where each player has a colour which is changed when the beam shot out from their opponent touches them. i.e. When Red player’s beam hits blue player, the the tint of the blue player supp…

---

## [Having an object fall down from top of screen from random x value](https://discourse.processing.org/t/having-an-object-fall-down-from-top-of-screen-from-random-x-value/4150)

<div class="topic-metadata">

**Author:** [@help.me](https://discourse.processing.org/u/help.me)\
**Replies:** 2\
**Last updated:** [October 5, 2018, 1:57am UTC](https://discourse.processing.org/t/having-an-object-fall-down-from-top-of-screen-from-random-x-value/4150 "2018-10-05T01:57:21Z")

</div>

I’m currently making a game where numbers are supposed to fall from the top of the screen to the bottom. But i’m having trouble getting the numbers fall from random values from the top of the screen to the bottom. Can an…

---

## [Fibonacci numbers with Function array](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145)

<div class="topic-metadata">

**Author:** [@gisue](https://discourse.processing.org/u/gisue)\
**Replies:** 3\
**Last updated:** [October 4, 2018, 9:18pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145 "2018-10-04T21:18:13Z")

</div>

How can we use array function for Fibonacci? I want to dynamically increase the Array by adding the next Fibonacci numbers. I need to use Processing Array Function and rewrite function fibNumber with integer array fi…

---

## [How to multiply (a + bi)(a + bi) with this Complex Number Class?](https://discourse.processing.org/t/how-to-multiply-a-bi-a-bi-with-this-complex-number-class/4073)

<div class="topic-metadata">

**Author:** [@ProsExplorer](https://discourse.processing.org/u/ProsExplorer)\
**Replies:** 6\
**Last updated:** [October 4, 2018, 6:43pm UTC](https://discourse.processing.org/t/how-to-multiply-a-bi-a-bi-with-this-complex-number-class/4073 "2018-10-04T18:43:19Z")

</div>

I found an example for complex number set multiplication, but I’m new to classes and math functions in processing. I know that the class sets up the operations, though have no idea how to use it. Can someone give an exam…

---

## [How to make a random RGB color value for variable?](https://discourse.processing.org/t/how-to-make-a-random-rgb-color-value-for-variable/4123)

<div class="topic-metadata">

**Author:** [@ProcessingDevin](https://discourse.processing.org/u/ProcessingDevin)\
**Replies:** 3\
**Last updated:** [October 4, 2018, 5:24pm UTC](https://discourse.processing.org/t/how-to-make-a-random-rgb-color-value-for-variable/4123 "2018-10-04T17:24:03Z")

</div>

I have this code and i only get random greyscale colors. All the answers i’ve found on the internet don’t work. How do i do this? color colorBall = color(0, 0, 0); float xspeed = 5; float yspeed = 4; float circleX = 0…

---

## [Collision check multiple balls](https://discourse.processing.org/t/collision-check-multiple-balls/4121)

<div class="topic-metadata">

**Author:** [@tatsuya98](https://discourse.processing.org/u/tatsuya98)\
**Replies:** 4\
**Last updated:** [October 4, 2018, 4:50pm UTC](https://discourse.processing.org/t/collision-check-multiple-balls/4121 "2018-10-04T16:50:02Z")

</div>

Hello, I am trying to make a simple ball dodging game. But i 'm having a small problem with the collision check using dist() function. Here is the section of the code: Ball\[\] balls; boolean \[\] keys; float w; float …

---

## [Processing is my Whetstone](https://discourse.processing.org/t/processing-is-my-whetstone/3885)

<div class="topic-metadata">

**Author:** [@HackinHarry](https://discourse.processing.org/u/HackinHarry)\
**Replies:** 6\
**Last updated:** [October 4, 2018, 1:28am UTC](https://discourse.processing.org/t/processing-is-my-whetstone/3885 "2018-10-04T01:28:06Z")

</div>

I’m not the sharpest tool in the shed, but I try to exercise what I got and Processing has been my whetstone. I recently tried out some vector math, cross product, dot product, etc. with good results after some typos sl…

---

## [Moving a shape by mouseClicked function](https://discourse.processing.org/t/moving-a-shape-by-mouseclicked-function/4112)

<div class="topic-metadata">

**Author:** [@nerdboybi](https://discourse.processing.org/u/nerdboybi)\
**Replies:** 5\
**Last updated:** [October 4, 2018, 3:02pm UTC](https://discourse.processing.org/t/moving-a-shape-by-mouseclicked-function/4112 "2018-10-04T15:02:43Z")

</div>

I would like to move a shape to wherever I have clicked on the canvas. This is my program. Please tell me what changes i need to make in this int xPos; int yPos; void setup() { size(500,500); } void draw() { …

---

## [Using void in PGraphics](https://discourse.processing.org/t/using-void-in-pgraphics/4045)

<div class="topic-metadata">

**Author:** [@Lore](https://discourse.processing.org/u/Lore)\
**Replies:** 4\
**Last updated:** [October 4, 2018, 4:44am UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045 "2018-10-04T04:44:33Z")

</div>

Hello, I have this section of code here void myArc(float cx, float cy) { float r = size / 2; float yOffset = (4\*r) / (3\*PI); circles.beginDraw(); circles.pushMatrix(); circles.translate(cx, cy - yOffset);…

---

## [\[SOLVED\] Getting lines to rotate from their centre](https://discourse.processing.org/t/solved-getting-lines-to-rotate-from-their-centre/4063)

<div class="topic-metadata">

**Author:** [@ianmarquette](https://discourse.processing.org/u/ianmarquette)\
**Replies:** 3\
**Last updated:** [October 3, 2018, 11:49pm UTC](https://discourse.processing.org/t/solved-getting-lines-to-rotate-from-their-centre/4063 "2018-10-03T23:49:43Z")

</div>

I’m trying to create some works by Vera Molnar in Processing to get a better understanding of how to use it. This is the piece I am trying to recreate: The part I am struggling with is getting the lines to all rotate…

---

## [Help needed, bounce, clickable area](https://discourse.processing.org/t/help-needed-bounce-clickable-area/4011)

<div class="topic-metadata">

**Author:** [@SolDrakibane](https://discourse.processing.org/u/SolDrakibane)\
**Replies:** 4\
**Last updated:** [October 3, 2018, 11:36pm UTC](https://discourse.processing.org/t/help-needed-bounce-clickable-area/4011 "2018-10-03T23:36:17Z")

</div>

Alright i have two issues at hand with the code below. Bounces Bouncing the bullseye works with the code below in the horizontal X. When i change that to Y it also works. How can i make X and Y work by making it bou…

---

## [Question about changing color over time](https://discourse.processing.org/t/question-about-changing-color-over-time/4093)

<div class="topic-metadata">

**Author:** [@vincentn20](https://discourse.processing.org/u/vincentn20)\
**Replies:** 1\
**Last updated:** [October 3, 2018, 6:27pm UTC](https://discourse.processing.org/t/question-about-changing-color-over-time/4093 "2018-10-03T18:27:43Z")

</div>

Here is my code int colR = 67; int colG = 91; int colB = 155; void setup() { size(1000, 800); frameRate(30); background(colR,colG,colB); delay(500); } void changeNight() { if(mousePressed) { for(int i = 1…

---

## [3d model in .obj format not appearing in my sketch](https://discourse.processing.org/t/3d-model-in-obj-format-not-appearing-in-my-sketch/4090)

<div class="topic-metadata">

**Author:** [@Jpupper](https://discourse.processing.org/u/Jpupper)\
**Replies:** 1\
**Last updated:** [October 3, 2018, 4:35pm UTC](https://discourse.processing.org/t/3d-model-in-obj-format-not-appearing-in-my-sketch/4090 "2018-10-03T16:35:35Z")

</div>

So, i´ve been trying to use a 3d model that i´ve downloaded from here : https://www.turbosquid.com/3d-models/brain-max-free/833681 Im using the standart code from LoadDisplayOBJ wich does shows up the rocket in the exam…

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

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