-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor file paths and import statements for game configuration
- Loading branch information
Showing
12 changed files
with
55 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { GameParam } from "./types" | ||
import { $ } from "./utils" | ||
const container = $("#container") as HTMLDivElement | ||
const { width, height } = container.getBoundingClientRect() | ||
export const gameParam: GameParam = { | ||
column: 10, | ||
row: 20, | ||
FPS: 60, | ||
speed: 2, | ||
keySpeed: 10, | ||
score: 0, | ||
devicePixelRatio: window.devicePixelRatio, | ||
// 给方块计算出整数值宽高,不然小数情况可能会出现方块间的间隙 | ||
get brickWidth() { | ||
return Math.round((width * this.devicePixelRatio) / this.column) | ||
}, | ||
get brickHeight() { | ||
return Math.round((height * this.devicePixelRatio) / this.row) | ||
}, | ||
// 以方块的整数值加上行列算出整个画布的宽高 | ||
get windowWidth() { | ||
return this.brickWidth * this.column | ||
}, | ||
get windowHeight() { | ||
return this.brickHeight * this.row | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const control = { | ||
operate: { | ||
left: ["a", "ArrowLeft"], | ||
right: ["d", "ArrowRight"], | ||
up: ["w", "ArrowUp"], | ||
down: ["s", "ArrowDown"], | ||
bottom: [" "], | ||
}, | ||
onceKey: ["up", "bottom"], | ||
speedUpKey: ["down"], | ||
speedUpRate: 2, | ||
pause: ["Enter", "p"], | ||
} as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters