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

Processing: persistence in transparent 3D object

Previously defined shape (triangle) appears but does not persist in 3D object (sphere) but does outside. The triangle appears in the transparent sphere but vanishes at the next rendering. For transparency, I used enabled DEPTH_SORT. // Aim of…
Alchemille
  • 51
  • 4
1
vote
3 answers

How do you make a circle shaped button in p5.js?

I am making a p5.js project. In it I am generating a list (with 8 elements) and setting them to 1/0. Each one represents a bit (1,2,4,8,16,32,64,128) and if the element is 1, I add the index of the bit array. For example i = 3, states[i] = 1,…
1
vote
1 answer

Why do some balls show they collided but others don't?

I want the balls I spawn in to bounce off of each other when they collide but first I am trying to make it so the code actually detects when they collide. To do that I change the color of the balls that collide with each other and then change them…
Tjtorin
  • 99
  • 1
  • 1
  • 10
1
vote
1 answer

How to manipulate a P5.JS Sketch when hovering over HTML element

I have a p5.js sketch behind the contents of my website, as a pattern. Currently, when you do mousePressed, the shapes get drawn again. I'd like to change this to happen when you hover over the links on the HTML page, not when you click on the…
bnnyrbt
  • 11
  • 1
1
vote
0 answers

Is there a way to optimisate a particle generating algorythm to work with many objects?

In fact, I'm making a background which has to kinda illustrate "influence". I tried to make this with particles, generated from a given point on the screen, which are moving toward a random direction, and which blast after some lifetime they have.…
Hypp
  • 11
  • 1
1
vote
1 answer

How do you work with sprites, and why were they used so widely in older games?

My friend and I decided to create a platformer together as our computer science project. I am currently using an image function in p5.js library to swap between images and create animations for walking, jumping, etc. I looked up how it was done…
Vadim Kim
  • 129
  • 12
1
vote
1 answer

Bug with a cookie

I am currently making a Flappybird game in Javacript and right now I am implementing a cookie to store the highscore. But here is the problem, the cookie is always undefined and won't change. So that nobody is confused, I should say that I use the…
Stefan
  • 1,122
  • 3
  • 14
  • 38
1
vote
2 answers

Maze solving algorithm using p5.js

I have generated a maze using depth first search - recursive backtracker algorithm. I also want to solve, but not getting idea about how to start solving my maze. I am using p5.js to create my maze, and want to solve my already generated maze. This…
pratteek shaurya
  • 850
  • 2
  • 12
  • 34
1
vote
2 answers

Is there a mistake in my method of cycling through an array of audio files?

When speech is detected then the first track plays, it plays till the end and then turns the mic on to listen for something, when it hears something it plays the second track and so on until track ten. Running this code on a chrome browser in…
dackdel
  • 21
  • 2
1
vote
1 answer

How to use a variable from a json to call another json in preload() function?

I am using using p5js library in javascript. I used wrapAPI to make some custom APIs to grab posts and comments from the web. The first API returns the latest posts with the post ID. The second API returns comments of the post with the ID from the…
TMX
  • 13
  • 2
1
vote
0 answers

Move an object between two ml5js poseNet keypoints using p5js

I'm trying to make a circle move between two body keypoints – i.e between left and right shoulder. I started with this code to make an object following some position: var rectLocation; var x = 50; var y = 50; function setup() { …
sebyakin
  • 11
  • 1
1
vote
1 answer

p5.js loadImage(); returning null with error 'SCRIPT5007: SCRIPT5007: Unable to get property 'x' of undefined or null reference'

I am currently recoding a game and im having problems with the rendering engine. i think that the problem is in my file paths, because the old (and identically coded) version works just fine. I've tried moving the program to another disk, changing…
1
vote
2 answers

Customizing buttons in p5js with DOM

I am trying to customize a button using the p5js DOM library. I have looked at the p5js reference and other sources, but there doesn't seem to be anything there. var button; function setup() { createCanvas(100, 100); background(0); …
Darrow Hartman
  • 4,142
  • 2
  • 17
  • 36
1
vote
1 answer

Why am I getting an infinite loop error inp5.js?

With a simple for loop I can trigger a potential infinite loop exception in the p5.js web editor function setup() { var cnt = 0; var startTime = new Date().getTime(); for (i = 0; i < 80000; i++) { console.log(cnt++); } var endTime =…
Tbw
  • 115
  • 1
  • 6
1
vote
2 answers

Javascript merge sort visualisation

I have managed to get a merge sort working in p5.js to sort different length lines but can not figure out how to actually show them being sorted. I.e show them unsorted and then update their position as they are being sorted. I'm not sure if there…