# Coding Questions

**URL:** https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=44

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

**Page:** 45

---

## [Trouble with z-index and body](https://discourse.processing.org/t/trouble-with-z-index-and-body/10486)

<div class="topic-metadata">

**Author:** [@Indieminor](https://discourse.processing.org/u/Indieminor)\
**Replies:** 5\
**Last updated:** [April 23, 2019, 1:20pm UTC](https://discourse.processing.org/t/trouble-with-z-index-and-body/10486 "2019-04-23T13:20:48Z")

</div>

Hey all, I am fairly new to programming (3.5 months in) and I came across p5.js and decided to implement it into a little project of mine. My main idea is to have random circles generate on keypress or click with random…

---

## [Trying to make a box rotate, getting error even after p5 check](https://discourse.processing.org/t/trying-to-make-a-box-rotate-getting-error-even-after-p5-check/10512)

<div class="topic-metadata">

**Author:** [@octaminotin](https://discourse.processing.org/u/octaminotin)\
**Replies:** 1\
**Last updated:** [April 21, 2019, 4:55am UTC](https://discourse.processing.org/t/trying-to-make-a-box-rotate-getting-error-even-after-p5-check/10512 "2019-04-21T04:55:39Z")

</div>

Heres the error code: Uncaught SyntaxError: missing ) after argument list (sketch: line 10) Thats, "rotateX(framecount \* 01.0) function setup() { createCanvas(400, 400); } function draw() { background(0); noStrok…

---

## [How to create an sphere to have set of tiles in certain position p5](https://discourse.processing.org/t/how-to-create-an-sphere-to-have-set-of-tiles-in-certain-position-p5/10470)

<div class="topic-metadata">

**Author:** [@alpheraz](https://discourse.processing.org/u/alpheraz)\
**Replies:** 6\
**Last updated:** [April 20, 2019, 6:01pm UTC](https://discourse.processing.org/t/how-to-create-an-sphere-to-have-set-of-tiles-in-certain-position-p5/10470 "2019-04-20T18:01:11Z")

</div>

Hello all, I am interested in creating an object that I want to use to hold videos/ or images within but am having great trouble in creating the framework of it. After looking at multiple forums and posts, I can’t seem…

---

## [How do you combine canvases in p5j weather you overlap or organise them](https://discourse.processing.org/t/how-do-you-combine-canvases-in-p5j-weather-you-overlap-or-organise-them/10275)

<div class="topic-metadata">

**Author:** [@octaminotin](https://discourse.processing.org/u/octaminotin)\
**Replies:** 8\
**Last updated:** [April 20, 2019, 5:24pm UTC](https://discourse.processing.org/t/how-do-you-combine-canvases-in-p5j-weather-you-overlap-or-organise-them/10275 "2019-04-20T17:24:56Z")

</div>

basically here it is the basic form of this thought. im considering instance mode being something, although i don’t get the error message for my first equation; note this for someone who knows nothing, but needs to learn…

---

## [How can i use this higher dimmensional equation in p5](https://discourse.processing.org/t/how-can-i-use-this-higher-dimmensional-equation-in-p5/10285)

<div class="topic-metadata">

**Author:** [@octaminotin](https://discourse.processing.org/u/octaminotin)\
**Replies:** 7\
**Last updated:** [April 20, 2019, 5:22pm UTC](https://discourse.processing.org/t/how-can-i-use-this-higher-dimmensional-equation-in-p5/10285 "2019-04-20T17:22:01Z")

</div>

decided to start a math script it reads x^2 + y^2 = 1

---

## [How to make an object move in a circle, as in revolving around a center](https://discourse.processing.org/t/how-to-make-an-object-move-in-a-circle-as-in-revolving-around-a-center/9965)

<div class="topic-metadata">

**Author:** [@Neo\_Wang](https://discourse.processing.org/u/Neo_Wang)\
**Replies:** 4\
**Last updated:** [April 20, 2019, 3:07pm UTC](https://discourse.processing.org/t/how-to-make-an-object-move-in-a-circle-as-in-revolving-around-a-center/9965 "2019-04-20T15:07:03Z")

</div>

what I am trying to do is to create a solar system. several ellipses revolve around a central point to simulate solar system. i know that i could use translate function to make it happen. however, what I am hoping to is…

---

## [The friction acting on a particle is the same , no matter the size](https://discourse.processing.org/t/the-friction-acting-on-a-particle-is-the-same-no-matter-the-size/10491)

<div class="topic-metadata">

**Author:** [@Capt.Sloth](https://discourse.processing.org/u/Capt.Sloth)\
**Replies:** 1\
**Last updated:** [April 20, 2019, 3:00pm UTC](https://discourse.processing.org/t/the-friction-acting-on-a-particle-is-the-same-no-matter-the-size/10491 "2019-04-20T15:00:18Z")

</div>

I have set the value of friction acting on a particle based on its size, yet it appears as if the small ones and the large ones come to a halt at the same rate.I plan on having the large circles come to a halt much quick…

---

## [Uncaught TypeError: Cannot read property 'x' of undefined (sketch: line 36)](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462)

<div class="topic-metadata">

**Author:** [@replicant2021](https://discourse.processing.org/u/replicant2021)\
**Replies:** 1\
**Last updated:** [April 20, 2019, 1:05am UTC](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462 "2019-04-20T01:05:41Z")

</div>

Hello there. I am making a code for Travel Salesman Problem but i got this issue function draw() { background(0); for (var i = 0; i \< cities.length; i++) { ellipse(cities\[i\].x , cities\[i\].y, 8, 8); } stroke(255) s…

---

## [Some variable overflow?](https://discourse.processing.org/t/some-variable-overflow/10449)

<div class="topic-metadata">

**Author:** [@Alexstrinda](https://discourse.processing.org/u/Alexstrinda)\
**Replies:** 2\
**Last updated:** [April 19, 2019, 3:46pm UTC](https://discourse.processing.org/t/some-variable-overflow/10449 "2019-04-19T15:46:45Z")

</div>

Hello! To make my first steps in creating a photo filter I decided to write a script that will take every pixel of some photo and redraw it to the left of the original. This way I planned to see two identical photos. S…

---

## [Theres must be a way of doing this more effectively!](https://discourse.processing.org/t/theres-must-be-a-way-of-doing-this-more-effectively/10430)

<div class="topic-metadata">

**Author:** [@peachman](https://discourse.processing.org/u/peachman)\
**Replies:** 3\
**Last updated:** [April 19, 2019, 7:58am UTC](https://discourse.processing.org/t/theres-must-be-a-way-of-doing-this-more-effectively/10430 "2019-04-19T07:58:49Z")

</div>

Hi all, At the moment I have a tile based system and I want to move either North, East, South or West of a tile, depending on what tile the ‘player’ is in. Done this fine. However my problems comes because of walls in t…

---

## [Mousedrag objects](https://discourse.processing.org/t/mousedrag-objects/10403)

<div class="topic-metadata">

**Author:** [@b\_and\_z](https://discourse.processing.org/u/b_and_z)\
**Replies:** 4\
**Last updated:** [April 18, 2019, 3:23pm UTC](https://discourse.processing.org/t/mousedrag-objects/10403 "2019-04-18T15:23:33Z")

</div>

I recently started looking into classes with a little help from the coding train, so I’m trying to rewrite a project with classes in hopes of making it simpler. Now I’m stuck with this problem: I want the user to drag ar…

---

## [3D rain drops \[The rate at which the drops fall gradually increases\]](https://discourse.processing.org/t/3d-rain-drops-the-rate-at-which-the-drops-fall-gradually-increases/10397)

<div class="topic-metadata">

**Author:** [@Capt.Sloth](https://discourse.processing.org/u/Capt.Sloth)\
**Replies:** 7\
**Last updated:** [April 18, 2019, 9:42am UTC](https://discourse.processing.org/t/3d-rain-drops-the-rate-at-which-the-drops-fall-gradually-increases/10397 "2019-04-18T09:42:04Z")

</div>

This a simple code in which multiple spheres are created at different X and Y coordinates and are given the speed at which they will fall.The speed seems to gradually increase as the number of spheres increase as a resu…

---

## [My paragraph '\<p\> \</p\>' is not uder the sketch](https://discourse.processing.org/t/my-paragraph-p-p-is-not-uder-the-sketch/10408)

<div class="topic-metadata">

**Author:** [@Sky](https://discourse.processing.org/u/Sky)\
**Replies:** 1\
**Last updated:** [April 17, 2019, 8:04pm UTC](https://discourse.processing.org/t/my-paragraph-p-p-is-not-uder-the-sketch/10408 "2019-04-17T20:04:47Z")

</div>

\<body\> \<h1\>Hello World!\</h1\> \<script src="sketch.js"\>\</script\> \<p\>I should be under the sketch\</p\> \</body\> (it is not under the sketch) How does this exactly work?

---

## [Array of method calls?](https://discourse.processing.org/t/array-of-method-calls/10327)

<div class="topic-metadata">

**Author:** [@aaronjmcd2](https://discourse.processing.org/u/aaronjmcd2)\
**Replies:** 2\
**Last updated:** [April 16, 2019, 5:21pm UTC](https://discourse.processing.org/t/array-of-method-calls/10327 "2019-04-16T17:21:42Z")

</div>

Hi all! Basically, I’m trying to build an overlapping drawing that is dependent on which step the user selects. For example: Step 1: A line. Step 2: A line and a circle. Step 3: A line and a circle and a square. Ste…

---

## [Flying text animation jitter](https://discourse.processing.org/t/flying-text-animation-jitter/10296)

<div class="topic-metadata">

**Author:** [@AndreasF](https://discourse.processing.org/u/AndreasF)\
**Replies:** 9\
**Last updated:** [April 16, 2019, 3:57pm UTC](https://discourse.processing.org/t/flying-text-animation-jitter/10296 "2019-04-16T15:57:00Z")

</div>

Hi everyone, I just started with my first sketch in p5. I want to create a flying text effect. I created a simple prototype in the online editor: https://editor.p5js.org/AndreasFurster/sketches/jc1Ozy7VU The only pro…

---

## [Can some one help me stack and navigate two canvases](https://discourse.processing.org/t/can-some-one-help-me-stack-and-navigate-two-canvases/10315)

<div class="topic-metadata">

**Author:** [@octaminotin](https://discourse.processing.org/u/octaminotin)\
**Replies:** 0\
**Last updated:** [April 16, 2019, 12:09am UTC](https://discourse.processing.org/t/can-some-one-help-me-stack-and-navigate-two-canvases/10315 "2019-04-16T00:09:42Z")

</div>

i got this so far {dot.operator function setup1() { iframe\>createCanvas(400, 500); } function draw() { background1(220); } {dot.operator function setup2() { iframe\>createCanvas(400, 400); } function draw() { …

---

## [Trying to code a catch game](https://discourse.processing.org/t/trying-to-code-a-catch-game/10137)

<div class="topic-metadata">

**Author:** [@gp-gp](https://discourse.processing.org/u/gp-gp)\
**Replies:** 3\
**Last updated:** [April 12, 2019, 4:20pm UTC](https://discourse.processing.org/t/trying-to-code-a-catch-game/10137 "2019-04-12T16:20:39Z")

</div>

Im trying to code this catch game i p5, and i cant figure out how i can detect the falling objekt with the “basket” i’ve drawn… hope you guys can help let box1\_x; let box1\_y; let box1 let box2\_x; let box2\_y; let box2\_…

---

## [How to Disable Right Click in the Internet browser](https://discourse.processing.org/t/how-to-disable-right-click-in-the-internet-browser/10211)

<div class="topic-metadata">

**Author:** [@peachman](https://discourse.processing.org/u/peachman)\
**Replies:** 2\
**Last updated:** [April 12, 2019, 12:38pm UTC](https://discourse.processing.org/t/how-to-disable-right-click-in-the-internet-browser/10211 "2019-04-12T12:38:00Z")

</div>

Hi all, I am having a huge frustration with ‘right Clicking’ with P5 in the online editor. I have been looking about for a while and cannot find the answer. Every time i ‘right click’ the options come up for chome, how…

---

## [Curve vertex contour problem](https://discourse.processing.org/t/curve-vertex-contour-problem/10179)

<div class="topic-metadata">

**Author:** [@mkoch](https://discourse.processing.org/u/mkoch)\
**Replies:** 1\
**Last updated:** [April 11, 2019, 9:39am UTC](https://discourse.processing.org/t/curve-vertex-contour-problem/10179 "2019-04-11T09:39:01Z")

</div>

Hello everyone, I have a problem using the beginContour and endContour methods with curve vertices. The contour is not rendered like expected. Here I’ve got a simple example of the problem https://editor.p5js.org/mko…

---

## [Access properties of a sketch's container in instance mode](https://discourse.processing.org/t/access-properties-of-a-sketchs-container-in-instance-mode/10088)

<div class="topic-metadata">

**Author:** [@surmvoise](https://discourse.processing.org/u/surmvoise)\
**Replies:** 4\
**Last updated:** [April 10, 2019, 11:59pm UTC](https://discourse.processing.org/t/access-properties-of-a-sketchs-container-in-instance-mode/10088 "2019-04-10T23:59:31Z")

</div>

How do I access properties of a sketch’s container in instance mode? I’d like to run multiple sketches in all the div’s with a certain class on a page. And I’d like to make the width of these sketches the same as the wi…

---

## [Erasing text or lines?](https://discourse.processing.org/t/erasing-text-or-lines/10104)

<div class="topic-metadata">

**Author:** [@joba1](https://discourse.processing.org/u/joba1)\
**Replies:** 4\
**Last updated:** [April 10, 2019, 7:30am UTC](https://discourse.processing.org/t/erasing-text-or-lines/10104 "2019-04-10T07:30:52Z")

</div>

Hi, I’m new to p5.js (and js in general) and stumbled over this while playing around with the first learning examples. Not sure if Beginners category is only for processing, so I post here: If I write a text in black o…

---

## [How would I apply randomSeed( )](https://discourse.processing.org/t/how-would-i-apply-randomseed/10054)

<div class="topic-metadata">

**Author:** [@dougouverson](https://discourse.processing.org/u/dougouverson)\
**Replies:** 15\
**Last updated:** [April 9, 2019, 3:02pm UTC](https://discourse.processing.org/t/how-would-i-apply-randomseed/10054 "2019-04-09T15:02:52Z")

</div>

Page 221 - 223 - Example 8-9: Move Shapes Randomly At the end of the example, there’s a NOTE about randomSeed( ). I checked out the Reference at https://p5js.org/reference/#/p5/randomSeed I’m trying to figure out how t…

---

## [Moving the camera around](https://discourse.processing.org/t/moving-the-camera-around/6567)

<div class="topic-metadata">

**Author:** [@philippe](https://discourse.processing.org/u/philippe)\
**Replies:** 9\
**Last updated:** [April 9, 2019, 2:15pm UTC](https://discourse.processing.org/t/moving-the-camera-around/6567 "2019-04-09T14:15:55Z")

</div>

I’m trying to move the the camera (with the keyboard) in my 3d sketch but can’t get things working. i’ve tried with and without the Camera() function the result is always a mess ! Could someone give me an hint : for e…

---

## [Unable to get data from .JSON files](https://discourse.processing.org/t/unable-to-get-data-from-json-files/9971)

<div class="topic-metadata">

**Author:** [@peachman](https://discourse.processing.org/u/peachman)\
**Replies:** 6\
**Last updated:** [April 9, 2019, 6:50am UTC](https://discourse.processing.org/t/unable-to-get-data-from-json-files/9971 "2019-04-09T06:50:28Z")

</div>

Hi All, I have been able to get data from JSON files before, but i am unable to get data from this one ‘https://www.osrsbox.com/osrsbox-db/items-json-slot/items-2h.json’ function preload(){ items = loadJSON('https://w…

---

## [Looking for Assistance or direction for dynamic glitter effect with blurr fading](https://discourse.processing.org/t/looking-for-assistance-or-direction-for-dynamic-glitter-effect-with-blurr-fading/9258)

<div class="topic-metadata">

**Author:** [@digimbyte](https://discourse.processing.org/u/digimbyte)\
**Replies:** 6\
**Last updated:** [April 8, 2019, 1:13am UTC](https://discourse.processing.org/t/looking-for-assistance-or-direction-for-dynamic-glitter-effect-with-blurr-fading/9258 "2019-04-08T01:13:40Z")

</div>

Hello, I am new to the world of canvas and I am looking for something quick, simple, and optimized for a clients website. the website has an SVG stencil of the logo and it needs particle effects on it, I’m familiar enou…

---

## [Series of latitude and longitude points to a 2D polygon](https://discourse.processing.org/t/series-of-latitude-and-longitude-points-to-a-2d-polygon/9900)

<div class="topic-metadata">

**Author:** [@kkisin](https://discourse.processing.org/u/kkisin)\
**Replies:** 4\
**Last updated:** [April 7, 2019, 8:24pm UTC](https://discourse.processing.org/t/series-of-latitude-and-longitude-points-to-a-2d-polygon/9900 "2019-04-07T20:24:39Z")

</div>

Hello! I’m trying to convert a series of latitude and longitude points to show up as a polygon at scale in p5.js for example starting with the following series of lat/lon points 44.964782, -93.276922 44.964125, -93.26…

---

## [Centre sketch on specific X and Y co-ordinates](https://discourse.processing.org/t/centre-sketch-on-specific-x-and-y-co-ordinates/9977)

<div class="topic-metadata">

**Author:** [@echo\_bravo](https://discourse.processing.org/u/echo_bravo)\
**Replies:** 2\
**Last updated:** [April 6, 2019, 7:26pm UTC](https://discourse.processing.org/t/centre-sketch-on-specific-x-and-y-co-ordinates/9977 "2019-04-06T19:26:02Z")

</div>

Hi, This is my first forum post/request so please forgive me if I miss any of the etiquette. I have used various various previous version of Java processing but am new to p5.js. What I am struggling with is how to cent…

---

## [Help with making code more effective and efficient](https://discourse.processing.org/t/help-with-making-code-more-effective-and-efficient/9924)

<div class="topic-metadata">

**Author:** [@peachman](https://discourse.processing.org/u/peachman)\
**Replies:** 3\
**Last updated:** [April 5, 2019, 11:05pm UTC](https://discourse.processing.org/t/help-with-making-code-more-effective-and-efficient/9924 "2019-04-05T23:05:41Z")

</div>

Hi All, First time poster, apologises in advance for bad formatting, I have only been using P5.js for about 2 weeks now. I have had previous knowledge of how code works from my programming course at college. 5 years on …

---

## [Creating a game in P5JS](https://discourse.processing.org/t/creating-a-game-in-p5js/9885)

<div class="topic-metadata">

**Author:** [@Ziomix](https://discourse.processing.org/u/Ziomix)\
**Replies:** 2\
**Last updated:** [April 3, 2019, 10:31pm UTC](https://discourse.processing.org/t/creating-a-game-in-p5js/9885 "2019-04-03T22:31:15Z")

</div>

Good morning, everyone, I would like to have some help in my project. My project is as follows: Create a game in P5JS ( of your choice). I already have the basis of the script and I know what I want to do next but unfo…

---

## [(web p5.js) 2048 - Lots of Undefined errors when I do remove(array, index)](https://discourse.processing.org/t/web-p5-js-2048-lots-of-undefined-errors-when-i-do-remove-array-index/9899)

<div class="topic-metadata">

**Author:** [@ILikePi](https://discourse.processing.org/u/ILikePi)\
**Replies:** 5\
**Last updated:** [April 3, 2019, 7:22pm UTC](https://discourse.processing.org/t/web-p5-js-2048-lots-of-undefined-errors-when-i-do-remove-array-index/9899 "2019-04-03T19:22:18Z")

</div>

This is the game of 2048, I am attempting to recreate it to practice using p5. The code is probably very messy, sorry in advance. The First Error I get is " remove is not defined " The Second Error I get is " fill is n…

[Previous page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=43)

[Next page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=45)
