-
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 import statements for improved code organization and readabi…
…lity
- Loading branch information
Showing
19 changed files
with
264 additions
and
105 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 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
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 |
---|---|---|
@@ -1,8 +1,4 @@ | ||
import Game from "./game" | ||
import { $ } from "./utils" | ||
import Ui from "./ui"; | ||
|
||
const game = new Game((score) => { | ||
$(".score")!.textContent = score + "" | ||
}) | ||
game.startGame() | ||
console.log(game) | ||
|
||
new Ui() |
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,74 @@ | ||
import { Binary, isBinaryString } from "./helper"; | ||
|
||
|
||
export type BinaryString<T extends BrickStruct> = { | ||
[K in keyof T]: isBinaryString<T[K]>; | ||
}; | ||
// type a = BinaryString<("00" | "10" | "01" | "11")[]> | ||
|
||
export type Struct< | ||
T extends number, | ||
R extends any[] = [] | ||
> = R["length"] extends T ? R : Struct<T, [...R, Binary<T>]>; | ||
|
||
export type BrickLetter = keyof Bricks; | ||
|
||
export type BrickColor = Bricks[BrickLetter]["color"]; | ||
|
||
export type BrickStruct = Bricks[BrickLetter]["struct"]; | ||
|
||
|
||
|
||
export type Bricks = { | ||
[key: string]: { | ||
color: string; | ||
struct: Readonly<Struct<1> | Struct<2> | Struct<3> | Struct<4>>; | ||
}; | ||
o: { | ||
color: "#FADADD"; | ||
struct: Readonly<Struct<2>>; | ||
}; | ||
i: { | ||
color: "#F7E9D4"; | ||
struct: Readonly<Struct<4>>; | ||
}; | ||
s: { | ||
color: "#C8E6C9"; | ||
struct: Readonly<Struct<3>>; | ||
}; | ||
z: { | ||
color: "#B3E5FC"; | ||
struct: Readonly<Struct<3>>; | ||
}; | ||
l: { | ||
color: "#FFCC80"; | ||
struct: Readonly<Struct<3>>; | ||
}; | ||
j: { | ||
color: "#FFEE58"; | ||
struct: Readonly<Struct<3>>; | ||
}; | ||
t: { | ||
color: "#CE93D8"; | ||
struct: Readonly<Struct<3>>; | ||
}; | ||
}; | ||
|
||
export interface IBrick { | ||
letter: BrickLetter; | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
color: BrickColor; | ||
structure: BinaryString<BrickStruct>; | ||
isRecycle: boolean; | ||
draw(ctx: CanvasRenderingContext2D): void; | ||
update(time: number, mapBinary: number[]): boolean; | ||
getBinary(): number[]; | ||
left(mapBinary: number[]): void; | ||
right(mapBinary: number[]): void; | ||
downOne(mapBinary: number[]): boolean; | ||
downBottom(mapBinary: number[]): boolean; | ||
rotate(mapBinary: number[]): void; | ||
} |
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
Oops, something went wrong.