Skip to content

pSEngine basics

xam4lor edited this page Jun 1, 2020 · 28 revisions

To begin a new project using pSEngine, you can find a template here. If you want to do it manually, you'll need to follow the next few steps.

The HTML part

Firstly, create a basic HTML file containing classic code.

<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">

      <title>YOUR PAGE TITLE</title>
   </head>
   <body>
   </body>
</html>


Then, add a script reference to the pSEngine library with <script type="text/javascript" src="_link_"></script>. For that, you can download and use the last version or use a direct link like https://mecanicascience.github.io/PhysicsSimulationEngine/versions/2.2.0/pSEngine.min.js.

You'll also need to add a reference to the p5.js library. For that, you can download the last version on their website, or use a reference to the 1.0.0 version https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js.



When loaded, pSEngine will try to create a canvas element inside an element with an simulationContent ID. To provide that, just add the following line code to the HTML file inside the <body> elements :

<div id="simulationContent">
</div>


Before starting next part, create a sketch.js and a SObject.js file (you can name them as you want it), and add a reference to them. The HTML file should be almost the same as the one below.

<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">

      <title>YOUR PAGE TITLE</title>

      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>
      <script type="text/javascript" src="https://mecanicascience.github.io/PhysicsSimulationEngine/versions/2.2.0/pSEngine.min.js"></script>
   </head>
   
   <body>
      <div id="simulationContent">
      </div>
   </body>
</html>



Javascript basics

Further reading

Clone this wiki locally