Questions tagged [p5.js]

p5.js is a JavaScript library that starts with the original goal of processing, to make coding accessible for artists, designers, educators, and beginners, and reinterprets this for today’s web.

p5.js is a JavaScript library that starts with the original goal of processing, to make coding accessible for artists, designers, educators, and beginners, and reinterprets this for today’s web. p5.js has a full set of drawing functionality too.

See also:

3071 questions
1
vote
1 answer

Line to line intersection works only on one side

I'm creating a raycasting engine on javascript using p5js and there is an issue with the line to line (raycast to wall) intersection. I found a lot of line to line collision algorithms, including p5 collide library, but the problem appears on every…
Dan
  • 39
  • 4
1
vote
1 answer

P5.js draw() Function Executing For-Loops in Wrong Order

So I've been racking my brain over why this doesn't work for hours now... What I'm trying to achieve is practically a "propagation" of rows through a 2D array. Basically, the first row of the array is set to random values, then that row is copied to…
Zaxter5
  • 57
  • 1
  • 2
  • 9
1
vote
0 answers

How to make canvas continue drawing when tab is changed

When I change the tab or I'm no focusing on the tab where canvas or my sketch exists, the drawing stops, I want it to continue drawing even if I'm not focusing on the page or tab where my canvas is. Like this example of code below, when I change to…
Mostafa AGUERRAM
  • 573
  • 1
  • 7
  • 17
1
vote
0 answers

How can I track two colors in p5.js?

Firstly, this is my first ever post on stack, so I'm sorry for being a noob and bad code formatting! My project is based on tracking 3D printed refresh icons - one coloured orange and one coloured blue. I want both to be tracked (ellipse will show).…
1
vote
0 answers

misunderstanding and questions around arrays and key pressed functions

My aim is to hook up a midi device to my computer to create and manipulate shapes in p5.js. I'm still learning code so have a few questions regarding arrays and keys. Is there a way to say if any of the values in noteC, noteE and noteG are…
2242
  • 21
  • 1
1
vote
1 answer

How to trigger animations in correct order in p5.js?

I'm trying to trigger animations in a simple pong game when the ball bounces off each edge. However, I'm struggling to get the animations to appear the way I want them to. I want the ellipses to draw on top of each other in the order that the edges…
bettywhite
  • 13
  • 3
1
vote
3 answers

How to check every item in a 2D array for specific condition?

:) I'm creating a maze using JS and P5, with a two dimensional array filled with numbers 0-8. 0 are empty spots, 1 are walls, 2 is the character you walk with, 3 is the exit and 4-8 are items that randomly spawn. In order to exit the maze (through…
A. Domingo
  • 13
  • 4
1
vote
0 answers

How to send an SQL query from a served javascript file to the server to execute?

I am unable to successfully send a SQL query from a served javascript file back to the server so that the server can process it. I intend on sending the result back to the javascript to do some conditional graphics work with p5.js. There will only…
Jdev52
  • 11
  • 2
1
vote
1 answer

Issues with multiple p5.image

I'm playing around with creating some optical art with p5 and I'm running into issues with the image function. This is mt sketch.js file: import Tile from "./Tile.js"; new p5(p5 => { const rows = 14; const columns = 14; const dimension…
annoyingmouse
  • 5,524
  • 1
  • 27
  • 45
1
vote
0 answers

Particle System/movement in Dynamo, using Python Scripting

So i am trying to translate/re-create this script below, which is in Java (p5 /P5.js), to PythonScript in Dynamo: and my attempt so far looks like this: I just want to know if I am going about this the right way? i feel like im not doing the def…
Zara
  • 87
  • 7
1
vote
1 answer

Breakout code not working. Not sure how to do array

I do not understand how to make multiple colored bricks into an array. Each row would have a different color and I only have one brick that appears and I am not sure how to get an 8x4 array of bricks. I have no clue on how to go about doing…
miles126
  • 11
  • 1
1
vote
2 answers

P5 - processing. unable to run and render multiple sketches at once

I have trouble placing and rendering multiple sketches in one page. I'm working in openprocessing. And since I can't edit the page it's html, I'm adding the code through creating a node and appendChild to the body. Expectations I have a link to the…
Tim
  • 861
  • 1
  • 12
  • 27
1
vote
2 answers

I can't call setup() for some reason

I can't call setup() on my p5js project or change any of the boolean values to false after the thing is started. I've tried making a new function called reset() and instead of calling setup() I called reset() but it didn't work. let x, y; let…
1
vote
1 answer

Cannot read property '0' of undefined in a function (p5.js)

At the first line of my code I put var array = [] but I get the error pointing towards this function. If I log array before calling the function its exactly what it's supposed to be but if I do that anywhere inside the function it doesn't get logged…
Stakoter
  • 17
  • 5
1
vote
1 answer

Make a bullet object in p5.js javascript

i was making a javascript game in p5.js. I made a lot of the game, then wanted to add some combat. I made a weapon that shoots bullets. But now the bullet is hard to make. So here is how my weapon works: it starts from the player location it founds…