Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // vars
- var G, A, state, colstate
- // motion vectors
- var yPos = 0;
- var xPos = 0;
- var xVel = 0;
- var yVel = 0;
- //max velocity
- var mv = 10
- // check tile switch
- var checkx1 = true;
- var checky1 = true;
- var checkx2 = true;
- var checky2 = true;
- var checkx3 = true;
- var checky3 = true;
- var checkx4 = true;
- var checky4 = true;
- // tile array
- var tile1, tile2, tile3, tile4, tilex1, tiley1, tilex2, tiley2, tilex3, tiley3, tilex4, tiley4
- // ping
- var p = "PING"
- // Key
- var key = {};
- // Key input - Key[KEYCODE] == true/false
- window.onkeyup = function(e) { key[e.keyCode] = false; }
- window.onkeydown = function(e) { key[e.keyCode] = true; }
- // right ground acceleration
- function speedupx0() {
- xVel = xVel + 1;
- }
- // right air acceleration
- function speedupx1() {
- xVel = xVel + 0.75;
- }
- // left ground acceleration
- function speedupx2() {
- xVel = xVel - 1;
- }
- // left air acceleration
- function speedupx3() {
- xVel = xVel - 0.75;
- }
- function checkxt1() {
- if (checkx1 == true) {
- if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 1) {
- tilex1 = "1";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 2) {
- tilex1 = "2";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 3) {
- tilex1 = "3";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 4) {
- tilex1 = "4";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 5) {
- tilex1 = "5";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 6) {
- tilex1 = "6";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 7) {
- tilex1 = "7";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 8) {
- tilex1 = "8";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 9) {
- tilex1 = "9";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 10) {
- tilex1 = "10";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 11) {
- tilex1 = "11";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 12) {
- tilex1 = "12";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 13) {
- tilex1 = "13";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 14) {
- tilex1 = "14";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 15) {
- tilex1 = "15";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 16) {
- tilex1 = "16";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 17) {
- tilex1 = "17";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 18) {
- tilex1 = "18";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 19) {
- tilex1 = "19";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 20) {
- tilex1 = "20";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 21) {
- tilex1 = "21";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 22) {
- tilex1 = "22";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 23) {
- tilex1 = "23";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 24) {
- tilex1 = "24";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 25) {
- tilex1 = "25";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 26) {
- tilex1 = "26";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 27) {
- tilex1 = "27";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 28) {
- tilex1 = "28";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 29) {
- tilex1 = "29";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 30) {
- tilex1 = "30";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 31) {
- tilex1 = "31";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 32) {
- tilex1 = "32";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 33) {
- tilex1 = "33";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 34) {
- tilex1 = "34";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 35) {
- tilex1 = "35";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 36) {
- tilex1 = "36";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 37) {
- tilex1 = "37";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 38) {
- tilex1 = "38";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 39) {
- tilex1 = "39";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 40) {
- tilex1 = "40";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 41) {
- tilex1 = "41";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 42) {
- tilex1 = "42";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 43) {
- tilex1 = "43";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 44) {
- tilex1 = "44";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 45) {
- tilex1 = "45";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 46) {
- tilex1 = "46";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 47) {
- tilex1 = "47";
- } else if (xPos + (innerWidth * 0.0365625) <= innerWidth) {
- tilex1 = "48";
- };
- };
- };
- function checkyt1() {
- if (checky1 == true) {
- if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 1) {
- tiley1 = "A";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 2) {
- tiley1 = "B";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 3) {
- tiley1 = "C";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 4) {
- tiley1 = "D";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 5) {
- tiley1 = "E";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 6) {
- tiley1 = "F";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 7) {
- tiley1 = "G";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 8) {
- tiley1 = "H";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 9) {
- tiley1 = "I";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 10) {
- tiley1 = "J";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 11) {
- tiley1 = "K";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 12) {
- tiley1 = "L";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 13) {
- tiley1 = "M";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 14) {
- tiley1 = "N";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 15) {
- tiley1 = "O";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 16) {
- tiley1 = "P";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 17) {
- tiley1 = "Q";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 18) {
- tiley1 = "R";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 19) {
- tiley1 = "S";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 20) {
- tiley1 = "T";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 21) {
- tiley1 = "U";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 22) {
- tiley1 = "V";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 23) {
- tiley1 = "W";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 24) {
- tiley1 = "X";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 25) {
- tiley1 = "Y";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 26) {
- tiley1 = "Z";
- } else if (yPos + (innerHeight * 0.065) <= innerHeight / 27) {
- tiley1 = "0";
- };
- };
- };
- function checkxt2() {
- if (checkx2 == true) {
- if (xPos <= (innerWidth / 48) * 1) {
- tilex2 = "1";
- } else if (xPos <= (innerWidth / 48) * 2) {
- tilex2 = "2";
- } else if (xPos <= (innerWidth / 48) * 3) {
- tilex2 = "3";
- } else if (xPos <= (innerWidth / 48) * 4) {
- tilex2 = "4";
- } else if (xPos <= (innerWidth / 48) * 5) {
- tilex2 = "5";
- } else if (xPos <= (innerWidth / 48) * 6) {
- tilex2 = "6";
- } else if (xPos <= (innerWidth / 48) * 7) {
- tilex2 = "7";
- } else if (xPos <= (innerWidth / 48) * 8) {
- tilex2 = "8";
- } else if (xPos <= (innerWidth / 48) * 9) {
- tilex2 = "9";
- } else if (xPos <= (innerWidth / 48) * 10) {
- tilex2 = "10";
- } else if (xPos <= (innerWidth / 48) * 11) {
- tilex2 = "11";
- } else if (xPos <= (innerWidth / 48) * 12) {
- tilex2 = "12";
- } else if (xPos <= (innerWidth / 48) * 13) {
- tilex2 = "13";
- } else if (xPos <= (innerWidth / 48) * 14) {
- tilex2 = "14";
- } else if (xPos <= (innerWidth / 48) * 15) {
- tilex2 = "15";
- } else if (xPos <= (innerWidth / 48) * 16) {
- tilex2 = "16";
- } else if (xPos <= (innerWidth / 48) * 17) {
- tilex2 = "17";
- } else if (xPos <= (innerWidth / 48) * 18) {
- tilex2 = "18";
- } else if (xPos <= (innerWidth / 48) * 19) {
- tilex2 = "19";
- } else if (xPos <= (innerWidth / 48) * 20) {
- tilex2 = "20";
- } else if (xPos <= (innerWidth / 48) * 21) {
- tilex2 = "21";
- } else if (xPos <= (innerWidth / 48) * 22) {
- tilex2 = "22";
- } else if (xPos <= (innerWidth / 48) * 23) {
- tilex2 = "23";
- } else if (xPos <= (innerWidth / 48) * 24) {
- tilex2 = "24";
- } else if (xPos <= (innerWidth / 48) * 25) {
- tilex2 = "25";
- } else if (xPos <= (innerWidth / 48) * 26) {
- tilex2 = "26";
- } else if (xPos <= (innerWidth / 48) * 27) {
- tilex2 = "27";
- } else if (xPos <= (innerWidth / 48) * 28) {
- tilex2 = "28";
- } else if (xPos <= (innerWidth / 48) * 29) {
- tilex2 = "29";
- } else if (xPos <= (innerWidth / 48) * 30) {
- tilex2 = "30";
- } else if (xPos <= (innerWidth / 48) * 31) {
- tilex2 = "31";
- } else if (xPos <= (innerWidth / 48) * 32) {
- tilex2 = "32";
- } else if (xPos <= (innerWidth / 48) * 33) {
- tilex2 = "33";
- } else if (xPos <= (innerWidth / 48) * 34) {
- tilex2 = "34";
- } else if (xPos <= (innerWidth / 48) * 35) {
- tilex2 = "35";
- } else if (xPos <= (innerWidth / 48) * 36) {
- tilex2 = "36";
- } else if (xPos <= (innerWidth / 48) * 37) {
- tilex2 = "37";
- } else if (xPos <= (innerWidth / 48) * 38) {
- tilex2 = "38";
- } else if (xPos <= (innerWidth / 48) * 39) {
- tilex2 = "39";
- } else if (xPos <= (innerWidth / 48) * 40) {
- tilex2 = "40";
- } else if (xPos <= (innerWidth / 48) * 41) {
- tilex2 = "41";
- } else if (xPos <= (innerWidth / 48) * 42) {
- tilex2 = "42";
- } else if (xPos <= (innerWidth / 48) * 43) {
- tilex2 = "43";
- } else if (xPos <= (innerWidth / 48) * 44) {
- tilex2 = "44";
- } else if (xPos <= (innerWidth / 48) * 45) {
- tilex2 = "45";
- } else if (xPos <= (innerWidth / 48) * 46) {
- tilex2 = "46";
- } else if (xPos <= (innerWidth / 48) * 47) {
- tilex2 = "47";
- } else if (xPos <= innerWidth) {
- tilex2 = "48";
- };
- };
- };
- function checkyt2() {
- if (checky2 == true) {
- if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 1) {
- tiley2 = "A";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 2) {
- tiley2 = "B";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 3) {
- tiley2 = "C";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 4) {
- tiley2 = "D";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 5) {
- tiley2 = "E";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 6) {
- tiley2 = "F";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 7) {
- tiley2 = "G";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 8) {
- tiley2 = "H";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 9) {
- tiley2 = "I";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 10) {
- tiley2 = "J";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 11) {
- tiley2 = "K";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 12) {
- tiley2 = "L";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 13) {
- tiley2 = "M";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 14) {
- tiley2 = "N";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 15) {
- tiley2 = "O";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 16) {
- tiley2 = "P";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 17) {
- tiley2 = "Q";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 18) {
- tiley2 = "R";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 19) {
- tiley2 = "S";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 20) {
- tiley2 = "T";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 21) {
- tiley2 = "U";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 22) {
- tiley2 = "V";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 23) {
- tiley2 = "W";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 24) {
- tiley2 = "X";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 25) {
- tiley2 = "Y";
- } else if (yPos + (innerHeight * 0.065) <= (innerHeight / 27) * 26) {
- tiley2 = "Z";
- } else if (yPos + (innerHeight * 0.065) <= innerHeight / 27) {
- tiley1 = "0";
- };
- };
- };
- function checkxt3() {
- if (checkx3 == true) {
- if (xPos <= (innerWidth / 48) * 1) {
- tilex3 = "1";
- } else if (xPos <= (innerWidth / 48) * 2) {
- tilex3 = "2";
- } else if (xPos <= (innerWidth / 48) * 3) {
- tilex3 = "3";
- } else if (xPos <= (innerWidth / 48) * 4) {
- tilex3 = "4";
- } else if (xPos <= (innerWidth / 48) * 5) {
- tilex3 = "5";
- } else if (xPos <= (innerWidth / 48) * 6) {
- tilex3 = "6";
- } else if (xPos <= (innerWidth / 48) * 7) {
- tilex3 = "7";
- } else if (xPos <= (innerWidth / 48) * 8) {
- tilex3 = "8";
- } else if (xPos <= (innerWidth / 48) * 9) {
- tilex3 = "9";
- } else if (xPos <= (innerWidth / 48) * 10) {
- tilex3 = "10";
- } else if (xPos <= (innerWidth / 48) * 11) {
- tilex3 = "11";
- } else if (xPos <= (innerWidth / 48) * 12) {
- tilex3 = "12";
- } else if (xPos <= (innerWidth / 48) * 13) {
- tilex3 = "13";
- } else if (xPos <= (innerWidth / 48) * 14) {
- tilex3 = "14";
- } else if (xPos <= (innerWidth / 48) * 15) {
- tilex3 = "15";
- } else if (xPos <= (innerWidth / 48) * 16) {
- tilex3 = "16";
- } else if (xPos <= (innerWidth / 48) * 17) {
- tilex3 = "17";
- } else if (xPos <= (innerWidth / 48) * 18) {
- tilex3 = "18";
- } else if (xPos <= (innerWidth / 48) * 19) {
- tilex3 = "19";
- } else if (xPos <= (innerWidth / 48) * 20) {
- tilex3 = "20";
- } else if (xPos <= (innerWidth / 48) * 21) {
- tilex3 = "21";
- } else if (xPos <= (innerWidth / 48) * 22) {
- tilex3 = "22";
- } else if (xPos <= (innerWidth / 48) * 23) {
- tilex3 = "23";
- } else if (xPos <= (innerWidth / 48) * 24) {
- tilex3 = "24";
- } else if (xPos <= (innerWidth / 48) * 25) {
- tilex3 = "25";
- } else if (xPos <= (innerWidth / 48) * 26) {
- tilex3 = "26";
- } else if (xPos <= (innerWidth / 48) * 27) {
- tilex3 = "27";
- } else if (xPos <= (innerWidth / 48) * 28) {
- tilex3 = "28";
- } else if (xPos <= (innerWidth / 48) * 29) {
- tilex3 = "29";
- } else if (xPos <= (innerWidth / 48) * 30) {
- tilex3 = "30";
- } else if (xPos <= (innerWidth / 48) * 31) {
- tilex3 = "31";
- } else if (xPos <= (innerWidth / 48) * 32) {
- tilex3 = "32";
- } else if (xPos <= (innerWidth / 48) * 33) {
- tilex3 = "33";
- } else if (xPos <= (innerWidth / 48) * 34) {
- tilex3 = "34";
- } else if (xPos <= (innerWidth / 48) * 35) {
- tilex3 = "35";
- } else if (xPos <= (innerWidth / 48) * 36) {
- tilex3 = "36";
- } else if (xPos <= (innerWidth / 48) * 37) {
- tilex3 = "37";
- } else if (xPos <= (innerWidth / 48) * 38) {
- tilex3 = "38";
- } else if (xPos <= (innerWidth / 48) * 39) {
- tilex3 = "39";
- } else if (xPos <= (innerWidth / 48) * 40) {
- tilex3 = "40";
- } else if (xPos <= (innerWidth / 48) * 41) {
- tilex3 = "41";
- } else if (xPos <= (innerWidth / 48) * 42) {
- tilex3 = "42";
- } else if (xPos <= (innerWidth / 48) * 43) {
- tilex3 = "43";
- } else if (xPos <= (innerWidth / 48) * 44) {
- tilex3 = "44";
- } else if (xPos <= (innerWidth / 48) * 45) {
- tilex3 = "45";
- } else if (xPos <= (innerWidth / 48) * 46) {
- tilex3 = "46";
- } else if (xPos <= (innerWidth / 48) * 47) {
- tilex3 = "47";
- } else if (xPos <= innerWidth) {
- tilex3 = "48";
- };
- };
- };
- function checkyt3() {
- if (checky3 == true) {
- if (yPos <= (innerHeight / 27) * 1) {
- tiley3 = "A";
- } else if (yPos <= (innerHeight / 27) * 2) {
- tiley3 = "B";
- } else if (yPos <= (innerHeight / 27) * 3) {
- tiley3 = "C";
- } else if (yPos <= (innerHeight / 27) * 4) {
- tiley3 = "D";
- } else if (yPos <= (innerHeight / 27) * 5) {
- tiley3 = "E";
- } else if (yPos <= (innerHeight / 27) * 6) {
- tiley3 = "F";
- } else if (yPos <= (innerHeight / 27) * 7) {
- tiley3 = "G";
- } else if (yPos <= (innerHeight / 27) * 8) {
- tiley3 = "H";
- } else if (yPos <= (innerHeight / 27) * 9) {
- tiley3 = "I";
- } else if (yPos <= (innerHeight / 27) * 10) {
- tiley3 = "J";
- } else if (yPos <= (innerHeight / 27) * 11) {
- tiley3 = "K";
- } else if (yPos <= (innerHeight / 27) * 12) {
- tiley3 = "L";
- } else if (yPos <= (innerHeight / 27) * 13) {
- tiley3 = "M";
- } else if (yPos <= (innerHeight / 27) * 14) {
- tiley3 = "N";
- } else if (yPos <= (innerHeight / 27) * 15) {
- tiley3 = "O";
- } else if (yPos <= (innerHeight / 27) * 16) {
- tiley3 = "P";
- } else if (yPos <= (innerHeight / 27) * 17) {
- tiley3 = "Q";
- } else if (yPos <= (innerHeight / 27) * 18) {
- tiley3 = "R";
- } else if (yPos <= (innerHeight / 27) * 19) {
- tiley3 = "S";
- } else if (yPos <= (innerHeight / 27) * 20) {
- tiley3 = "T";
- } else if (yPos <= (innerHeight / 27) * 21) {
- tiley3 = "U";
- } else if (yPos <= (innerHeight / 27) * 22) {
- tiley3 = "V";
- } else if (yPos <= (innerHeight / 27) * 23) {
- tiley3 = "W";
- } else if (yPos <= (innerHeight / 27) * 24) {
- tiley3 = "X";
- } else if (yPos <= (innerHeight / 27) * 25) {
- tiley3 = "Y";
- } else if (yPos <= (innerHeight / 27) * 26) {
- tiley3 = "Z";
- } else if (yPos <= innerHeight / 27) {
- tiley3 = "0";
- };
- };
- };
- function checkxt4() {
- if (checkx4 == true) {
- if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 1) {
- tilex4 = "1";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 2) {
- tilex4 = "2";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 3) {
- tilex4 = "3";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 4) {
- tilex4 = "4";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 5) {
- tilex4 = "5";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 6) {
- tilex4 = "6";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 7) {
- tilex4 = "7";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 8) {
- tilex4 = "8";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 9) {
- tilex4 = "9";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 10) {
- tilex4 = "10";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 11) {
- tilex4 = "11";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 12) {
- tilex4 = "12";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 13) {
- tilex4 = "13";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 14) {
- tilex4 = "14";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 15) {
- tilex4 = "15";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 16) {
- tilex4 = "16";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 17) {
- tilex4 = "17";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 18) {
- tilex4 = "18";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 19) {
- tilex4 = "19";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 20) {
- tilex4 = "20";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 21) {
- tilex4 = "21";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 22) {
- tilex4 = "22";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 23) {
- tilex4 = "23";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 24) {
- tilex4 = "24";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 25) {
- tilex4 = "25";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 26) {
- tilex4 = "26";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 27) {
- tilex4 = "27";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 28) {
- tilex4 = "28";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 29) {
- tilex4 = "29";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 30) {
- tilex4 = "30";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 31) {
- tilex4 = "31";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 32) {
- tilex4 = "32";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 33) {
- tilex4 = "33";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 34) {
- tilex4 = "34";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 35) {
- tilex4 = "35";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 36) {
- tilex4 = "36";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 37) {
- tilex4 = "37";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 38) {
- tilex4 = "38";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 39) {
- tilex4 = "39";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 40) {
- tilex4 = "40";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 41) {
- tilex4 = "41";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 42) {
- tilex4 = "42";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 43) {
- tilex4 = "43";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 44) {
- tilex4 = "44";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 45) {
- tilex4 = "45";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 46) {
- tilex4 = "46";
- } else if (xPos + (innerWidth * 0.0365625) <= (innerWidth / 48) * 47) {
- tilex4 = "47";
- } else if (xPos + (innerWidth * 0.0365625) <= innerWidth) {
- tilex4 = "48";
- };
- };
- };
- function checkyt4() {
- if (checky4 == true) {
- if (yPos <= (innerHeight / 27) * 1) {
- tiley4 = "A";
- } else if (yPos <= (innerHeight / 27) * 2) {
- tiley4 = "B";
- } else if (yPos <= (innerHeight / 27) * 3) {
- tiley4 = "C";
- } else if (yPos <= (innerHeight / 27) * 4) {
- tiley4 = "D";
- } else if (yPos <= (innerHeight / 27) * 5) {
- tiley4 = "E";
- } else if (yPos <= (innerHeight / 27) * 6) {
- tiley4 = "F";
- } else if (yPos <= (innerHeight / 27) * 7) {
- tiley4 = "G";
- } else if (yPos <= (innerHeight / 27) * 8) {
- tiley4 = "H";
- } else if (yPos <= (innerHeight / 27) * 9) {
- tiley4 = "I";
- } else if (yPos <= (innerHeight / 27) * 10) {
- tiley4 = "J";
- } else if (yPos <= (innerHeight / 27) * 11) {
- tiley4 = "K";
- } else if (yPos <= (innerHeight / 27) * 12) {
- tiley4 = "L";
- } else if (yPos <= (innerHeight / 27) * 13) {
- tiley4 = "M";
- } else if (yPos <= (innerHeight / 27) * 14) {
- tiley4 = "N";
- } else if (yPos <= (innerHeight / 27) * 15) {
- tiley4 = "O";
- } else if (yPos <= (innerHeight / 27) * 16) {
- tiley4 = "P";
- } else if (yPos <= (innerHeight / 27) * 17) {
- tiley4 = "Q";
- } else if (yPos <= (innerHeight / 27) * 18) {
- tiley4 = "R";
- } else if (yPos <= (innerHeight / 27) * 19) {
- tiley4 = "S";
- } else if (yPos <= (innerHeight / 27) * 20) {
- tiley4 = "T";
- } else if (yPos <= (innerHeight / 27) * 21) {
- tiley4 = "U";
- } else if (yPos <= (innerHeight / 27) * 22) {
- tiley4 = "V";
- } else if (yPos <= (innerHeight / 27) * 23) {
- tiley4 = "W";
- } else if (yPos <= (innerHeight / 27) * 24) {
- tiley4 = "X";
- } else if (yPos <= (innerHeight / 27) * 25) {
- tiley4 = "Y";
- } else if (yPos <= (innerHeight / 27) * 26) {
- tiley4 = "Z";
- } else if (yPos <= innerHeight / 27) {
- tiley4 = "0";
- };
- };
- };
- function roundgrav(x) {
- return Math.ceil(x / 10) * 10;
- }
- setInterval (function update() {
- var sprite = document.getElementById('sprite');
- sprite.style.bottom = yPos + 'px';
- sprite.style.left = xPos + 'px';
- xPos = xPos + xVel;
- yPos = yPos + yVel;
- checkxt1();
- checkyt1();
- checkxt2();
- checkyt2();
- checkxt3();
- checkyt3();
- checkxt4();
- checkyt4();
- tile1 = tiley1 + tilex1;
- tile2 = tiley2 + tilex2;
- tile3 = tiley3 + tilex3;
- tile4 = tiley4 + tilex4;
- // console.log("1:",tile1,'\n',"2:",tile2,'\n',"3:",tile3,'\n',"4:",tile4)
- // TEMP ground
- if (yPos <= 0) {
- G = true;
- A = false;
- yPos = 0;
- } else if (colstate == 0) {
- G = false;
- A = true;
- };
- // gravity
- if (G == true) {
- yVel = 0;
- } else if (yVel >= -30) {
- yVel = yVel - 0.5;
- }
- // col
- if (tile3 == "D27" || tile3 == "D28" || tile3 == "D29" || tile3 == "D30" || tile4 == "D27" || tile4 == "D28" || tile4 == "D29" || tile4 == "D30" || tile3 == "H36" || tile3 == "H37" || tile3 == "H38" || tile3 == "H39" || tile4 == "H36" || tile4 == "H37" || tile4 == "H38" || tile4 == "H39" || tile3 == "L30" || tile3 == "L31" || tile3 == "L32" || tile3 == "L33" || tile4 == "L30" || tile4 == "L31" || tile4 == "L32" || tile4 == "L33" || tile3 == "L20" || tile3 == "L21" || tile3 == "L22" || tile3 == "L23" || tile4 == "L20" || tile4 == "L21" || tile4 == "L22" || tile4 == "L23") {
- yVel = 0;
- G = true;
- A = false;
- colstate = 1;
- } else {
- colstate = 0;
- }
- // friction
- if (G == true) {
- if (xVel > 0) {
- xVel = xVel - 0.5;
- } else if (xVel < 0) {
- xVel = xVel + 0.5;
- }
- } else {
- if (xVel > 0) {
- xVel = xVel - 0.25;
- } else if (xVel < 0) {
- xVel = xVel + 0.25;
- }
- }
- // impact - fix for air to ground friction deficit
- if (A == true) {
- state = 1;
- }
- if (state == 1) {
- if (G == true) {
- state = 0;
- xVel = Math.round(xVel)
- yPos = roundgrav(yPos)
- }
- }
- // jump
- if (key[32] == true && G == true) {
- if (yVel <= 13.5) {
- yVel = 13.5;
- }
- };
- // right
- if (key[68] == true) {
- if (G == true) {
- var reintxvg0 = setInterval(speedupx0(), 20)
- if (xVel > mv) {
- clearInterval(reintxvg0);
- xVel = mv
- };
- } else if (A == true) {
- var reintxvg1 = setInterval(speedupx1(), 20)
- if (xVel > mv) {
- clearInterval(reintxvg1);
- xVel = mv
- }
- }
- };
- // left
- if (key[65] == true) {
- if (G == true) {
- var reintxvg0 = setInterval(speedupx2(), 20)
- if (xVel < -mv) {
- clearInterval(reintxvg0);
- xVel = -mv
- };
- } else if (A == true) {
- var reintxvg1 = setInterval(speedupx3(), 20)
- if (xVel < -mv) {
- clearInterval(reintxvg1);
- xVel = -mv
- }
- }
- };
- // tile x
- }, 16.66);
Advertisement
Add Comment
Please, Sign In to add comment