forked from craftyjs/Crafty
-
Notifications
You must be signed in to change notification settings - Fork 1
Repository Structure
starwed edited this page Jul 12, 2013
·
9 revisions
This is an explanation of the main Crafty repo.
These are the important directories:
-
/src-- The source code for Crafty -
/build-- Scripts for building crafty and its documentation -
/tests-- Unit tests using the qunit framework. (Several are broken, but core and events should work.) -
/demos-- Small demos of various parts of Crafty's functionality. They can be used to check functionality not covered by the unit tests (such as whether rendering works!)
The build scripts currently depend on php.
- To build crafty, run
build-crafty.shfrom the build directory. It generates a newcrafty.jsin the top level directory of the project.crafty.jsis generated by concatanting many separate source files together. - To build the documentation, run
build-api.sh. The documentation will be generated in/build/api. Documentation is generated from comments in the source code.
Just open up the html files to run the tests in a browser. The following tests should pass; others are currently broken.
- core.html -- tests many parts of Crafty's core functionality
- events.html -- tests several aspects of Crafty's event system
To make Crafty more maintainable, it is split into many separate source files. Build scripts concatanate these files into one monolithic files: crafty.js. Comments in the source code are used to generate the documentation.
core.js - Core methods:
-
Crafty.cfor creating components,Crafty.efor entities -
bind,unbindand similar event handling code -
Crafty()searching for entities -
Crafty.initfor initalizing the stage -
Crafty.timer.stepfor handling the game loop, as well aspause,stop, and similar functions -
Crafty.extendis defined here
extensions.js - Misc. additional imortant code
- testing support for canvas, CSS transitions, deviceorientation, devicemotion, audio and so on
-
Crafty.spritefor creating sprites from spritesheets -
Crafty.addEventandCrafty.removeEventfor directly handling DOM events -
Crafty.viewportfor handling camera movement; component "viewport" - Definitions of
Crafty.keysandCrafty.mouseButtons
Other files
- 2D.js -- Components "2D", "Gravity"; objects Crafty.polygon, Crafty.circle, Crafty.matrix.
- DOM.js -- Components "DOM"; objects Crafty.DOM
- DebugLayer.js -- Components "DebugCanvas", "DebugRectangle", "VisibleMBR", "DebugPolygon", "WiredHitBox", "SolidHitBox"; objects Crafty.DebugCanvas
- HashMap.js -- object Crafty.HashMap and helper functions
- animate.js -- Component "Animation"
- animation.js -- Components "SpriteAnimation", "Tween"
- canvas.js -- Components "Canvas"; objects Crafty.canvas
- collision.js -- Components "Collision"
- controls.js -- Components "Mouse", "Draggable", "Keyboard", "Multiway", "Fourway", "Twoway"; objects Crafty.keydown, Crafty.mouseDispatch, Crafty.touchDispatch, Crafty.keyboardDisptach
- device.js -- Object Crafty.device
- drawing.js -- Components "Color", "Tint", "Image"; methods Crafty.scene; object Crafty.DrawManager
- html.js -- Component "HTML"
- import.js -- Method Crafty.import
- isometric.js -- Object Crafty.isometric
- loader.js -- Methods Crafty.load, Crafty.modules
- math.js -- Objects Crafty.math, Crafty.math.Vector2D, Crafty.math.Matrix2D
- particles.js -- Component "Particles"
- sound.js -- Object Crafty.audio
- sprite.js -- Component "Sprite". (But see extensions.js for
Crafty.sprite) - storage.js -- Object Crafty.storage
- text.js -- Component "Text"
- time.js -- Component "Delay"
These files are only necessary for compiling a complete crafty.js
- license.txt -- Licensing information
- intro.js -- Preamble for built crafty.js file
- outro.js -- Closing lines for built crafty.js file