Jump to content

AlexT

New Members
  • Posts

    2
  • Joined

  • Last visited

AlexT's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the link. How is this looking? switch (e.keyCode) { case '65': if (prex[0] > 5) { prex[0] = prex[0] - step; } break; case '68': if (prex[0] < right) { prex[0] = prex[0] + step; } break;
  2. Hello Everyone, I have to change the if statements to a switch statement, in this game. Can anyone help? Thanks. var checkKeyPressed = function (e) { // Press key A or key D to make dog run to the left or right // The running speed is specified by the step variable, 10 by default. // If you replace 10 with a larger integer, the dog will run faster. //press A, dog runs left if (e.keyCode == "65") { if (prex[0] > 5) { prex[0] = prex[0] - step; } } //press D, dog runs right if (e.keyCode == "68") { if (prex[0] < right) { prex[0] = prex[0] + step; } } };
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.