Site Output
- Your game is well styled, and the concept is well imagined on the web page. I’m really impressed with what you’ve produced here.
- The apples randomly rotating whilst falling is a great touch.
Code Knowledge & Use
- You’ve effectively used event listeners and control flow to manage the functions in your JavaScript
- I would like to see you make your conditions (
if statements) easier to read/ digest, for example you have quite a complex one here in detectCollision. For complex conditions, it can be good to pull the condition into its own function:
// your code...
if (
apple[i].x + apple[i].width >= player.x &&
apple[i].x <= player.x + player.width &&
apple[i].y + apple[i].height >= player.y &&
apple[i].y <= player.y + player.height
)
// pulling your condition into an isCollision function...
const isCollision = (apple, player) => {
const xOverlap =
apple.x + apple.width >= player.x && apple.x <= player.x + player.width;
const yOverlap =
apple.y + apple.height >= player.y && apple.y <= player.y + player.height;
return xOverlap && yOverlap;
};
// call that new function in the condition...
if (isCollision(apple, player))
- I’m happy you’ve got a good understanding of JS methods and control flow, I think something for you to focus on is improving your refactoring skills.. a good example where you’ve done this well is line 42-43. Creating variables for complex expressions like
position and borderBottom is great.
Readability
- You’ve used functions to separate logic across your JavaScript, and ordered different sections of your code well
- Remove those extra
console.log statements! They may be useful when working on a project, but should be removed when pushed up to a live site.
- You’ve used
for loops confidently, I’d recommend refactoring some of them into a forEach method, it can be more concise and easier to read.
Responsiveness
- Although your game looks good and is responsive to mobile, I can’t play the game at all! I would have loved to see some controls available for mobile devices, as they don’t have arrow keys to use.
- I would recommend this being the next feature to add (maybe over the christmas break if you get time!)
Site Output
Code Knowledge & Use
ifstatements) easier to read/ digest, for example you have quite a complex one here indetectCollision. For complex conditions, it can be good to pull the condition into its own function:positionandborderBottomis great.Readability
console.logstatements! They may be useful when working on a project, but should be removed when pushed up to a live site.forloops confidently, I’d recommend refactoring some of them into aforEachmethod, it can be more concise and easier to read.Responsiveness