Josh Engebretson 11 years ago
parent
commit
e4c6b76635

+ 14 - 2
PhysicsPlatformer/Resources/Components/Avatar.js

@@ -14,7 +14,7 @@ sprite.setAnimation(animationSet, "Idle");
 sprite.setLayer(100);
 
 var light = node.createComponent("PointLight2D");
-light.color = [1, 1, 1, .55];
+light.color = [1, 1, 1, .75];
 light.softShadowLength = 20;
 light.radius = 20;
 light.castShadows = true;
@@ -154,6 +154,18 @@ function handleInput(timeStep) {
     var jump = input.getKeyDown(Atomic.KEY_SPACE);
     var zoomIn = input.getKeyDown(Atomic.KEY_W);
     var zoomOut = input.getKeyDown(Atomic.KEY_S);
+    
+    if (daytime) 
+    {
+        var sunleft = input.getKeyDown(Atomic.KEY_Q);
+        var sunright = input.getKeyDown(Atomic.KEY_E);    
+        
+        if (sunleft)
+            TheSun.direction += timeStep * 100;
+        if (sunright)
+            TheSun.direction -= timeStep * 100;
+    }
+
 
     if (input.getNumJoysticks()) {
         var state = GetGamepadState(0);
@@ -208,7 +220,7 @@ function handleInput(timeStep) {
     if (jump && jumpDelta <= 0 && contactCount) {
 
         jumpDelta = .25;
-        self.soundSource.gain = 0.75;
+        self.soundSource.gain = 0.45;
         self.soundSource.play(jumpSound);
 
         vel[1] = 0;

+ 18 - 17
PhysicsPlatformer/Resources/Components/Coin.js

@@ -9,15 +9,19 @@ var node = self.node;
 
 // Resources
 var animationSet = cache.getResource("AnimationSet2D", "Sprites/GoldIcon.scml");
-var coinSound = cache.getResource("Sound","Sounds/Pickup_Coin8.ogg");
-var coinBounceSound = cache.getResource("Sound","Sounds/Coin_Bounce.ogg");
+var coinSound = cache.getResource("Sound", "Sounds/Pickup_Coin8.ogg");
+var coinBounceSound = cache.getResource("Sound", "Sounds/Coin_Bounce.ogg");
 
 var sprite = node.createComponent("AnimatedSprite2D");
 sprite.setAnimation(animationSet, "idle");
 sprite.setLayer(100);
 
 var light = node.createComponent("PointLight2D");
-light.color = [1, 1, .56, .8];
+if (daytime)
+    light.color = [1, 1, .56, .4];
+else
+    light.color = [1, 1, .56, .8];
+
 light.radius = .85;
 lightGroup.addLight(light);
 
@@ -28,30 +32,27 @@ var body;
 function onPlayerHit() {
 
     //ThePlayer.light.enabled = false;
-    
+
     // sprite enabled is not removing the sprite
     light.enabled = false;
     node.scale2D = [0, 0];
     sprite.enabled = false;
-    body.enabled = false;    
+    body.enabled = false;
     self.soundSource.gain = 1.0;
-    self.soundSource.play(coinSound );
-    
+    self.soundSource.play(coinSound);
+
 }
 
 self.onPhysicsBeginContact2D = function(world, bodyA, bodyB, nodeA, nodeB) {
 
     if (nodeA == ThePlayer.node && nodeB == node) {
         onPlayerHit();
-    }
-    else if (nodeB == node)
-    {
+    } else if (nodeB == node) {
         var vel = body.linearVelocity;
-        if (vec2.length(vel) > 3)
-        {
-            self.soundSource.gain = .4;
+        if (vec2.length(vel) > 3) {
+            self.soundSource.gain = .3;
             self.soundSource.play(coinBounceSound);
-       }
+        }
     }
 
 }
@@ -61,10 +62,10 @@ function start() {
 
     self.soundSource = node.createComponent("SoundSource");
     self.soundSource.soundType = Atomic.SOUND_EFFECT;
-    
+
     // would just like to listen to body collisions here
     self.listenToEvent(null, "PhysicsBeginContact2D", self.onPhysicsBeginContact2D);
-    
+
 
 }
 
@@ -82,7 +83,7 @@ function update(timeStep) {
         body.castShadows = false;
 
         var circle = node.createComponent("CollisionCircle2D");
-                
+
         // Set radius
         circle.setRadius(.3);
         // Set density

+ 1 - 1
PhysicsPlatformer/Resources/Components/UI.js

@@ -33,7 +33,7 @@ function start() {
     scoreText.horizontalAlignment = Atomic.HA_LEFT;
     scoreText.verticalAlignment = Atomic.VA_TOP;
 
-    gameui.addChild(scoreText);
+    //gameui.addChild(scoreText);
 
     var heartContainer = new Atomic.UIElement();
     heartContainer.setPosition(-16, 48);

+ 3 - 5
PhysicsPlatformer/Resources/PhysicsPlatformer.js

@@ -32,7 +32,7 @@ function Update() {
 
 function CreateScene() {
 
-    daytime = true;
+    daytime = false;
 
     scene = new Atomic.Scene();
     scene.createComponent("Octree");
@@ -57,9 +57,9 @@ function CreateScene() {
     lightGroup = lightGroupNode.createComponent("Light2DGroup");
     lightGroup.setPhysicsWorld(physicsWorld);
     if (daytime)
-        lightGroup.ambientColor = [1, 1, 1, .9];
+        lightGroup.ambientColor = [1, 1, 1, 1];
     else
-        lightGroup.ambientColor = [.8, .8, .8, .5];
+        lightGroup.ambientColor = [.8, .8, .8, .25];
     
     
     if (daytime)
@@ -67,8 +67,6 @@ function CreateScene() {
         TheSun = scene.createComponent("DirectionalLight2D");
         TheSun.color = [1, 1, 1, 0.15];
         TheSun.castShadows = true;
-        TheSun.softShadows = true;
-        TheSun.softShadowLength = 20;
         TheSun.numRays = 1024;
         TheSun.backtrace = false;        
         lightGroup.addLight(TheSun);