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

Frogger js core code #92

Merged
merged 4 commits into from
Sep 6, 2022
Merged

Frogger js core code #92

merged 4 commits into from
Sep 6, 2022

Conversation

AsaMitaka
Copy link
Contributor

Object oriented JS

Demo
Code

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@AsaMitaka AsaMitaka changed the title js core code Frogger js core code Aug 9, 2022
@github-actions
Copy link

Thank you for contributing to this repo! ❤️️

Frogger Arcade Game -- JS OO exercise check list

Relates to Object-Oriented JavaScript task.

Let's do some self-checks to fix most common issues and to make some improvements to the code while reviewers find some time to dedicate it to your submission.

Go through the checklist below, fix code as appropriate and mark fulfilled requirements when you genuinely believe you are done.

Please, feel free to ask questions here or seek for help in the Students' chat.

Check-list - definition of done

Minimal requirements to meet:

  • it is OK to employ ES6 features like const, let etc.
  • the code is very DRY
  • OO is implemented using JS prototype chain object model (not ES6 classes syntax)
  • Requirements re Constants:
    • all numbers like block dimensions, initial locations are defined as named constants (e.g. const STEP = 101;) as otherwise numbers scattered across code base look cryptic; named constants add semantic meaning and improve readability
    • every number that has a semantic purpose (like those listed above) should be defined as constants; think of how your code reads - the closer to plain English the better
    • there are core constants and derived constants
      (e.g. derived constant const FIELD_WIDTH = BLOCK_WIDTH * BLOCKS_NUMBER;)
    • arrays of constants are also constants
      (e.g. const INITIAL_POSITIONS = [1,2,3,4].map(rowNumber => rowNumber * BLOCK_HEIGHT);)
    • const objects help organizing and structure const data even better
      (e.g. const PLAYER_CONF = { initialPosition: {x: 1, y: 5}, sprite: '...', ...etc... };
  • Requirements re OOP:
    • classes do not refer to any global variables, like global variable player, which is an instance of Player class
      (referring to global constants and globals provided by the gaming platform like Resources is OK);
      Hint: pass Player instance as an argument to every enemy
    • Separation of Concerns principle is followed
      (e.g. update method does only rendering and doesn't contain any unrelated inline code; for example collision check is defined as a dedicated method and only called from inside update)
    • Nice To Have: properties common for some classes are generalized into a base class
      (e.g. there is Character base class, which is extended by Enemy and Player classes)
    • class extension is implemented using Subclass.prototype = Object.create(Superclass.prototype), not Subclass.prototype = new Superclass(params);; Helpful resource
  • Most common mistakes
    • Make sure target = condition ? valueWhenConditionTrue : valueWhenConditionFalse is used instead of condition ? target = valueWhenConditionTrue : target = valueWhenConditionFalse; Conditional (ternary) operator

Sincerely yours,
Submissions Kottachecker 😺

Copy link

@yaripey yaripey left a comment

Choose a reason for hiding this comment

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

Hey! There are some improvements that can be done, but in general, nice work!

You've chosen to make the character go not cell-by-cell but with smaller steps which are fine but it's a little strange that it can go so low, almost off the level, and stops going left so early. Please work on the limits of where the character can go.

Also, check comments below.

@@ -0,0 +1,169 @@
// Enemies our player must avoid
Copy link

Choose a reason for hiding this comment

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

Seems like an irrelevant comment here.

@@ -0,0 +1,169 @@
// Enemies our player must avoid
var newP = document.createElement('p');
Copy link

Choose a reason for hiding this comment

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

You should avoid using vars. Most of the time to store a value const is enough and only if you are 100% sure that you'll change this value in code later use let.

newP.textContent = `Your score: 0 `;
document.body.append(newP);

var enemyStat = {
Copy link

Choose a reason for hiding this comment

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

There is no reason for a separate object that stores information about enemies since you already has a whole class for them. Store these values there.


Player.prototype.win = function() {
if (field.min >= this.posY) {
console.log(field.min, this.posY);
Copy link

Choose a reason for hiding this comment

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

console.log is fine for debugging but should be removed from the final version of the code.

@yaripey yaripey self-assigned this Aug 20, 2022
@AsaMitaka AsaMitaka requested a review from yaripey August 20, 2022 12:59
@yaripey
Copy link

yaripey commented Aug 20, 2022

Did you forget to update your own repo? Github Pages demo still has problems listed in my previous review.

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.

Also follow the requirements here #92 (comment)

Feel free asking questions here or in Students' chat if anything is not really clear.

When done, please confirm explicitly that all requirements are met.

@AsaMitaka AsaMitaka requested review from OleksiyRudenko and removed request for yaripey August 31, 2022 16:23
@yaripey
Copy link

yaripey commented Sep 6, 2022

Great job!

@yaripey yaripey merged commit 4e76946 into kottans:main Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants