-
Notifications
You must be signed in to change notification settings - Fork 1
Remove infinitely stalling player block via rotations & add counterclockwise rotations & remap actions #31
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
Conversation
This is to match tetr.io's keybindings.
…lockwise rotation on `Z`
src/GameLoop.tsx
Outdated
| !playerPhysics.isInRBounds(cell.r) || | ||
| board[cell.r][cell.c].char !== EMPTY | ||
| ) { | ||
| overlappingI = i; |
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.
I think there's a better way to do this than filter.
| }); | ||
| if (keyCode === 37) { | ||
| // Left | ||
| if ("ArrowLeft" == code) { |
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.
Much clearer than before!
src/PlayerPhysics.tsx
Outdated
| console.log(this.adjustedCells); | ||
| const mid = Math.floor(this.layout.length / 2); | ||
| return cells.map(({ r, c, char, uid }) => { | ||
| return cells.map(({ r, c, uid, char }) => { |
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.
Why reverse these? Keep them in the same order everywhere and where you construct them. Matters for performance a lot.
| let isPlayerMovementEnabled = false; | ||
| let didInstantDrop = false; | ||
|
|
||
| let leaveGroundPenalty = 0; |
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.
No global mutable state.
| let didInstantDrop = false; | ||
|
|
||
| let leaveGroundPenalty = 0; | ||
| const leaveGroundRate = 250; |
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.
This one should be fine if it's a constant.
| @@ -1,5 +1,4 @@ | |||
| import * as React from "react"; | |||
| import { useState } from "react"; | |||
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.
Commit this change directly to main; it's separate.
| root.render( | ||
| <StrictMode> | ||
| <GameLoop/>, | ||
| <GameLoop /> |
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.
Commit this change directly to main; it's separate.
|
|
||
| function updatePlayerPos( | ||
| { keyCode, repeat }: { keyCode: number; repeat: boolean }, | ||
| { code }: { code: string }, |
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.
Where is this function called?
Co-authored-by: Khyber Sen <[email protected]>
Co-authored-by: Khyber Sen <[email protected]>
Fixes #20