Selaa lähdekoodia

Commented Basic2D, Basic3D, Butterflies, RoboMan3D and ToonTown examples.
Resurrected LightFlicked component, day/night time and sounds in ToonTown example :)

rsredsq 10 vuotta sitten
vanhempi
sitoutus
7a27429e1c

+ 9 - 2
Basic2D/Resources/Components/Star.js

@@ -1,22 +1,29 @@
 'atomic component';
 
+//A star component
 exports.component = function(self) {
 
+    //link to the current node
     var node = self.node;
 
+    //start function calls when component attached to the node, calls after constructor
     self.start = function() {
 
+        //create StaticSprite2D component to the current node
         var sprite2D = node.createComponent("StaticSprite2D");
+        //get star.png sprite from cache
         sprite2D.sprite = Atomic.cache.getResource("Sprite2D", "Sprites/star.png");
+        //set blend mode to BLEND_ALPHA
         sprite2D.blendMode = Atomic.BLEND_ALPHA;
 
     }
 
+    //update function calls each frame
     self.update = function(timeStep) {
-
+        //roll a node
         node.roll(timeStep * 100);
 
     }
 
 
-}
+}

+ 2 - 10
Basic2D/Resources/Scripts/main.js

@@ -1,11 +1,3 @@
 // This script is the main entry point of the game
-
-var scene = Atomic.player.loadScene("Scenes/Scene.scene");
-
-// called per frame, optional
-function update(timeStep) {
-
-
-}
-
-exports.update = update;
+//Load scene
+Atomic.player.loadScene("Scenes/Scene.scene");

+ 6 - 2
Basic3D/Resources/Components/Spinner.js

@@ -1,15 +1,19 @@
 "atomic component";
 
+//define inspector fields
 var inspectorFields = {
+    //value speed will be able to be edited from editor
+    //default value sets to the 1.0, so speed has a number type
     speed: 1.0
 }
 
 exports.component = function(self) {
 
+    //update function calls each frame
     self.update = function(timeStep) {
-
+        //rotate node around Y axis
         self.node.yaw(timeStep * 75 * self.speed);
 
     }
 
-}
+}

+ 2 - 10
Basic3D/Resources/Scripts/main.js

@@ -1,11 +1,3 @@
 // This script is the main entry point of the game
-
-var scene = Atomic.player.loadScene("Scenes/Scene.scene");
-
-// called per frame, optional
-function update(timeStep) {
-
-
-}
-
-exports.update = update;
+//Load scene
+Atomic.player.loadScene("Scenes/Scene.scene");

+ 11 - 13
Butterflies/Resources/Components/Butterfly.js

@@ -12,20 +12,18 @@ exports.component = function(self) {
     self.rotationSpeed = 10;
     self.direction = Math.random() * Math.PI * 2;
     self.time = 0.0;
-    
-    var spr = node.createComponent("AnimatedSprite2D");
-
-    spr.animationSet = animationSet;
-    spr.setAnimation("idle");
-    spr.color = [.1 + Math.random() * .9, .1 + Math.random() * .9, .1 + Math.random() * .9, 1];
-    spr.blendMode = Atomic.BLEND_ALPHA;
-    
 
+    //start function calls once, when component attached to the node
     self.start = function() {
-
+        //pos is a array with 2 elements, the first is X, the second is Y
         self.pos = node.getPosition2D();
-        self.spr = node.getComponent("AnimatedSprite2D");
 
+        //create AnimatedSprite2D component
+        self.spr = node.createComponent("AnimatedSprite2D");
+        self.spr.animationSet = animationSet;
+        self.spr.setAnimation("idle");
+        self.spr.color = [.1 + Math.random() * .9, .1 + Math.random() * .9, .1 + Math.random() * .9, 1];
+        self.spr.blendMode = Atomic.BLEND_ALPHA;
     }
 
     self.update = function(timeStep) {
@@ -37,10 +35,11 @@ exports.component = function(self) {
         self.pos[1] += Math.sin(self.direction) * self.speed * timeStep;
         node.position2D = self.pos;
         node.rotation2D = (self.direction + Math.PI * 3 / 2) * (180 / Math.PI);
+        //check if our butterfly is out of bounds
         if (self.pos[0] < -halfWidth || self.pos[1] < -halfHeight || self.pos[0] > halfWidth || self.pos[1] > halfHeight)
             node.remove();
     }
-
+    //just a maths functions, nothing really interesting
     self.circWrapTo = function(value, target, step) {
         if (value == target) return target;
         var max = Math.PI * 2;
@@ -53,7 +52,6 @@ exports.component = function(self) {
         return result;
     };
     self.wrappedDistance = function(a, b, max) {
-
         if (a == b) return 0;
         var l;
         var r;
@@ -69,4 +67,4 @@ exports.component = function(self) {
     };
 
 
-}
+}

+ 8 - 4
Butterflies/Resources/Components/Spawner.js

@@ -7,20 +7,24 @@ var particleEffect = Atomic.cache.getResource("ParticleEffect2D", "Particles/par
 exports.component = function(self) {
 
     self.update = function(timeStep) {
-
+        //if Left mouse button is pressed
         if (Atomic.input.getMouseButtonDown(Atomic.MOUSEB_LEFT)) {
 
             var mpos = Atomic.input.getMousePosition();
+            //project mouse screen position to the world position
             var pos = viewport.screenToWorldPoint(mpos[0], mpos[1], 0);
-
+            //create butterfly node
             var butterfly = self.scene.createChild("Butterfly");
             butterfly.position2D = pos;
             butterfly.createJSComponent("Components/Butterfly.js");
-
+            
+        //if Right mouse button WAS pressed once
         } else if (Atomic.input.getMouseButtonPress(Atomic.MOUSEB_RIGHT)) {
 
+            //create particle emitter
             var emitter = self.scene.createChild("ButterflyEmitter");
             var mpos = Atomic.input.getMousePosition();
+            //project mouse screen position to the world position
             var pos = viewport.screenToWorldPoint(mpos[0], mpos[1], 0);
             emitter.position2D = pos;
             var pex = emitter.createComponent("ParticleEmitter2D");
@@ -30,4 +34,4 @@ exports.component = function(self) {
 
     }
 
-}
+}

+ 3 - 2
Butterflies/Resources/Scripts/main.js

@@ -12,6 +12,7 @@ var camera = cameraNode.createComponent("Camera");
 
 // setup as 2D
 camera.setOrthographic(true);
+//Atomic.PIXEL_SIZE / 2 means that our pixels are doubled up
 camera.setOrthoSize(Atomic.graphics.height * Atomic.PIXEL_SIZE / 2);
 
 // create a viewport
@@ -40,7 +41,7 @@ function createInstructions() {
     layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_RIGHT_BOTTOM;
     // while "distribution" handles the Y axis
     layout.layoutDistributionPosition = Atomic.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM;
-    
+
     var fd = new Atomic.UIFontDescription();
     fd.id = "Vera";
     fd.size = 18;
@@ -54,4 +55,4 @@ function createInstructions() {
     layout.addChild(scoreText);
 
 
-}
+}

+ 47 - 34
RoboMan3D/Resources/Components/AvatarController.js

@@ -1,16 +1,19 @@
 // designate component
 "atomic component";
-
-var inspectorFields = {
-  speed: 1.0
-}
-
+//import gl-matrix library
+//https://github.com/toji/gl-matrix for more information
 var glmatrix = require("gl-matrix");
 var quat = glmatrix.quat;
 var vec3 = glmatrix.vec3;
 
+//define an inspectorFields to make variables visible in editor
+var inspectorFields = {
+  //needs default value to make editor understand type of that value
+  speed: 1.0
+}
+//define a component AvatarController
 exports.component = function(self) {
-
+  //link to the current node
   var node = self.node;
 
   var cameraNode;
@@ -19,6 +22,7 @@ exports.component = function(self) {
   var okToJump = true;
   var inAirTime = 0;
 
+  //define constans
   var MOVE_FORCE = 1.8;
   var INAIR_MOVE_FORCE = 0.02;
   var BRAKE_FORCE = 0.2;
@@ -46,7 +50,7 @@ exports.component = function(self) {
   self.idle = true;
 
   self.start = function() {
-
+    //get main camera and set its node to cameraNode
     var camera = node.scene.getMainCamera();
     cameraNode = camera.node;
 
@@ -69,17 +73,19 @@ exports.component = function(self) {
 
   self.fixedUpdate = function(timestep) {
 
+    //get a RigidBody component from the current node
     var body = node.getComponent("RigidBody");
 
     // Update the in air timer. Reset if grounded
     if (!onGround)
-    inAirTimer += timeStep;
+      inAirTimer += timeStep;
     else
-    inAirTimer = 0.0;
+      inAirTimer = 0.0;
 
     // When character has been in air less than 1/10 second, it's still interpreted as being on ground
     var softGrounded = inAirTimer < INAIR_THRESHOLD_TIME;
 
+    // Get rotation of the current node
     var rot = node.getRotation();
 
     var moveDir = [0, 0, 0];
@@ -128,24 +134,25 @@ exports.component = function(self) {
         if (okToJump) {
           var jumpforce = [0, 1, 0];
           vec3.scale(jumpforce, jumpforce, JUMP_FORCE);
+          //Apply impulse to the body
           body.applyImpulse(jumpforce);
           okToJump = false;
         }
-      } else
-      okToJump = true;
+      } else {
+        okToJump = true;
+      }
     }
 
 
     if (softGrounded && vec3.length(moveDir) > 0.0)
-    self.idle = false;
+      self.idle = false;
     else
-    self.idle = true;
+      self.idle = true;
 
 
     // Reset grounded flag for next frame
     onGround = true;
 
-
   }
 
   function MoveCamera(timeStep) {
@@ -159,24 +166,25 @@ exports.component = function(self) {
     pitch = pitch + MOUSE_SENSITIVITY * mouseMoveY;
 
     if (pitch < -90)
-    pitch = -90;
+      pitch = -90;
 
     if (pitch > 90)
-    pitch = 90;
+      pitch = 90;
 
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode.rotation = QuatFromEuler(pitch, yaw, 0.0);
 
     var speed = MOVE_SPEED * timeStep;
 
+    //translate camera on the amount of speed value
     if (moveForward)
-    cameraNode.translate([0.0, 0.0, speed])
+      cameraNode.translate([0.0, 0.0, speed])
     if (moveBackwards)
-    cameraNode.translate([0.0, 0.0, -speed])
+      cameraNode.translate([0.0, 0.0, -speed])
     if (moveLeft)
-    cameraNode.translate([-speed, 0.0, 0.0])
+      cameraNode.translate([-speed, 0.0, 0.0])
     if (moveRight)
-    cameraNode.translate([speed, 0.0, 0.0])
+      cameraNode.translate([speed, 0.0, 0.0])
 
   }
 
@@ -198,63 +206,67 @@ exports.component = function(self) {
     // Mouse sensitivity as degrees per pixel
     var MOUSE_SENSITIVITY = 0.1;
 
+    //check input
     if (input.getKeyDown(Atomic.KEY_W))
-    moveForward = true;
+        moveForward = true;
     if (input.getKeyDown(Atomic.KEY_S))
-    moveBackwards = true;
+        moveBackwards = true;
     if (input.getKeyDown(Atomic.KEY_A))
-    moveLeft = true;
+        moveLeft = true;
     if (input.getKeyDown(Atomic.KEY_D))
-    moveRight = true;
+        moveRight = true;
 
     if (input.getKeyPress(Atomic.KEY_F))
-    button0 = true;
+        button0 = true;
     if (input.getKeyPress(Atomic.KEY_SPACE))
-    button1 = true;
+        button1 = true;
 
+    //update mouse coordinates
     mouseMoveX = input.getMouseMoveX();
     mouseMoveY = input.getMouseMoveY();
 
-
-
   }
 
   self.update = function(timeStep) {
 
     UpdateControls();
 
+    //if it's a free view
     if (cameraMode != 2) {
       yaw += mouseMoveX * YAW_SENSITIVITY;
       pitch += mouseMoveY * YAW_SENSITIVITY;
     }
 
     if (pitch < -80)
-    pitch = -80;
+      pitch = -80;
     if (pitch > 80)
-    pitch = 80;
+      pitch = 80;
 
     if (button0) {
       cameraMode++;
       if (cameraMode == 3)
-      cameraMode = 0;
+        cameraMode = 0;
     }
 
   }
 
+  //that function called right after update function
   self.postUpdate = function(timestep) {
 
     // Get camera lookat dir from character yaw + pitch
     var rot = node.getRotation();
 
+    //create quaternion
     dir = quat.create();
+    //set X value
     quat.setAxisAngle(dir, [1, 0, 0], (pitch * Math.PI / 180.0));
 
     quat.multiply(dir, [rot[1], rot[2], rot[3], rot[0]], dir);
 
     var headNode = node.getChild("Head_Tip", true);
 
+    //if it's a FPS view
     if (cameraMode == 1) {
-
       var headPos = headNode.getWorldPosition();
       var offset = [0.0, 0.15, 0.2];
       vec3.add(headPos, headPos, vec3.transformQuat(offset, offset, [rot[1], rot[2], rot[3], rot[0]]));
@@ -264,6 +276,7 @@ exports.component = function(self) {
       node.setRotation([dir[3], dir[0], dir[1], dir[2]]);
 
     }
+    //if it's a third person view
     if (cameraMode == 0) {
 
       var aimPoint = node.getWorldPosition();
@@ -283,9 +296,9 @@ exports.component = function(self) {
       node.setRotation([dir[3], dir[0], dir[1], dir[2]]);
 
     }
-    else
+    else{
       MoveCamera(timestep);
-
+    }
   }
 }
 

+ 7 - 6
RoboMan3D/Resources/Components/RoboMan.js

@@ -1,19 +1,21 @@
 // designate component
 "atomic component";
 
+//A RoboMan component
 exports.component = function(self) {
-
+  //link to the current node
   var node = self.node;
 
+  //get Animation and Avatar controller components
   var animCtrl = node.getComponent("AnimationController");
   var controller = node.getJSComponent("AvatarController");
 
   var idle = true;
 
   self.start = function() {
-
+    //get main camera of the current scene
     var camera = node.scene.getMainCamera();
-
+    //if it exist
     if (camera) {
 
       camera.node.position = [0, 0, -10];
@@ -22,17 +24,16 @@ exports.component = function(self) {
     }
 
     animCtrl.playExclusive("Idle", 0, true, 0.0);
-
+    //rotate current node around Y axis
     node.yaw(180);
 
   }
 
-  // we need an update or it doesn't run the start, fix in JSVM
   self.update = function(timeStep) {
 
+    //rotate current node around Y axis
     node.yaw(180);
 
-
     if (idle != controller.idle) {
 
       idle = controller.idle;

+ 2 - 9
RoboMan3D/Resources/Scripts/main.js

@@ -1,10 +1,3 @@
 // This script is the main entry point of the game
-
-var scene = Atomic.player.loadScene("Scenes/Test.scene");
-
-// called per frame, optional
-function update(timeStep) {
-
-}
-
-exports.update = update;
+//Load scene
+Atomic.player.loadScene("Scenes/Test.scene");

+ 0 - 1
RoboMan3D/Resources/Scripts/main.js.asset

@@ -1,7 +1,6 @@
 {
 	"version": 1,
 	"guid": "32a79f4468a7351975f6a1fad7e85306",
-	"timestamp": 1437768286,
 	"JavascriptImporter": {
 		"IsComponentFile": false
 	}

+ 45 - 32
ToonTown/Resources/Components/AvatarController.js

@@ -1,16 +1,19 @@
 // designate component
 "atomic component";
-
-var inspectorFields = {
-  speed: 1.0
-}
-
+//import gl-matrix library
+//https://github.com/toji/gl-matrix for more information
 var glmatrix = require("gl-matrix");
 var quat = glmatrix.quat;
 var vec3 = glmatrix.vec3;
 
+//define an inspectorFields to make variables visible in editor
+var inspectorFields = {
+  //needs default value to make editor understand type of that value
+  speed: 1.0
+}
+//define a component AvatarController
 exports.component = function(self) {
-
+  //link to the current node
   var node = self.node;
 
   var cameraNode;
@@ -19,6 +22,7 @@ exports.component = function(self) {
   var okToJump = true;
   var inAirTime = 0;
 
+  //define constans
   var MOVE_FORCE = 1.8;
   var INAIR_MOVE_FORCE = 0.02;
   var BRAKE_FORCE = 0.2;
@@ -46,7 +50,7 @@ exports.component = function(self) {
   self.idle = true;
 
   self.start = function() {
-
+    //get main camera and set its node to cameraNode
     var camera = node.scene.getMainCamera();
     cameraNode = camera.node;
 
@@ -69,6 +73,7 @@ exports.component = function(self) {
 
   self.fixedUpdate = function(timestep) {
 
+    //get a RigidBody component from the current node
     var body = node.getComponent("RigidBody");
 
     // Update the in air timer. Reset if grounded
@@ -80,6 +85,7 @@ exports.component = function(self) {
     // When character has been in air less than 1/10 second, it's still interpreted as being on ground
     var softGrounded = inAirTimer < INAIR_THRESHOLD_TIME;
 
+    // Get rotation of the current node
     var rot = node.getRotation();
 
     var moveDir = [0, 0, 0];
@@ -128,24 +134,25 @@ exports.component = function(self) {
         if (okToJump) {
           var jumpforce = [0, 1, 0];
           vec3.scale(jumpforce, jumpforce, JUMP_FORCE);
+          //Apply impulse to the body
           body.applyImpulse(jumpforce);
           okToJump = false;
         }
-      } else
-      okToJump = true;
+      } else {
+        okToJump = true;
+      }
     }
 
 
     if (softGrounded && vec3.length(moveDir) > 0.0)
-    self.idle = false;
+      self.idle = false;
     else
-    self.idle = true;
+      self.idle = true;
 
 
     // Reset grounded flag for next frame
     onGround = true;
 
-
   }
 
   function MoveCamera(timeStep) {
@@ -159,24 +166,25 @@ exports.component = function(self) {
     pitch = pitch + MOUSE_SENSITIVITY * mouseMoveY;
 
     if (pitch < -90)
-    pitch = -90;
+      pitch = -90;
 
     if (pitch > 90)
-    pitch = 90;
+      pitch = 90;
 
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode.rotation = QuatFromEuler(pitch, yaw, 0.0);
 
     var speed = MOVE_SPEED * timeStep;
 
+    //translate camera on the amount of speed value
     if (moveForward)
-    cameraNode.translate([0.0, 0.0, speed])
+      cameraNode.translate([0.0, 0.0, speed])
     if (moveBackwards)
-    cameraNode.translate([0.0, 0.0, -speed])
+      cameraNode.translate([0.0, 0.0, -speed])
     if (moveLeft)
-    cameraNode.translate([-speed, 0.0, 0.0])
+      cameraNode.translate([-speed, 0.0, 0.0])
     if (moveRight)
-    cameraNode.translate([speed, 0.0, 0.0])
+      cameraNode.translate([speed, 0.0, 0.0])
 
   }
 
@@ -198,61 +206,66 @@ exports.component = function(self) {
     // Mouse sensitivity as degrees per pixel
     var MOUSE_SENSITIVITY = 0.1;
 
+    //check input
     if (input.getKeyDown(Atomic.KEY_W))
-    moveForward = true;
+        moveForward = true;
     if (input.getKeyDown(Atomic.KEY_S))
-    moveBackwards = true;
+        moveBackwards = true;
     if (input.getKeyDown(Atomic.KEY_A))
-    moveLeft = true;
+        moveLeft = true;
     if (input.getKeyDown(Atomic.KEY_D))
-    moveRight = true;
+        moveRight = true;
 
     if (input.getKeyPress(Atomic.KEY_F))
-    button0 = true;
+        button0 = true;
     if (input.getKeyPress(Atomic.KEY_SPACE))
-    button1 = true;
+        button1 = true;
 
+    //update mouse coordinates
     mouseMoveX = input.getMouseMoveX();
     mouseMoveY = input.getMouseMoveY();
 
-
-
   }
 
   self.update = function(timeStep) {
 
     UpdateControls();
 
+    //if it's a free view
     if (cameraMode != 2) {
       yaw += mouseMoveX * YAW_SENSITIVITY;
       pitch += mouseMoveY * YAW_SENSITIVITY;
     }
 
     if (pitch < -80)
-    pitch = -80;
+      pitch = -80;
     if (pitch > 80)
-    pitch = 80;
+      pitch = 80;
 
     if (button0) {
       cameraMode++;
       if (cameraMode == 3)
-      cameraMode = 0;
+        cameraMode = 0;
     }
 
   }
 
+  //that function called right after update function
   self.postUpdate = function(timestep) {
 
     // Get camera lookat dir from character yaw + pitch
     var rot = node.getRotation();
 
+    //create quaternion
     dir = quat.create();
+    //set X value
     quat.setAxisAngle(dir, [1, 0, 0], (pitch * Math.PI / 180.0));
 
     quat.multiply(dir, [rot[1], rot[2], rot[3], rot[0]], dir);
 
     var headNode = node.getChild("Head_Tip", true);
 
+    //if it's a FPS view
     if (cameraMode == 1) {
 
       var headPos = headNode.getWorldPosition();
@@ -264,6 +277,7 @@ exports.component = function(self) {
       node.setRotation([dir[3], dir[0], dir[1], dir[2]]);
 
     }
+    //if it's a third person view
     if (cameraMode == 0) {
 
       var aimPoint = node.getWorldPosition();
@@ -283,9 +297,9 @@ exports.component = function(self) {
       node.setRotation([dir[3], dir[0], dir[1], dir[2]]);
 
     }
-    else
+    else{
       MoveCamera(timestep);
-
+    }
   }
 }
 
@@ -307,4 +321,3 @@ function QuatFromEuler(x, y, z) {
     q[3] = cosY * cosX * sinZ - sinY * sinX * cosZ;
     return q;
 }
-

+ 28 - 26
ToonTown/Resources/Components/LightFlicker.js

@@ -1,36 +1,38 @@
-// a flickering light component
+"atomic component"
 
-var node = self.node;
-self.light = node.getComponent("Light");
-var baseRange = 45;
-var targetValue = baseRange;
+// a flickering light component
+exports.component = function(self){
+  var node = self.node;
+  self.light = node.getComponent("Light");
+  var baseRange = 45;
+  var targetValue = baseRange;
 
-flicker = "mmmaaaammmaaaabcdefgabcdefg";
-var index = Math.random() * (flicker.length - 1);
+  //define a flicker pattern
+  var flicker = "mmmaaaammmaaaabcdefgabcdefg";
+  var index = Math.random() * (flicker.length - 1);
 
-// make sure first update catches
-time = 100;
+  // make sure first update catches
+  var time = 100;
 
-function update(timestep) {
+  self.update = function(timestep) {
 
-	time += timestep;
-	if (time > .05)
-	{
-		index++;
-		time = 0.0;
-		if (index >= flicker.length)
-			index = 0;
+    time += timestep;
+    if (time > .05)
+    {
+      index++;
+      time = 0.0;
+      if (index >= flicker.length)
+        index = 0;
 
-		targetValue = baseRange * (flicker.charCodeAt(index)/255);
-		
-	}
-		
-	if (self.light.range < targetValue)
-		self.light.range += timestep * 10;
+      targetValue = baseRange * (flicker.charCodeAt(index)/255);
 
-	if (self.light.range > targetValue)
-		self.light.range -= timestep * 10;
+    }
 
-}
+    if (self.light.range < targetValue)
+      self.light.range += timestep * 10;
 
+    if (self.light.range > targetValue)
+      self.light.range -= timestep * 10;
 
+  }
+}

+ 1 - 1
ToonTown/Resources/Components/LightFlicker.js.asset

@@ -2,6 +2,6 @@
 	"version": 1,
 	"guid": "e266b5b54ff6e1a6851dd7d18a182f63",
 	"JavascriptImporter": {
-		"IsComponentFile": false
+		"IsComponentFile": true
 	}
 }

+ 8 - 7
ToonTown/Resources/Components/RoboMan.js

@@ -1,19 +1,21 @@
 // designate component
 "atomic component";
 
+//A RoboMan component
 exports.component = function(self) {
-
+  //link to the current node
   var node = self.node;
 
+  //get Animation and Avatar controller components
   var animCtrl = node.getComponent("AnimationController");
   var controller = node.getJSComponent("AvatarController");
 
   var idle = true;
 
   self.start = function() {
-
+    //get main camera of the current scene
     var camera = node.scene.getMainCamera();
-
+    //if it exist
     if (camera) {
 
       camera.node.position = [0, 0, -10];
@@ -22,17 +24,16 @@ exports.component = function(self) {
     }
 
     animCtrl.playExclusive("Idle", 0, true, 0.0);
-
+    //rotate current node around Y axis
     node.yaw(180);
 
   }
 
-  // we need an update or it doesn't run the start, fix in JSVM
   self.update = function(timeStep) {
-
+    
+    //rotate current node around Y axis
     node.yaw(180);
 
-
     if (idle != controller.idle) {
 
       idle = controller.idle;

+ 38 - 45
ToonTown/Resources/Components/Scene.js

@@ -1,46 +1,39 @@
-var game = Atomic.game;
-var node = self.node;
-
-var time = 12;
-
-function start() {
-
-    var scene = game.scene;
-    
-    // Add light flickers
-    var lightNodes = scene.getChildrenWithComponent("Light", true);
-    for (var i = 0; i < lightNodes.length; i++) {
-        lightNodes[i].createJSComponent("LightFlicker");
-    }
-    
-    // create the procedural sky
-    var pnode = scene.createChild();
-    var procSky = self.procSky = pnode.createComponent("ProcSky");
-    
-    procSky.setDayTime(time);
-
-    // add the roboman
-
-    var spawnPoint = scene.getChild("PlayerInfoStart", true);
-
-    var roboman = node.createChild("TheRoboMan");
-    roboman.createJSComponent("RoboMan");
-    if (spawnPoint) {
-        roboman.position = spawnPoint.position;
-    }
-
-    var musicFile = game.cache.getResource("Sound", "Music/StoryTime.ogg");
-    musicFile.looped = true;
-    var musicNode = scene.createChild("MusicNode");
-    var musicSource = musicNode.createComponent("SoundSource");
-    musicSource.gain = .5;
-    musicSource.soundType = Atomic.SOUND_MUSIC;
-    musicSource.play(musicFile);
-
+"atomic component"
+
+//Define a Scene component
+exports.component = function(self) {
+  //we are attaching that component to the Scene, so we are sure that ours node is a scene
+  var scene = self.node;
+  var time = 12;
+
+  self.start = function() {
+
+      // Add light flickers
+      var lightNodes = scene.getChildrenWithComponent("Light", true);
+      for (var i = 0; i < lightNodes.length; i++) {
+          lightNodes[i].createJSComponent("Components/LightFlicker.js");
+      }
+
+      // create the procedural sky
+      var pnode = scene.createChild();
+      self.procSky = pnode.createComponent("ProcSky");
+      self.procSky.setDayTime(time);
+
+      //Create music
+      var musicFile = Atomic.cache.getResource("Sound", "Music/StoryTime.ogg");
+      //Set it looped
+      musicFile.looped = true;
+      var musicNode = scene.createChild("MusicNode");
+      var musicSource = musicNode.createComponent("SoundSource");
+      musicSource.gain = .5;
+      musicSource.soundType = Atomic.SOUND_MUSIC;
+      musicSource.play(musicFile);
+
+  }
+
+  self.update = function(timeStep) {
+
+      time += timeStep * .08;
+      self.procSky.setDayTime(time);
+  }
 }
-
-function update(timeStep) {
-
-    time += timeStep * .08;
-    self.procSky.setDayTime(time);
-}

+ 1 - 1
ToonTown/Resources/Components/Scene.js.asset

@@ -2,6 +2,6 @@
 	"version": 1,
 	"guid": "2cae69442197f1e4e86803956e71d730",
 	"JavascriptImporter": {
-		"IsComponentFile": false
+		"IsComponentFile": true
 	}
 }

+ 5 - 3
ToonTown/Resources/Components/TouchInput.js

@@ -1,15 +1,16 @@
 
 // Atomic Component
-
+//TODO: TOUCH INPUT
+/*
 var game = Atomic.game;
 var node = self.node;
 var input = game.input;
 
 function start() {
 
-	// input.setTouchEmulation(true);
+  // input.setTouchEmulation(true);
     var layout = game.cache.getResource("XMLFile", "Data/ScreenJoystick.xml");
-    var uiStyle = game.cache.getResource("XMLFile", "UI/DefaultStyle.xml");    
+    var uiStyle = game.cache.getResource("XMLFile", "UI/DefaultStyle.xml");
     input.addScreenJoystick(layout, uiStyle);
 
 }
@@ -17,3 +18,4 @@ function start() {
 function update(timeStep) {
 
 }
+*/

+ 0 - 5
ToonTown/Resources/Models/Materials.asset

@@ -1,5 +0,0 @@
-{
-	"version": 1,
-	"guid": "a5a438fed0475820a09dc00cc5e1394c",
-	"FolderImporter": {}
-}

+ 0 - 5
ToonTown/Resources/Prefabs.asset

@@ -1,5 +0,0 @@
-{
-	"version": 1,
-	"guid": "70e6273db6a2ed2b2335dc6342503d20",
-	"FolderImporter": {}
-}

+ 13 - 9
ToonTown/Resources/Scenes/ToonTown.scene

@@ -5,15 +5,18 @@
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Elapsed Time" value="0" />
-	<attribute name="Next Replicated Node ID" value="363" />
-	<attribute name="Next Replicated Component ID" value="1978" />
-	<attribute name="Next Local Node ID" value="16778752" />
-	<attribute name="Next Local Component ID" value="16777472" />
+	<attribute name="Next Replicated Node ID" value="365" />
+	<attribute name="Next Replicated Component ID" value="1981" />
+	<attribute name="Next Local Node ID" value="16779264" />
+	<attribute name="Next Local Component ID" value="16777984" />
 	<attribute name="Variables" />
 	<attribute name="Variable Names" value="" />
 	<component type="PhysicsWorld" id="1" />
 	<component type="Octree" id="2" />
 	<component type="DebugRenderer" id="3" />
+	<component type="JSComponent" id="1979">
+		<attribute name="ComponentFile" value="JSComponentFile;Components/Scene.js" />
+	</component>
 	<node id="2">
 		<attribute name="Is Enabled" value="true" />
 		<attribute name="Name" value="Zone" />
@@ -2093,7 +2096,7 @@
 				<attribute name="Offset Position" value="-0.0046978 -0.0166991 0.524431" />
 			</component>
 			<component type="RigidBody" id="229">
-				<attribute name="Physics Rotation" value="0.690346 -0.690346 0.153046 0.153046" />
+				<attribute name="Physics Rotation" value="0.690346 -0.690345 0.153046 0.153046" />
 				<attribute name="Physics Position" value="21.1301 26.1692 -38.3391" />
 				<attribute name="Collision Layer" value="2" />
 			</component>
@@ -2382,7 +2385,7 @@
 				<attribute name="Offset Position" value="1.44734e-08 2.94815e-07 1.83862" />
 			</component>
 			<component type="RigidBody" id="263">
-				<attribute name="Physics Rotation" value="0.690346 -0.690346 0.153046 0.153046" />
+				<attribute name="Physics Rotation" value="0.690346 -0.690345 0.153046 0.153046" />
 				<attribute name="Physics Position" value="24.1318 26.1692 -39.6341" />
 				<attribute name="Collision Layer" value="2" />
 			</component>
@@ -2404,7 +2407,7 @@
 				<attribute name="Offset Position" value="-1.44734e-08 1.18641e-06 1.83862" />
 			</component>
 			<component type="RigidBody" id="266">
-				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690346 0.690346" />
+				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690345 0.690346" />
 				<attribute name="Physics Position" value="26.417 26.1692 -29.326" />
 				<attribute name="Collision Layer" value="2" />
 			</component>
@@ -2426,7 +2429,7 @@
 				<attribute name="Offset Position" value="-1.87003e-07 1.71676e-07 1.04035" />
 			</component>
 			<component type="RigidBody" id="269">
-				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690346 0.690346" />
+				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690345 0.690346" />
 				<attribute name="Physics Position" value="29.1319 26.1692 -30.4572" />
 				<attribute name="Collision Layer" value="2" />
 			</component>
@@ -2470,7 +2473,7 @@
 				<attribute name="Offset Position" value="-1.29754e-07 0.0445475 0.956814" />
 			</component>
 			<component type="RigidBody" id="275">
-				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690346 0.690346" />
+				<attribute name="Physics Rotation" value="-0.153046 0.153046 0.690345 0.690346" />
 				<attribute name="Physics Position" value="23.901 26.1692 -28.0872" />
 				<attribute name="Collision Layer" value="2" />
 			</component>
@@ -6083,6 +6086,7 @@
 		<component type="AnimatedModel" id="1973">
 			<attribute name="Model" value="Model;Cache/e30fa79a0b75b75cbe5b03a73baa28a5.mdl" />
 			<attribute name="Material" value="Material;Roboman/Materials/Robot_01_mat.material" />
+			<attribute name="Cast Shadows" value="true" />
 			<attribute name="Bone Animation Enabled">
 				<variant type="Bool" value="true" />
 				<variant type="Bool" value="true" />

+ 2 - 9
ToonTown/Resources/Scripts/main.js

@@ -1,10 +1,3 @@
 // This script is the main entry point of the game
-
-var scene = Atomic.player.loadScene("Scenes/ToonTown.scene");
-
-// called per frame, optional
-function update(timeStep) {
-
-}
-
-exports.update = update;
+//Load scene
+Atomic.player.loadScene("Scenes/ToonTown.scene");