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

create frogger-game #53

Merged
merged 5 commits into from
Aug 15, 2022
Merged

Conversation

Pozzitive11
Copy link
Contributor

Frogger game

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, 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.

@Pozzitive11 well done!
Let's use the opportunity to improve the code and be ready for a massive expansion of game characters to be added by our peer developers.

ctx.drawImage(Resources.get(this.sprite), this.x, this.y);
}

collision() {
Copy link
Member

@OleksiyRudenko OleksiyRudenko Aug 6, 2022

Choose a reason for hiding this comment

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

By convention method/function names should start with a verb.

Comment on lines 97 to 99
new Enemy(tileSize.height * 3 - enemy.enemyCenter, 90),
new Enemy(tileSize.height * 2 - enemy.enemyCenter, 150),
new Enemy(tileSize.height * 1 - enemy.enemyCenter, 100),
Copy link
Member

Choose a reason for hiding this comment

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

What are these magic numbers - 90, 150, 100?
Let the code explain them.

Comment on lines 61 to 63
render() {
ctx.drawImage(Resources.get(this.sprite), this.x, this.y);
}
Copy link
Member

Choose a reason for hiding this comment

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

ENemy class has exactly the same method. Let's make this DRY. Consider having a base class for both Player and Enemy, that would handle all shared properties and behaviour.

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.

@Pozzitive11 your changes feel unfinished. Let's polish it.

}
class Enemy extends gameObjectRender {
constructor(y, speed, sprite) {
super(y, sprite);
Copy link
Member

Choose a reason for hiding this comment

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

Super class doesn't have a constructor. This operation is effectively void. Same is applicable to the Player class. However the idea to have similar properties and similar behaviour in a base class is great.
Can you fix this and implement shared properties and methods via the base class?

left: 0,
};

class gameObjectRender {
Copy link
Member

Choose a reason for hiding this comment

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

Think of class hierarchy as of bilogical taxonomy. Humans inherit features from apes, apes from mammals, mammals from vertebraes, and so on.
In this fictional game world bugs and player have a common fictional predecessor whose name could be saying something to the developers that may want to contribute to your game. May be a both bugs and player are instances of a character?

@Pozzitive11
Copy link
Contributor Author

sorry for making the same mistakes 🥲

@OleksiyRudenko OleksiyRudenko self-assigned this Aug 7, 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.

@Pozzitive11 great job!

@OleksiyRudenko OleksiyRudenko merged commit 74e0e7e into kottans:main Aug 15, 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.

3 participants