Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I don't consider myself a javascript expert yet (proof of that is my own attempt at Simon in javascript attempt at Simon in javascript!), but I see some things that may help you improve your code.

Use responsive design

Unfortunately, the css uses absolute px measurements instead of relative measurements, so the result is that on a small screen, like a phone, this isn't playable because most of the game is off the screen. If you're using the Firefox browser, you can use the built-in responsive design view to see how your page looks at various screen sizes.

Amend the gameplay

Each round starts a brand new sequence. That's not necessarily an error, but the way the original worked was that it would add one to the sequence each time, so if the sequence for round 4 was "RGYB", the sequence for round 5 might be "RGYBG".

Is the + operator needed here?

There is this line in the code:

var step = 2 * +i;

Generally, I understand that +i would give the numeric representation of i, but it doesn't seem possible that i is anything but numeric there. Could be I'm missing something.

Disable input until the sequence is done

Right now, a user can "cheat" by just following the game as it lights each button rather than having to wait for the sequence to be done before replaying. This effectively eliminates the memory aspect of the game. Better would be to disable input until the computer has played the entire sequence once.

Add sound

You probably already have that in mind, but that was an important aspect of the original game.

I don't consider myself a javascript expert yet (proof of that is my own attempt at Simon in javascript!), but I see some things that may help you improve your code.

Use responsive design

Unfortunately, the css uses absolute px measurements instead of relative measurements, so the result is that on a small screen, like a phone, this isn't playable because most of the game is off the screen. If you're using the Firefox browser, you can use the built-in responsive design view to see how your page looks at various screen sizes.

Amend the gameplay

Each round starts a brand new sequence. That's not necessarily an error, but the way the original worked was that it would add one to the sequence each time, so if the sequence for round 4 was "RGYB", the sequence for round 5 might be "RGYBG".

Is the + operator needed here?

There is this line in the code:

var step = 2 * +i;

Generally, I understand that +i would give the numeric representation of i, but it doesn't seem possible that i is anything but numeric there. Could be I'm missing something.

Disable input until the sequence is done

Right now, a user can "cheat" by just following the game as it lights each button rather than having to wait for the sequence to be done before replaying. This effectively eliminates the memory aspect of the game. Better would be to disable input until the computer has played the entire sequence once.

Add sound

You probably already have that in mind, but that was an important aspect of the original game.

I don't consider myself a javascript expert yet (proof of that is my own attempt at Simon in javascript!), but I see some things that may help you improve your code.

Use responsive design

Unfortunately, the css uses absolute px measurements instead of relative measurements, so the result is that on a small screen, like a phone, this isn't playable because most of the game is off the screen. If you're using the Firefox browser, you can use the built-in responsive design view to see how your page looks at various screen sizes.

Amend the gameplay

Each round starts a brand new sequence. That's not necessarily an error, but the way the original worked was that it would add one to the sequence each time, so if the sequence for round 4 was "RGYB", the sequence for round 5 might be "RGYBG".

Is the + operator needed here?

There is this line in the code:

var step = 2 * +i;

Generally, I understand that +i would give the numeric representation of i, but it doesn't seem possible that i is anything but numeric there. Could be I'm missing something.

Disable input until the sequence is done

Right now, a user can "cheat" by just following the game as it lights each button rather than having to wait for the sequence to be done before replaying. This effectively eliminates the memory aspect of the game. Better would be to disable input until the computer has played the entire sequence once.

Add sound

You probably already have that in mind, but that was an important aspect of the original game.

Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284

I don't consider myself a javascript expert yet (proof of that is my own attempt at Simon in javascript!), but I see some things that may help you improve your code.

Use responsive design

Unfortunately, the css uses absolute px measurements instead of relative measurements, so the result is that on a small screen, like a phone, this isn't playable because most of the game is off the screen. If you're using the Firefox browser, you can use the built-in responsive design view to see how your page looks at various screen sizes.

Amend the gameplay

Each round starts a brand new sequence. That's not necessarily an error, but the way the original worked was that it would add one to the sequence each time, so if the sequence for round 4 was "RGYB", the sequence for round 5 might be "RGYBG".

Is the + operator needed here?

There is this line in the code:

var step = 2 * +i;

Generally, I understand that +i would give the numeric representation of i, but it doesn't seem possible that i is anything but numeric there. Could be I'm missing something.

Disable input until the sequence is done

Right now, a user can "cheat" by just following the game as it lights each button rather than having to wait for the sequence to be done before replaying. This effectively eliminates the memory aspect of the game. Better would be to disable input until the computer has played the entire sequence once.

Add sound

You probably already have that in mind, but that was an important aspect of the original game.

lang-css

AltStyle によって変換されたページ (->オリジナル) /