0

I write simple canvas game in Js, I have around 700 lines of code and would like to separate it for more clarity. I want to have one main game loop js file and other files with class and etc. My question is that how I make them connected so the main game loop file could use the other classes and functions from other files??

1 Answers1

0

You can use in the html of your game and that would import the code directly into your html as one main script. Also remember to replace filename.js with your filename.

Timothy Chen
  • 431
  • 3
  • 8
  • How do I do that? What's the name of that solution? I tried modules and error ocures using it and I would need to do a live server for that to work. – Rafal Tomasz Tasak Dec 13 '20 at 23:01
  • Basically in the html of the web page you could put something like and in that thing you could do import {import} from "anotherscriptname.js"; and in anotherscriptname.js do export default class [WHATEVER THE INPUT NAME IS]. – Timothy Chen Dec 13 '20 at 23:20