I’m trying to make an array of images ‘spring’ onto the canvas from the bottom of the screen and then land in random positions, like this image here:enter image description here (this is a screenshot of my canvas after you remove the physics) Here is my attempt so far: https://editor.p5js.org/holographicleah/sketches/DUY0EDnqN I like the animation of the spring that i’ve managed,
Tag: p5.js
Detect multiple keypresses and trigger an action once in p5.js
I want the user to be able to press a+d once and my game should increase the score, not hold it to increase score, similar to when pressing a+d causes a special effect to occur in a game. This code did not work so I didn’t bother to call it fail attempts test. This is my first failing attempt: This
How to go through two colours with sine wave in p5.js
I know how to do it with black and white example I would like it to be purple instead of black but I can’t do it. I would like to achieve something like this. Answer I dont know much about p5.js. But simple googling and would offer this solution With lerp color you could create implementation that supports even more
p5: Using Sine wave in WEBGL to change y-axis
I have some spheres that I want to move straight on the x axis with only their y-axis changing based on the sine wave (you know the up and down yo-yo pattern). It is pretty simple in 2d but for some reason, in WEBGL, the angle changes in the sin function is not working for this.y. Answer You only call
How to draw colorful rotating flower in p5.js?
How can I color those leaves? I added fill(‘red’), fill(‘blue’) in front of each ellipse and somehow only one color dominates all of the petals. Plus, I want it to rotate at a constant speed. Answer Fill seems to work fine. (and added a loop to be more concise)…
Check if mouse is in triangle with three x,y coordinates
Say I have a triangle made with 3 points. How do I check if said triangle contains the a certain set of points? I’m trying to make an interactive UI with P5.js that includes an arrow that allows you to resize the object. The wireframe code is: Is there a dynamic way to tell if a point is within a
jQuery getScript() and a div element id
I am using jQuery to add a div to a page that I’d want to then use as a location for content produced by another script (in this case ,p5). It will work fine if I assign include a static div with the id=’p5canvas’ but when I use jQuery to add dynamic content (see below), nothing happens and I don’t
incorrect bouncing behaviour in p5js play library
I’m using the play library: https://molleindustria.github.io/p5.play/ I’m doing a simple bouncing balls demo, with one large ball whose mass in play is given by $pi r^2$. The basic physics looks right to me. But after a few seconds, the large ball starts to jump large distances when struck by a small ball. Here’s my complete code (EDIT, also pasted below):
Trying to allow the user to step through a for loop for an algorithm using JS and P5 via a button press
i am trying to figure out how i can enable a user to step through an algorithm using a button click on P5 and JS. The other code i have takes some text and displays some custom character cells that are used in the algorithm i mentioned below. I want the user to click a next button and have it
if something == something show something and keep showing it
so when this is true i want to keep the images even when this turns false later Answer I don’t understand why the condition looks like this label==”HowMuchCanYouSee”==true and not just this label==”HowMuchCanYouSee” Anyway you may add a new flag to the story starting with false that will be turned to true the first time your code it’s hit, and