From 7b1cb4e9863c4567cdf8a6ffa59145436de5b52a Mon Sep 17 00:00:00 2001 From: Ryan Rule-Hoffman Date: Thu, 17 Sep 2015 22:41:43 -0400 Subject: [PATCH] Fixed issue so you can now use the up arrow for jumping and the shift key for running. --- Enjine/keyboardInput.js | 3 ++- code/character.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Enjine/keyboardInput.js b/Enjine/keyboardInput.js index 8205a53..e4aad52 100755 --- a/Enjine/keyboardInput.js +++ b/Enjine/keyboardInput.js @@ -33,7 +33,8 @@ Enjine.Keys = { Left: 37, Up: 38, Right: 39, - Down: 40 + Down: 40, + Shift: 16 }; Enjine.KeyboardInput = { diff --git a/code/character.js b/code/character.js index 853c771..2e1b9c3 100755 --- a/code/character.js +++ b/code/character.js @@ -173,7 +173,7 @@ Mario.Character.prototype.Move = function() { this.Visible = (((this.InvulerableTime / 2) | 0) & 1) === 0; this.WasOnGround = this.OnGround; - var sideWaysSpeed = Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) ? 1.2 : 0.6; + var sideWaysSpeed = (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) ) ? 1.2 : 0.6; if (this.OnGround) { if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Down) && this.Large) { @@ -190,7 +190,7 @@ Mario.Character.prototype.Move = function() { this.Facing = -1; } - if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S) || (this.JumpTime < 0 && !this.OnGround && !this.Sliding)) { + if ((Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Up)) || (this.JumpTime < 0 && !this.OnGround && !this.Sliding)) { if (this.JumpTime < 0) { this.Xa = this.XJumpSpeed; this.Ya = -this.JumpTime * this.YJumpSpeed; @@ -246,13 +246,13 @@ Mario.Character.prototype.Move = function() { this.Sliding = false; } - if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) && this.CanShoot && this.Fire && this.World.FireballsOnScreen < 2) { + if ((Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) ) && this.CanShoot && this.Fire && this.World.FireballsOnScreen < 2) { Enjine.Resources.PlaySound("fireball"); this.World.AddSprite(new Mario.Fireball(this.World, this.X + this.Facing * 6, this.Y - 20, this.Facing)); } - this.CanShoot = !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A); - this.MayJump = (this.OnGround || this.Sliding) && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S); + this.CanShoot = !(Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) ); + this.MayJump = (this.OnGround || this.Sliding) && !(Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Up)); this.XFlip = (this.Facing === -1); this.RunTime += Math.abs(this.Xa) + 5; @@ -304,7 +304,7 @@ Mario.Character.prototype.Move = function() { if (this.Carried !== null) { this.Carried.X *= this.X + this.Facing * 8; this.Carried.Y *= this.Y - 2; - if (!Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A)) { + if (!(Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) )) { this.Carried.Release(this); this.Carried = null; } @@ -544,7 +544,7 @@ Mario.Character.prototype.Stomp = function(object) { this.Sliding = false; this.InvulnerableTime = 1; } else if (object instanceof Mario.Shell) { - if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) && object.Facing === 0) { + if ((Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) ) && object.Facing === 0) { this.Carried = object; object.Carried = true; } else { @@ -637,7 +637,7 @@ Mario.Character.prototype.Kick = function(shell) { return; } - if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A)) { + if ((Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) || Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Shift) )) { this.Carried = shell; shell.Carried = true; } else {