Skip to content
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

Merged
merged 4 commits into from
Oct 9, 2022
Merged

Conversation

MosQuitO404
Copy link
Contributor

Object Oriented JS

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@github-actions
Copy link

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:

  • Make sure your code follows General Requirements
  • Use common sense or seek for an advice whenever requirements look ambiguous or unclear.

By the way, you may proceed to the next task before this one is reviewed and merged.

Sincerely yours,
Submissions Kottachecker 😺

@MosQuitO404
Copy link
Contributor Author

MosQuitO404 commented Sep 12, 2022

@A-Ostrovnyy I have completed self-checks and fixed code accordingly

@A-Ostrovnyy A-Ostrovnyy added the self-check-done Student confirmed that self-checks against requirements/common-mistakes are done label Sep 12, 2022
@MosQuitO404
Copy link
Contributor Author

@A-Ostrovnyy Hi! Feedback received, bugs were not found. Review please.

Copy link
Member

@OleksiyRudenko OleksiyRudenko left a 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

Comment on lines 46 to 51
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;
Copy link
Member

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

Copy link
Contributor Author

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];
Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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 :)

Comment on lines 59 to 60
this.rowHeight = 75;
this.columnWidth = 101;
Copy link
Member

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.

Copy link
Contributor Author

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++) {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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 = [];
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Done

@MosQuitO404
Copy link
Contributor Author

MosQuitO404 commented Oct 2, 2022

@A-Ostrovnyy, @OleksiyRudenko Hi! Please mark label for Stage 0.1 See please this comment 9 days ago #513 (comment)

@MosQuitO404 MosQuitO404 closed this Oct 2, 2022
@MosQuitO404 MosQuitO404 reopened this Oct 2, 2022
Copy link
Member

@OleksiyRudenko OleksiyRudenko left a 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 OleksiyRudenko merged commit 5f0e179 into kottans:main Oct 9, 2022
@MosQuitO404
Copy link
Contributor Author

@MosQuitO404 great job!

@OleksiyRudenko Thank you very much! The best motivation for me.

@MosQuitO404 MosQuitO404 deleted the frogger branch October 9, 2022 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-check-done Student confirmed that self-checks against requirements/common-mistakes are done Stage0.1 task-Frogger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants