-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Object Oriented JS (frogger) #513
Conversation
Hey! Congratulations on your PR! 😎😎😎 Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code. Go through the requirements/most common mistakes linked below and fix the code as appropriate. If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat. When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly. Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒 Please, make sure that your code follows the requirements Universal recommendations:
By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
@A-Ostrovnyy I have completed self-checks and fixed code accordingly |
@A-Ostrovnyy Hi! Feedback received, bugs were not found. Review please. |
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.
@MosQuitO404 good start.
Needs improvement.
Comments below refer to these requirements
if (player.y < this.y + player.collisionAreaHeight && | ||
player.y + player.collisionAreaHeight > this.y && | ||
player.x < this.x + player.collisionAreaWidth && | ||
player.x + player.collisionAreaWidth > this.x) { | ||
player.x = player.columnWidth * 2; | ||
player.y = player.rowHeight * 5; |
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.
See item 4.iii of the requirements
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.
Ok, done! Thanks
}; | ||
|
||
Enemy.prototype.positionEnemyMaker = function() { | ||
const allowedPositions = [47, 129, 211]; |
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.
Imagine you are tasked to add two more rows. Please optimize this.
Rows seem to be of the same height. Something is off in your calculations. Let computer do calculations.
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.
Resolved
// You should multiply any movement by the dt parameter | ||
// which will ensure the game runs at the same speed for | ||
// all computers. | ||
if (this.x < 500) { |
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.
50, -95 and other numbers seem mysterious.
See section 3 of the requirements.
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.
Ok, resolved. It's canvas size :)
this.rowHeight = 75; | ||
this.columnWidth = 101; |
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.
These do not seem to be properties of a player. Player doesn't have rows or columns.
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.
Ok! Done
// Place the player object in a variable called player | ||
let allEnemies = []; | ||
function createEnemies(minEnemies, maxEnemies) { | ||
for (let i = 0; i < Math.floor(Math.random() * (maxEnemies - minEnemies + 1)) + minEnemies; 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.
i < Math.floor(Math.random() * (maxEnemies - minEnemies + 1)) + minEnemies
runs at every loop iteration.
Is it what you actualy want?
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.
Yes. Every start new game this iteration randomly generate from 3 to 5 enemies.
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.
But the quoted fragment is executed not only for every new game but literally at every for
loop iteration. i
gets compared to a different number at every i++
change.
What sense does it make?
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.
@OleksiyRudenko Thanks! You're right. Please see resolve in code. So maybe is this right solution?
alert('Great! You Win!'); | ||
this.x = this.columnWidth * 2; | ||
this.y = this.rowHeight * 5; | ||
allEnemies = []; |
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.
See item 4.iii of the requirements.
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.
Ok! Done
@A-Ostrovnyy, @OleksiyRudenko Hi! Please mark label for Stage 0.1 See please this comment 9 days ago #513 (comment) |
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.
@MosQuitO404 great job!
@OleksiyRudenko Thank you very much! The best motivation for me. |
Object Oriented JS
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.