Skip to content

Commit

Permalink
chore: Rename downBottom method to downToBottom in Brick class
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhuid committed Jun 4, 2024
1 parent 71a6e2e commit f7d22fc
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/brick/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Brick implements IBrick {
}
return true
}
downBottom(mapBinary: number[]) {
downToBottom(mapBinary: number[]) {
while (!this.isOverlap(mapBinary, this.getBinary(), this.x, this.y + 1)) {
this.y++
}
Expand Down
1 change: 0 additions & 1 deletion src/canvasWithMapCtx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { gameParam } from "./gameConfig"
import { ICanvasWithMapCtx } from "./types"
import { BrickColor } from "./types/brick"
import { $ } from "./utils"

const canvas = $(".canvas.brick") as HTMLCanvasElement
Expand Down
1 change: 1 addition & 0 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class Game implements IGame {
restartGame() {
this.canvasWithMapCtx.cleanUpCanvas()
this.canvasWithMapCtx = new CanvasWithMapCtx()
this.Scorer.reset()
this.renderer = new Renderer(this.canvasWithMapCtx)
}
playGame() {
Expand Down
2 changes: 1 addition & 1 deletion src/inputHandler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const getHandle = (function () {
left: "left",
right: "right",
down: "downOne",
bottom: "downBottom",
bottom: "downToBottom",
up: "rotate",
} as const
return (operation: OperateEvents, ctrlKey: Control) => {
Expand Down
4 changes: 2 additions & 2 deletions src/operate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default class Operation implements OperateEvents {
this.brick.isRecycle = true
}
}
downBottom() {
const shouldNextOne = this.brick.downBottom(this.canvasWithMapCtx.mapBinary)
downToBottom() {
const shouldNextOne = this.brick.downToBottom(this.canvasWithMapCtx.mapBinary)
if (shouldNextOne) {
this.brick.isRecycle = true
}
Expand Down
1 change: 0 additions & 1 deletion src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default class Renderer implements IRenderer {
this.operation.brick.draw(this.canvasWithMapCtx.ctx)
}
private update(time: number) {
// console.log(time)
const shouldNextOne = this.operation.brick.update(
time,
this.canvasWithMapCtx.mapBinary
Expand Down
2 changes: 1 addition & 1 deletion src/types/brick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ export interface IBrick {
left(mapBinary: number[]): void;
right(mapBinary: number[]): void;
downOne(mapBinary: number[]): boolean;
downBottom(mapBinary: number[]): boolean;
downToBottom(mapBinary: number[]): boolean;
rotate(mapBinary: number[]): void;
}
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type OperateEvents = {
left: () => void
right: () => void
downOne: () => void
downBottom: () => void
downToBottom: () => void
rotate: () => void
pauseGame: () => void
}
Expand Down

0 comments on commit f7d22fc

Please sign in to comment.