Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit

Permalink
Fixed crouch jumping & sliding
Browse files Browse the repository at this point in the history
Also added in mario.keys.left/right_down, as recommended by brycepauken
  • Loading branch information
Diogenesthecynic committed Oct 16, 2013
1 parent 90bfebb commit 9496a7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions things.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,9 @@ function moveMario(me) {
me.skidding = false;
}
}
// Otherwise slow down a bit, with a little more if crouching
// Otherwise slow down a bit/*, with a little more if crouching*/
else {
me.xvel *= (.98 - Boolean(me.crouching) * .07);
me.xvel *= (.98/* - Boolean(me.crouching) * .07*/);
decel = .035;
}

Expand Down
36 changes: 21 additions & 15 deletions triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,39 @@ function keydown(event) {
if(typeof(event) != "number" || event.which)
event = event.which;

var keys = mario.keys;
switch(event) {
case 37: case 65: // left
mario.keys.run = -1;
keys.run = -1;
keys.left_down = true; // independent of changes to mario.keys.run
break;

case 38: case 87: case 32: // up
mario.keys.up = true;
if(mario.canjump && !mario.crouching && (mario.resting || map.underwater)) {
mario.keys.jump = 1;
mario.canjump = mario.keys.jumplev = 0;
keys.up = true;
if(mario.canjump &&/* !mario.crouching &&*/ (mario.resting || map.underwater)) {
keys.jump = 1;
mario.canjump = keys.jumplev = 0;
// To do: can mario make a jumping sound during the spring?
if(mario.power > 1) play("Jump Super.wav");
else play("Jump Small.wav");
if(map.underwater) setTimeout(function() {
mario.jumping = mario.keys.jump = false;
mario.jumping = keys.jump = false;
}, timer * 14);
}
break;

case 39: case 68: // right
mario.keys.run = 1;
keys.run = 1;
keys.right_down = true; // independent of changes to mario.keys.run
break;

case 40: case 83: // down
mario.keys.crouch = 1;
keys.crouch = 1;
break;

case 16: // sprint
if(mario.power == 3 && mario.keys.sprint == 0) mario.fire();
mario.keys.sprint = 1;
if(mario.power == 3 && keys.sprint == 0) mario.fire();
keys.sprint = 1;
break;

case 80: // pause
Expand Down Expand Up @@ -92,27 +95,30 @@ function keyup(event) {
if(typeof(event) != "number" || event.which)
event = event.which;

var keys = mario.keys;
switch(event) {
case 37: case 65: // left
mario.keys.run = 0;
keys.run = 0;
keys.left_down = false; // independent of changes to mario.keys.run
break;

case 38: case 87: case 32: // up
if(!map.underwater) mario.keys.jump = mario.keys.up = 0;
if(!map.underwater) keys.jump = keys.up = 0;
mario.canjump = true;
break;

case 39: case 68: // right
mario.keys.run = 0;
keys.run = 0;
keys.left_down = false; // independent of changes to mario.keys.run
break;

case 40: case 83: // down
mario.keys.crouch = 0;
keys.crouch = 0;
removeCrouch();
break;

case 16: // sprint
mario.keys.sprint = 0;
keys.sprint = 0;
break;

case 80: // paused
Expand Down

0 comments on commit 9496a7f

Please sign in to comment.