Hold E and rock button to place rocks fast

This commit is contained in:
RedEnchilada 2016-05-09 23:49:20 -05:00
parent c27116a75e
commit d9bef1eeb3
2 changed files with 12 additions and 3 deletions

View file

@ -459,13 +459,13 @@ Level = function(levelName) {
Input.held("greenkey") ? "green" :
Input.held("yellowkey") ? "yellow" : "white";
if (Input.pressed("rocksm")) {
if (pressOrTurbo("rocksm")) {
spawnRock("small");
}
if (Input.pressed("rockmed")) {
if (pressOrTurbo("rockmed")) {
spawnRock("medium");
}
if (Input.pressed("rocklg")) {
if (pressOrTurbo("rocklg")) {
spawnRock("large");
}
@ -530,6 +530,10 @@ Level = function(levelName) {
dolphin.momentum.x = Math.cos(dolphin.activeSprite.rotation)*2;
dolphin.momentum.y = Math.sin(dolphin.activeSprite.rotation)*2;
}
if (Input.held("fast")) {
dolphin.momentum.x = Math.cos(dolphin.activeSprite.rotation)*8;
dolphin.momentum.y = Math.sin(dolphin.activeSprite.rotation)*8;
}
if (Input.pressed("export")) {
level.map.spawn = {
@ -540,6 +544,10 @@ Level = function(levelName) {
LEVELEDITORBOX.innerText = JSON.stringify(level.map);
}
function pressOrTurbo(key) {
return Input.pressed(key) || (Input.held("fast") && Input.held(key) && !(level.ticCount % 4));
}
}
return level;

View file

@ -32,6 +32,7 @@ Input = (function() {
greenkey: 66+5, // G
yellowkey: 83+6, // Y
slow: 81, // Q
fast: 69, // E
};
Input.setControl = function(control, key) {