-
-
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
create frogger-game #53
Conversation
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.
@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() { |
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.
By convention method/function names should start with a verb.
new Enemy(tileSize.height * 3 - enemy.enemyCenter, 90), | ||
new Enemy(tileSize.height * 2 - enemy.enemyCenter, 150), | ||
new Enemy(tileSize.height * 1 - enemy.enemyCenter, 100), |
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.
What are these magic numbers - 90, 150, 100?
Let the code explain them.
render() { | ||
ctx.drawImage(Resources.get(this.sprite), this.x, this.y); | ||
} |
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.
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.
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.
@Pozzitive11 your changes feel unfinished. Let's polish it.
} | ||
class Enemy extends gameObjectRender { | ||
constructor(y, speed, sprite) { | ||
super(y, sprite); |
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.
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 { |
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.
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?
sorry for making the same mistakes 🥲 |
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.
@Pozzitive11 great job!
Frogger game
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.