-
Notifications
You must be signed in to change notification settings - Fork 1
Repository Structure
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.sh
from the build directory. It generates a newcrafty.js
in the top level directory of the project.crafty.js
is 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.
== Testing ==
Just open up the html files to run the tests in a browser. The following tests should pass; others are broken.
- core.html -- tests many parts of Crafty's core functionality
- events.html -- tests several aspects of Crafty's event system
== Source code==
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.c
for creating components,Crafty.e
for entities -
bind
,unbind
and similar event handling code -
Crafty()
searching for entities -
Crafty.init
for initalizing the stage -
Crafty.timer.step
for handling the game loop, as well aspause
,stop
, and similar functions -
Crafty.extend
is defined here
extensions.js -- Misc. additional imortant code
-
testing support for canvas, CSS transitions, deviceorientation, devicemotion, audio and so on
-
Crafty.sprite
for creating sprites from spritesheets -
Crafty.addEvent
andCrafty.removeEvent
for directly handling DOM events -
Crafty.viewport
for handling camera movement; component "viewport" -
Definitions of
Crafty.keys
andCrafty.mouseButtons
-
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