Game Development Reference
In-Depth Information
• Though it may feel natural to write the entire application in JavaScript, try
to avoid creating new DOM in JavaScript. Doing so is slow, and there's a
reason HTML and CSS exist. (Also, don't be afraid to use HTML and CSS;
sometimes that's a much easier solution than, say, writing a custom shader.)
• Use a style guide. Which one you choose is not especially important, but
maintaining a consistent style helps avoid silly mistakes that are otherwise
vulnerable to JavaScript's dynamic typing and expressive syntax.
• JavaScript's prototypal inheritance tends to feel strange to developers used
to classical object-oriented programming. The main advantages are that it's
dynamic (you can add new properties to prototypes and objects after they're
created); there is no diamond problem (you never have ambiguities due to
multiple ancestors); and it's simpler to just do what you want without rigid
structures. We've seen that Three.js uses an inheritance pattern; you can
also use OOP patterns in your code, and it helps to be aware of JavaScript's
strengths in this regard instead of fighting with its weaknesses.
Using Grunt ( http://gruntjs.com/ ) is strongly recommended to simplify your
publishing and testing workflow because it helps minimize the amount of time
between making a change and testing it in action. Grunt is a command-line tool that
executes predetermined tasks, so you can use it to easily perform other publishing
steps. For example, production code should be minified, concatenated, and checked
for syntax errors, which Grunt can do using the UglifyJS and JSHint projects. If
your project is open source, big enough, or has enough people to need separate
documentation, JSDuck ( https://github.com/senchalabs/jsduck ) is a useful tool
to automatically generate it from code comments (and Grunt supports it too). You
can find a great tutorial on getting started with Grunt at http://flippinawesome.
org/2013/07/01/building-a-javascript-library-with-grunt-js/ .
Existing workflows and level development
Few changes should be needed to studios' existing game development pipelines in
order to produce Three.js-based games. Some programmers may not even need to
learn JavaScript if they're not already familiar with it since many languages compile
to JavaScript. Existing processes can be maintained for testing and producing as well
as for developing pitches, concepts, storyboards, models, textures, sounds, and other
resources. The biggest challenge is in assembling those resources—building levels
into Three.js scenes. There aren't amazing tools yet for designing levels for Three.js
games that need them, partly because Three.js is a graphics library and games have
a lot of custom requirements that are hard to generalize well for a single tool. Level
editors tend to be tied pretty closely to the game engine and the classes it provides.
 
Search WWH ::




Custom Search