Skip to content

Commit

Permalink
Merge pull request #1 from Marauderer97/key-control
Browse files Browse the repository at this point in the history
Fixes fossasia#253 Adds Keyboard Control and updates the how-to-play svg
  • Loading branch information
Marauderer97 authored Jan 13, 2017
2 parents 1b29b05 + 15ec816 commit 3c402b5
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions javascript/start.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Execute everything that should be started.
// This script must be the last script. Otherwise not all functions may be loaded.


var characters;
var backgrounds;

window.onload = function() {
scaleToFullscreen();
showStartScreen();

var characters = ["bird", "bat", "alien","flappydino","helicopter", "rocket","Santa", "Super_rocket", "Flappyfish", "unicorn", "botty", "black_cat","ball","octodex", "grandma","dog"];
var backgrounds=["background","Gotham","space","Snow", "Sea", "Island", "binarybg","Evil"];
characters = ["bird", "bat", "alien","flappydino","helicopter", "rocket","Santa", "Super_rocket", "Flappyfish", "unicorn", "botty", "black_cat","ball","octodex", "grandma","dog"];
backgrounds=["background","Gotham","space","Snow", "Sea", "Island", "binarybg","Evil"];

rand=Math.floor((Math.random() * (backgrounds.length)));
backgroundChange(backgrounds[rand])
Expand All @@ -17,3 +18,31 @@ window.onload = function() {
characterChange(characters[rand])

}
i=0;
j=0;
window.onkeydown = function(event){
switch(event.keyCode){
case 32:
var layer=characters[i];
console.log(characters[i]);
characterChange(layer);
i=(i+1)%(characters.length);
break;
case 66:
var layer=backgrounds[j];
console.log(backgrounds[j]);
backgroundChange(layer);
j=(j+1)%(backgrounds.length);
break;
case 13:
startGame();
break;
case 82:
restartGame();
break;
default:
console.log("enterred");
break;
}
return false;
}

0 comments on commit 3c402b5

Please sign in to comment.