4 <title>Serpentity Browser Test
</title>
5 <script src=
"/bower_components/neon/neon.js"></script>
6 <script src=
"/bower_components/serpentity/serpentity.js"></script>
7 <script src=
"/bower_components/serpentity/entity.js"></script>
8 <script src=
"/bower_components/serpentity/node.js"></script>
9 <script src=
"/bower_components/serpentity/node_collection.js"></script>
10 <script src=
"/bower_components/serpentity/component.js"></script>
11 <script src=
"/bower_components/serpentity/system.js"></script>
12 <script type=
"application/javascript">
16 console.log("\n## Loading")
17 console.log("Serpentity: " + (typeof Serpentity !== "undefined" ? "LOAD OK" : "FAIL"));
18 console.log("Serpentity.Entity: " + (typeof Serpentity !== "undefined" && Serpentity.Entity ? "LOAD OK" : "FAIL"));
19 console.log("Serpentity.Component: " + (typeof Serpentity !== "undefined" && Serpentity.Component ? "LOAD OK" : "FAIL"));
20 console.log("Serpentity.System: " + (typeof Serpentity !== "undefined" && Serpentity.System ? "LOAD OK" : "FAIL"));
21 console.log("Serpentity.Node: " + (typeof Serpentity !== "undefined" && Serpentity.Node ? "LOAD OK" : "FAIL"));
22 console.log("Serpentity.NodeCollection: " + (typeof Serpentity !== "undefined" && Serpentity.NodeCollection ? "LOAD OK" : "FAIL"));
24 //////////////////////
25 // Create test classes
26 //////////////////////
27 console.log("\n## Creating Test Classes");
28 Class("TestSystem").inherits(Serpentity.System)({
30 added : function added(engine) {
31 this.testNodes = engine.getNodes(TestNode);
32 console.log("System added callback: " + "EXEC OK");
35 removed : function removed(engine) {
36 this.testNodes = null;
37 console.log("System removed callback: " + "EXEC OK");
40 update : function update(dt) {
41 this.testNodes.forEach(function (node) {
42 console.log("Running Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
44 console.log("System update callback: " + "EXEC OK");
48 var testSystem = new TestSystem();
50 Class("LowProTestSystem").inherits(Serpentity.System)({
52 added : function added(engine) {
53 this.testNodes = engine.getNodes(TestNode);
54 console.log("System added callback: " + "EXEC OK");
57 removed : function removed(engine) {
58 this.testNodes = null;
59 console.log("System removed callback: " + "EXEC OK");
62 update : function update(dt) {
63 this.testNodes.forEach(function (node) {
64 console.log("Running Low Priority Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
66 console.log("System update callback: " + "EXEC OK");
70 var lowProTestSystem = new LowProTestSystem();
71 console.log("LowProTestSystem: " + "CREATE OK")
73 Class("MidProTestSystem").inherits(Serpentity.System)({
75 added : function added(engine) {
76 this.testNodes = engine.getNodes(TestNode);
77 console.log("System added callback: " + "EXEC OK");
80 removed : function removed(engine) {
81 this.testNodes = null;
82 console.log("System removed callback: " + "EXEC OK");
85 update : function update(dt) {
86 this.testNodes.forEach(function (node) {
87 console.log("Running Mid Priority Node: " + (node.test.testMessage === "test" ? "SYSTEM OK" : "FAIL"));
89 console.log("System update callback: " + "EXEC OK");
93 var midProTestSystem = new MidProTestSystem();
94 console.log("MidProTestSystem: " + "CREATE OK")
97 Class("TestComponent").inherits(Serpentity.Component)({
102 console.log("TestComponent: " + "CREATE OK")
104 Class("TestNode").inherits(Serpentity.Node)({
109 console.log("TestNode: " + "CREATE OK")
112 console.log("\n## Adding system to the engine")
114 var engine = new Serpentity();
115 console.log("engine: " + "CREATE OK")
117 engine.addSystem(testSystem,
0);
119 console.log("\n## Running update without any entities")
122 console.log("\n## Adding system to the engine and updating")
123 var entity = new Serpentity.Entity();
124 entity.add(new TestComponent());
125 engine.addEntity(entity);
128 console.log("\n## Adding Low Priority System")
129 engine.addSystem(lowProTestSystem,
10);
132 console.log("\n## Adding Mid Priority System")
133 engine.addSystem(midProTestSystem,
5);
136 console.log("\n## Removing the system and readding")
137 engine.removeSystem(testSystem);
139 engine.addSystem(testSystem,
0);
142 console.log("\n## Adding a second entity")
143 var entity = new Serpentity.Entity();
144 entity.add(new TestComponent());
145 engine.addEntity(entity);
148 console.log("\n## Removing entity")
149 engine.removeEntity(entity)
152 console.log("\n## Removing system")
153 engine.removeSystem(testSystem)
158 <h1>404 Droids Not Found
</h1>
159 Look in your console...