4 <title>Serpentity Browser Test
</title>
5 <script src=
"/bower_components/neon/neon.js"></script>
6 <script src=
"/bower_components/serpentity/dist/serpentity.js"></script>
7 <script type=
"application/javascript">
11 console.log("\n## Loading")
12 console.log("Serpentity: " + (typeof Serpentity !== "undefined" ? "LOAD OK" : "FAIL"));
13 console.log("Serpentity.Entity: " + (typeof Serpentity !== "undefined" && Serpentity.Entity ? "LOAD OK" : "FAIL"));
14 console.log("Serpentity.Component: " + (typeof Serpentity !== "undefined" && Serpentity.Component ? "LOAD OK" : "FAIL"));
15 console.log("Serpentity.System: " + (typeof Serpentity !== "undefined" && Serpentity.System ? "LOAD OK" : "FAIL"));
16 console.log("Serpentity.Node: " + (typeof Serpentity !== "undefined" && Serpentity.Node ? "LOAD OK" : "FAIL"));
17 console.log("Serpentity.NodeCollection: " + (typeof Serpentity !== "undefined" && Serpentity.NodeCollection ? "LOAD OK" : "FAIL"));
19 //////////////////////
20 // Create test classes
21 //////////////////////
22 console.log("\n## Creating Test Classes");
23 Class("TestSystem").inherits(Serpentity.System)({
25 added : function added(engine) {
26 this.testNodes = engine.getNodes(TestNode);
27 console.log("System added callback: " + "EXEC OK");
30 removed : function removed(engine) {
31 this.testNodes = null;
32 console.log("System removed callback: " + "EXEC OK");
35 update : function update(dt) {
36 this.testNodes.forEach(function (node) {
37 console.log("Running Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
39 console.log("System update callback: " + "EXEC OK");
43 var testSystem = new TestSystem();
45 Class("LowProTestSystem").inherits(Serpentity.System)({
47 added : function added(engine) {
48 this.testNodes = engine.getNodes(TestNode);
49 console.log("System added callback: " + "EXEC OK");
52 removed : function removed(engine) {
53 this.testNodes = null;
54 console.log("System removed callback: " + "EXEC OK");
57 update : function update(dt) {
58 this.testNodes.forEach(function (node) {
59 console.log("Running Low Priority Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
61 console.log("System update callback: " + "EXEC OK");
65 var lowProTestSystem = new LowProTestSystem();
66 console.log("LowProTestSystem: " + "CREATE OK")
68 Class("MidProTestSystem").inherits(Serpentity.System)({
70 added : function added(engine) {
71 this.testNodes = engine.getNodes(TestNode);
72 console.log("System added callback: " + "EXEC OK");
75 removed : function removed(engine) {
76 this.testNodes = null;
77 console.log("System removed callback: " + "EXEC OK");
80 update : function update(dt) {
81 this.testNodes.forEach(function (node) {
82 console.log("Running Mid Priority Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
84 console.log("System update callback: " + "EXEC OK");
88 var midProTestSystem = new MidProTestSystem();
89 console.log("MidProTestSystem: " + "CREATE OK")
92 Class("TestComponent").inherits(Serpentity.Component)({
97 console.log("TestComponent: " + "CREATE OK")
99 Class("TestNode").inherits(Serpentity.Node)({
104 console.log("TestNode: " + "CREATE OK")
107 console.log("\n## Adding system to the engine")
109 var engine = new Serpentity();
110 console.log("engine: " + "CREATE OK")
112 engine.addSystem(testSystem,
0);
114 console.log("\n## Running update without any entities")
117 console.log("\n## Adding system to the engine and updating")
118 var entity = new Serpentity.Entity();
119 entity.add(new TestComponent());
120 engine.addEntity(entity);
123 console.log("\n## Adding Low Priority System")
124 engine.addSystem(lowProTestSystem,
10);
127 console.log("\n## Adding Mid Priority System")
128 engine.addSystem(midProTestSystem,
5);
131 console.log("\n## Removing the system and readding")
132 engine.removeSystem(testSystem);
134 engine.addSystem(testSystem,
0);
137 console.log("\n## Adding a second entity")
138 var entity = new Serpentity.Entity();
139 entity.add(new TestComponent());
140 engine.addEntity(entity);
143 console.log("\n## Removing entity")
144 engine.removeEntity(entity)
147 console.log("\n## Removing system")
148 engine.removeSystem(testSystem)
153 <h1>404 Droids Not Found
</h1>
154 Look in your console...