Using p5.js functions with Node.js



I’ve been experimenting with Node.js and, and I am now trying to use them together by making a simple shooter game.

Currently, I have a server file, which handles all the game logic and updates the game (collision detection, updating positions), then sends the updated state to the client, which renders it using p5.js on the client’s screen.

However, because my server.js file is a stand-alone javascript file (no index.html), it seems I have no way of accessing p5.js functions within in, which has some functions I would like to use (such as using vectors).

There are multiple resources that I have visited, such as the processing wiki and The Coding Trains videos, but they all don’t use p5.js functions or update it in the client (which I don’t want to do).

Is there any way I can use p5 functions in my server.js, to make it easier to update the game, or do I have to just stick with javascript functions?

I’m not sure if this is the place to ask this, but any questions or advice are welcome,


I’ve got a PVector class in JS if you want: :grinning:


Thanks, that’s exactly what I needed :slight_smile:!