I want to make most of my game in JS, but also prevent players from seeing my game's functions in the console, which means I want to use
For example, I have a Player class which is applied to my Player object type using
createInstance() doesn't take any constructor arguments, I made a static function called
create() to allow me to add properties to the instance after it gets created.
The problem with this is that the Player class is global, so a player could easily go into the console and type
Player.create() to create a new player object.
However, I'm not sure how I would go about this while also letting the rest of my code access these functions.
The only potential solution I've found wraps an IIFE around the Player class so that it's locked away from global scope, but now this means I can only access this class from within the IIFE.
What's the best way to solve this?
P.S: It looks like
runtime is required to do anything with your game's code. Is this fact alone enough to solve this problem?