-
-
Notifications
You must be signed in to change notification settings - Fork 185
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-game #204
Frogger-game #204
Conversation
Covered some common mistakes:
|
Please bring it back to the |
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.
@zhenyakornilov very well coded!
Apart of bringing collision checking function back as mentioned above, let's add more semantics to the constants so that peer developers were able to read what every number means and implement changes quickly when needed.
if (this.direction === "left") { | ||
this.x -= dt * this.speed; | ||
if (this.x < 0) { | ||
this.x = GAME_BOARD_WIDTH + 10; |
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 is 10
here and across the codebase? I guess -10
is the same but just negative. If true then having OFFSET = 10
and referring to it as OFFSET
and -OFFSET
would be fine.
Of course OFFSET
word doesn't explain it application, so invent a better name.
|
||
checkOverlap() { | ||
if ( | ||
this.player.x < this.x + 60 && |
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 is 60
?
Made some changes |
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.
@zhenyakornilov please go through your code and extrapolate previous comments re magic numbers to all other similar situations in your code.
Do not expect a reviewer to "red pen" every single tiny bug in the code. Own it truly.
It seems to be a bit better now. |
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.
@zhenyakornilov a really good job!
Hint on naming in graphic environments:
In regular structures like matrices, game fields (which are also matrices) elements' coordinates are defined by row (or column), matrix row height (or matrix column width), and offset.
So, for e.g. y = verticalOffset + row * rowHeight
. Items to place into the matrix may have their own individual offsets (like in this game where visual part has offsets against its pixel representation).
So having defined offsets, widths and heights it is possible to calculate any coordinates based on row and column index.
Object-Oriented JS - Frogger-game
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.