Game Development Reference
In-Depth Information
It's generally considered poor form to prevent client-side cheating
in single-player modes, except when it comes to artifacts that other
players can see, such as high scores.
Development processes
Whether you're an individual who builds games as a hobby or a developer for a
large game publisher, you can benefit from following a number of best practices
adopted from JavaScript development for the Web and game development on other
platforms. You can also build Three.js-based games without deviating too far from
your favorite game development processes.
JavaScript best practices
In previous chapters, we haven't been very concerned with the high-level structure
of our code. We wrote some examples as single HTML files, and we split the FPS and
CTF projects into separate files, but for polished games we should be more careful,
especially when working with teams. General coding lessons apply:
• Keep assets in folders by file type/purpose. For example, at a high level you
might have folders such as css , js , images , models , and sounds . Within
the js folder, organize JavaScript files by purpose; keep library, source, and
production code separate.
• Avoid putting code that directly handles user input event listeners in class
constructors, because that makes them harder to reuse and extend.
• Use separate files for configuration/constants that you can fiddle with to
adjust how the game feels .
• Detect features instead of browsers, since different browser versions
support different features and some features can be toggled on or off in
browser settings.
• Avoid using setTimeout and setInterval for timers in the animation
loop because having a lot of separate timers can cause performance issues.
Instead, check how much time has passed in your animation loop, for
example, using Date.now() or THREE.Clock .
If your game can pause, make sure you're not including
time elapsed while paused.
 
Search WWH ::




Custom Search