-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project 1 #23
base: master
Are you sure you want to change the base?
Project 1 #23
Conversation
|
||
|
||
function shuffleArray(arr) { | ||
for (var i = arr.length - 1; i > 0; i--){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain this line of codes to me, why does the loop reversing? and how does the es6 code works?
Use simple example.
@@ -0,0 +1,291 @@ | |||
//Part 1 - Shuffle array, add a random number btw 1-4 into array(for adding rounds) | |||
var instructorMoves = [37,38,39,40] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid creating a global variables, you can put this under line 21.
return (value - 36); | ||
}) | ||
|
||
for(let e = 0; e <= randSequence.length; e++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm? why not just tagged your instructor number class into one div, so you don't have to do this loop instead.
e.g.
var danceMove = instructorMoves [Math.floor( Math.random() * instructorMoves.length )]
$('.instructor').addClass(`dance${danceMove}`)
this.play(); | ||
}, false); | ||
|
||
$button.on('click' , function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what button is this? Be more descriptive on your variable naming.
$(".startBtn").hide() | ||
$(".resetBtn").show() | ||
|
||
$body.on('keydown', (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation issues here
// Set keys with different images for player 1 | ||
if(strOfKeys === 37) { | ||
$('.playerOneDiv').addClass("move"); | ||
$('.playerOneDiv').css('backgroundImage', `url("./assets/images/player1_1.png")`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again same issues here like the instructor moves, why just add in the class instead?
Project Workflow: 2 / 5 Glow
Grow
Things to look out for
|
Project Workflow: 3 / 5 GlowInteresting and fun game. :) GrowKeep DRY(Don't Repeat Yourself) and KISS(Keep It Simple Stupid) principle in your mind, save your lines and make the logic clear if possible. Indentation is very important for readability and debugging. Avoid using of global scope. Things to look out forCode refactoring with DRY principle. |
whichPlayer = 2 | ||
} | ||
|
||
//Part 3 - Matching keypressed with instructorMoves in sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may refactor matching logics for reducing repetition.
No description provided.