From f7d22fc255c7fb35449c2509ee8b1c65060f33bb Mon Sep 17 00:00:00 2001 From: huiddd <1732122592@qq.com> Date: Wed, 5 Jun 2024 02:44:32 +0800 Subject: [PATCH] chore: Rename `downBottom` method to `downToBottom` in `Brick` class --- src/brick/index.ts | 2 +- src/canvasWithMapCtx.ts | 1 - src/game.ts | 1 + src/inputHandler/index.ts | 2 +- src/operate.ts | 4 ++-- src/renderer.ts | 1 - src/types/brick.ts | 2 +- src/types/index.ts | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/brick/index.ts b/src/brick/index.ts index 828afbf..7b64e36 100644 --- a/src/brick/index.ts +++ b/src/brick/index.ts @@ -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++ } diff --git a/src/canvasWithMapCtx.ts b/src/canvasWithMapCtx.ts index ceadedb..934b891 100644 --- a/src/canvasWithMapCtx.ts +++ b/src/canvasWithMapCtx.ts @@ -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 diff --git a/src/game.ts b/src/game.ts index 44e6fd3..33b028c 100644 --- a/src/game.ts +++ b/src/game.ts @@ -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() { diff --git a/src/inputHandler/index.ts b/src/inputHandler/index.ts index 98a4c10..6509f6a 100644 --- a/src/inputHandler/index.ts +++ b/src/inputHandler/index.ts @@ -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) => { diff --git a/src/operate.ts b/src/operate.ts index 9a4fe10..b000ee4 100644 --- a/src/operate.ts +++ b/src/operate.ts @@ -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 } diff --git a/src/renderer.ts b/src/renderer.ts index 5c4c1bf..975fe27 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -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 diff --git a/src/types/brick.ts b/src/types/brick.ts index 4f2e0ff..f40eb19 100644 --- a/src/types/brick.ts +++ b/src/types/brick.ts @@ -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; } diff --git a/src/types/index.ts b/src/types/index.ts index e21f52d..ea7bb84 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -19,7 +19,7 @@ export type OperateEvents = { left: () => void right: () => void downOne: () => void - downBottom: () => void + downToBottom: () => void rotate: () => void pauseGame: () => void }