# Physics engine looks like not working but dunno how to test

**URL:** <https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229>\
**Category:** Coding Questions\
**Created:** [March 11, 2023, 8:41am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229 "2023-03-11T08:41:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 11, 2023, 8:41am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/1 "2023-03-11T08:41:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 11, 2023, 9:53am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/2 "2023-03-11T09:53:22Z")

</div>

> [@jounce](#):
>
> [physics lib - Replit](https://replit.com/@imcute-aaaa/physics-lib#script.js)

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 11, 2023, 11:27am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/3 "2023-03-11T11:27:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 11, 2023, 11:27am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/4 "2023-03-11T11:27:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 11, 2023, 11:48am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/5 "2023-03-11T11:48:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 11, 2023, 3:09pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/6 "2023-03-11T15:09:11Z")

</div>

> [@jounce](#):
>
> … p5 and processing are different and have different categories)

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:

> **[home | p5.js](https://p5js.org)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 12, 2023, 12:03am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/7 "2023-03-12T00:03:39Z")

</div>

> [@quark](#):
>
> I don’t understand the problem you can simple create some code in setup and draw to test

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

> [@GoToLoop](#):
>
> n order to avoid ambiguity use “p5.js” or “p5js” instead for this particular flavor:

oh

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 12, 2023, 8:52am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/8 "2023-03-12T08:52:16Z")

</div>

> [@jounce](#):
>
> It’s too complicated to use and I haven’t figured out a way of confining some stuff

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

> [@quark](#):
>
> 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** _.

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 12, 2023, 11:34am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/9 "2023-03-12T11:34:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 12, 2023, 12:23pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/10 "2023-03-12T12:23:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 12, 2023, 12:27pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/11 "2023-03-12T12:27:19Z")

</div>

it is with useful comments

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 12, 2023, 3:27pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/12 "2023-03-12T15:27:12Z")

</div>

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](https://github.com/quarks/canvasGUI/blob/main/src_ts/canvas_gui.ts) I am not saying this is perfect but might give you some ideas for your own library. 😄

```auto
//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

```

---

<div class="post-metadata">

**Author:** ![jounce](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jounce](https://discourse.processing.org/u/jounce)\
**Post date:** [March 13, 2023, 11:37am UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/13 "2023-03-13T11:37:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 13, 2023, 8:46pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/14 "2023-03-13T20:46:22Z")

</div>

Comments should at least comment on the purpose of each method

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 13, 2023, 10:01pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229/15 "2023-03-13T22:01:37Z")

</div>

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
