Physics engine looks like not working but dunno how to test

https://replit.com/@imcute-aaaa/physics-lib#script.js
(im not asking about p5,but i used p5,so i can ask,right?)

I tried running this and just got a blank screen so I looked at the code and found

function setup() {
	createCanvas(innerWidth, innerHeight);
	document.body.style.margin = 0;
	document.body.style.padding = 0;
}
function mouseClicked() {
	fullscreen() || fullscreen(true);
}
function draw() {
	background(255);
}

As you can see it has the basic p5.js sketch layout but it does nothing except create a canvas and changes to fullscreen on a mouse click.

What did you expect it to do?

2 Likes

Define a class and some functions.
I should test if the class is working correctly(the functions are tested) but its too big to test.

(yeah thankyou moderator i didn’t realize that p5 and processing are different and have different categories)

There seems to be 2 options

  1. you created the code in the link provided
    If this is the case then I don’t understand the problem you can simple create some code in setup and draw to test
  2. someone else created the code and you want to use it
    This is a real problem for you because there is no API documentation and no comments in the code to help you. In this case I would look for a better example.
2 Likes

Actually just “p5” is an old abbreviation for “Processing”.

The name “Processing” can also refer to all of its flavors.

In order to avoid ambiguity use “p5.js” or “p5js” instead for this particular flavor:

2 Likes

It’s too complicated to use and I haven’t figured out a way of confining some stuff

oh

In which case you didn’t create the code so we go for option 2 from my last post -

1 Like

i did create the code but then found out it was nearly impossible to use

If you created the code then you should at least understand what it is supposed to do so document the source code with useful comments. Without them no one has a chance of helping you.

Once you have commented your code then try to make a simple sketch using the most basic functionality of your code and come back here when you are stuck.

1 Like

it is with useful comments

Below is a copy of all the comments I could find and if you think they are useful I don’t know what else to say except have a look at source code produced for other libraries e.g. canvasGUI I am not saying this is perfect but might give you some ideas for your own library. :smile:

//no methods,is not a class
//on the x axis
//effectively the zero vector
//there is a reason
//to avoid dissymmetry of indices
//monadic forces
//dyadic forces
//DEBUG-UNFRIENDLY AREA AHEAD
//in case some weird force is time dependent which would break the laws of physics but i choose to ignore that
1 Like

Oops!Looks like that its not helpful if not with the line its on

Comments should at least comment on the purpose of each method

1 Like

But when you programmed this tool, you must have had an usage scenario in mind.

Just try to get three items to exist and to display

1 Like