Skip to content

Commit

Permalink
feat(scenes): show solved pipes before going to next level
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed May 18, 2024
1 parent e6d16bb commit cc01921
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/constants/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ export enum FilledPipe {
'╋' = '╋',
}

export enum EmptyToFilledPipe {
'═' = '━',
'║' = '┃',
'╔' = '┏',
'╗' = '┓',
'╚' = '┗',
'╝' = '┛',
'╠' = '┣',
'╣' = '┫',
'╦' = '┳',
'╩' = '┻',
'╬' = '╋',
}

export enum DirectionPipe {
'△' = '△',
'▷' = '▷',
Expand Down
18 changes: 15 additions & 3 deletions src/scenes/game.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scene, Tag } from '../constants'
import { EmptyToFilledPipe, Scene, Tag } from '../constants'
import { checkSolution, rotatePipe } from '../helpers'
import { getLevel, hasLevel } from '../levels'

Expand All @@ -16,10 +16,22 @@ scene(Scene.game, (levelNumber: number) => {
})

onClick(Tag.pipe, (pipe) => {
rotatePipe(pipe)
if (!checkSolution(level)) {
rotatePipe(pipe)
}

if (checkSolution(level)) {
go(Scene.game, levelNumber + 1)
level.get(Tag.pipe).forEach((pipe) => {
pipe.use(
sprite(
EmptyToFilledPipe[pipe.solution as keyof typeof EmptyToFilledPipe],
),
)
})

wait(1, () => {
go(Scene.game, levelNumber + 1)
})
}
})
})

0 comments on commit cc01921

Please sign in to comment.