Browse Source

In this update i have made the arrow keys useable ;)

David Mortensen 10 years ago
parent
commit
67ff098d07

+ 24 - 12
RobomanPlatformer/Resources/Components/AvatarController.js

@@ -40,7 +40,7 @@ var button1 = false;
 var lastButton0 = false;
 var lastButton1 = false;
 
-var timer = 0.85;
+var timer = 0.79;
 var fallTimer = 1.5;
 
 self.idle = true;
@@ -201,54 +201,63 @@ function UpdateControls() {
     // Mouse sensitivity as degrees per pixel
     var MOUSE_SENSITIVITY = 0.1;
 
-    if (input.getKeyDown(Atomic.KEY_W)) {
+    // We set the default movement keys here
+    if (input.getKeyDown(Atomic.KEY_W) || input.getKeyDown(Atomic.KEY_UP)) {
         yaw = 0;
         moveForward = true;
     }
-    if (input.getKeyDown(Atomic.KEY_S)) {
+    if (input.getKeyDown(Atomic.KEY_S) || input.getKeyDown(Atomic.KEY_DOWN)) {
         yaw = 180;
         moveBackwards = true;
     }
-    if (input.getKeyDown(Atomic.KEY_A)) {
+    if (input.getKeyDown(Atomic.KEY_A) || input.getKeyDown(Atomic.KEY_LEFT)) {
         yaw = -90;
         moveLeft = true;
     }
-    if (input.getKeyDown(Atomic.KEY_D)) {
+    if (input.getKeyDown(Atomic.KEY_D) || input.getKeyDown(Atomic.KEY_RIGHT)) {
         yaw = 90;
         moveRight = true;
     }
+    
+    // This is the key for changing camera modes
     if (input.getKeyPress(Atomic.KEY_F)) {
         button1 = true;
     }
+    // This is the key for jumping
     if (input.getKeyDown(Atomic.KEY_SPACE)) {
         button0 = true;
     }
 
-    if (input.getKeyDown(Atomic.KEY_W) && input.getKeyDown(Atomic.KEY_A)) {
+    // Here we set the angled directions
+    if (input.getKeyDown(Atomic.KEY_W) && input.getKeyDown(Atomic.KEY_A) || input.getKeyDown(Atomic.KEY_UP) && input.getKeyDown(Atomic.KEY_LEFT)) {
         yaw = -45;
     }
-    if (input.getKeyDown(Atomic.KEY_W) && input.getKeyDown(Atomic.KEY_D)) {
+    if (input.getKeyDown(Atomic.KEY_W) && input.getKeyDown(Atomic.KEY_D) || input.getKeyDown(Atomic.KEY_UP) && input.getKeyDown(Atomic.KEY_RIGHT)) {
         yaw = 45;
     }
-    if (input.getKeyDown(Atomic.KEY_S) && input.getKeyDown(Atomic.KEY_A)) {
+    if (input.getKeyDown(Atomic.KEY_S) && input.getKeyDown(Atomic.KEY_A) || input.getKeyDown(Atomic.KEY_DOWN) && input.getKeyDown(Atomic.KEY_LEFT)) {
         yaw = -135;
     }
-    if (input.getKeyDown(Atomic.KEY_S) && input.getKeyDown(Atomic.KEY_D)) {
+    if (input.getKeyDown(Atomic.KEY_S) && input.getKeyDown(Atomic.KEY_D) || input.getKeyDown(Atomic.KEY_DOWN) && input.getKeyDown(Atomic.KEY_RIGHT)) {
         yaw = 135;
     }
 
-    if (input.getKeyDown(Atomic.KEY_W) || input.getKeyDown(Atomic.KEY_S) || input.getKeyDown(Atomic.KEY_A) || input.getKeyDown(Atomic.KEY_D)) {
+    // Here we define if a default move key is pressed, it should animate RoboMan
+    if (input.getKeyDown(Atomic.KEY_W) || input.getKeyDown(Atomic.KEY_S) || input.getKeyDown(Atomic.KEY_A) || input.getKeyDown(Atomic.KEY_D) || input.getKeyDown(Atomic.KEY_UP) || input.getKeyDown(Atomic.KEY_DOWN) || input.getKeyDown(Atomic.KEY_LEFT) || input.getKeyDown(Atomic.KEY_RIGHT)) {
+        // If RoboMan is NOT jumping we want to play walk animation
         if (!self.jump)
         {
             self.walk = true;
             self.run = false;
             
+            // If we're not holding the run button down, we want the move force to be normal and walk animation to play
             if (!input.getKeyDown(Atomic.KEY_LSHIFT))
             {
                 MOVE_FORCE = 64.8;
                 self.walk = true;
                 self.run = false;
             }
+            // Else if we ARE holding the run button down WHILE pressing a move key, then we want RoboMan to play the run animation
             else
             {
                 MOVE_FORCE = 129.6;
@@ -256,6 +265,7 @@ function UpdateControls() {
                 self.run = true;
             }
         }
+        // Else if we are jumping, we don't want to play either the run or walk animations
         else
         {
             self.walk = false;
@@ -275,6 +285,7 @@ function UpdateControls() {
             }
         }
     }
+    // If we're not pressing a move key we normally want to play the idle animation on RoboMan
     else
     {
         if (!self.jump)
@@ -288,6 +299,7 @@ function UpdateControls() {
                 self.idle = true;
             }
         }
+        // Here we want to play the jump animation even though we're only moving in the Y axis!
         else
         {
             self.idle = false;
@@ -321,8 +333,8 @@ function update(timeStep) {
         okToJump = true;
         isGrounded = true;
         onGround = true;
-        timer = 0.85;
-    } else if (timer < 0.75 && timer > 0.1) {
+        timer = 0.79;
+    } else if (timer < 0.69 && timer > 0.1) {
         okToJump = false;
     }
 

+ 1 - 2
RobomanPlatformer/Resources/Components/RoboMan.js

@@ -24,8 +24,7 @@ function start() {
     animCtrl.playExclusive("Models/RoboMan_Normal_Idle.ani", 0, true, 0.0);
 
     game.cameraNode.position = [0, 5.5, -10];
-    game.cameraNode.pitch(20);
-
+    
 }
 
 // we need an update or it doesn't run the start, fix in JSVM

+ 4 - 5
RobomanPlatformer/Resources/Components/Scene.js

@@ -20,9 +20,9 @@ function start() {
     var zone = zoneNode.createComponent("Zone");
     zone.boundingBox = [-1000, -1000, -1000, 1000, 1000, 1000];
     zone.ambientColor = [0.15, 0.15, 0.15];
-    zone.fogColor = [0.5, 0.5, 0.7, 1.0];
-    zone.fogStart = 10;
-    zone.fogEnd = 100;
+    zone.fogColor = [0.6, 0.6, 0.85, 1.0];
+    //zone.fogStart = 10;
+    //zone.fogEnd = 100;
 
     var lightNode = scene.createChild("Directional Light");
     lightNode.direction = [0.6, -1.0, 0.8];
@@ -33,14 +33,13 @@ function start() {
 
     // If we're running on android tweak the shadows
     if (Atomic.platform == "Android") {
-
         light.setShadowCascade(20.0, 50.0, 200.0, 0.0, 0.9);
         light.shadowIntensity = 0.33;
     } else {
         light.setShadowCascade(10.0, 50.0, 200.0, 0.0, 0.8);
     }
 
-    light.setShadowBias(0.00025, 0.5);
+    light.setShadowBias(0.0003, 0.5);
     light.specularIntensity = 8;
 
     // add the roboman

+ 1 - 1
RobomanPlatformer/Resources/Data/ScreenJoystick.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <element inherit="UI/ScreenJoystick.xml">
     <replace sel="/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value">Jump</replace>
-    <add sel="/element/element[./attribute[@name='Name' and @value='Jump']]">
+    <add sel="/element/element[./attribute[@name='Name' and @value='Button0']]">
         <attribute name="Is Visible" value="true" />
         <element type="Text">
         <attribute name="Name" value="KeyBinding" />

+ 41 - 0
RobomanPlatformer/Roboman Platformer.atomic

@@ -0,0 +1,41 @@
+{
+    "version": 1,
+    "build_settings": {
+        "version": 1,
+        "android": {
+            "app_name": "RoboManPlatformer2",
+            "package": "com.DavidMortensen.RoboManPlatformer2",
+            "target_sdk_version": "android-19",
+            "min_sdk_version": "",
+            "activity_name": "",
+            "company_name": "David Mortensen",
+            "product_name": "RoboMan Platformer 2"
+        },
+        "ios": {
+            "app_name": "",
+            "package": "",
+            "provision_file": "",
+            "company_name": "",
+            "product_name": "",
+            "appid_prefix": ""
+        },
+        "mac": {
+            "app_name": "",
+            "package": "",
+            "company_name": "",
+            "product_name": ""
+        },
+        "windows": {
+            "app_name": "",
+            "package": "",
+            "company_name": "",
+            "product_name": ""
+        },
+        "webgl": {
+            "app_name": "",
+            "package": "",
+            "company_name": "",
+            "product_name": ""
+        }
+    }
+}