Skip to content

Commit

Permalink
Add additional animations
Browse files Browse the repository at this point in the history
I want to also animate on colour, but I'm waiting for

https://developer.mozilla.org/en-US/docs/Web/CSS/@property

to be released for better support
  • Loading branch information
ccouzens committed Apr 14, 2024
1 parent 31fd12f commit ec53367
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
43 changes: 41 additions & 2 deletions public/game-win-animations.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:root.win #route {
:root.win[data-animation="1"] #route {
animation: 5s infinite normal stroke-dash-array;
}

:root.win #walls {
:root.win[data-animation="1"] #walls {
animation: 10s infinite normal stroke-dash-array;
}

Expand All @@ -21,3 +21,42 @@
stroke-dasharray: 5 0;
}
}

:root.win[data-animation="2"] #route {
stroke-linejoin: round;
stroke-linecap: round;
animation: 2.5s infinite alternate expand-width;
}

:root.win[data-animation="2"] #walls {
animation: 5s infinite alternate fade-to-transparent;
}

@keyframes expand-width {
to {
stroke-width: 5;
}
}

@keyframes fade-to-transparent {
to {
stroke: transparent;
}
}

:root.win[data-animation="3"] #route {
animation: 5s infinite alternate fade-to-transparent;
stroke-linejoin: round;
stroke-linecap: round;
}

:root.win[data-animation="3"] #walls {
stroke-linecap: round;
animation: 5s infinite alternate expand-to-1;
}

@keyframes expand-to-1 {
to {
stroke-width: 1;
}
}
1 change: 1 addition & 0 deletions src/game/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function newMaze(app: App): void {
"viewBox",
`-0.125 -0.125 ${app.computer.maze_width(app.maze) + 0.25} ${app.computer.maze_height(app.maze) + 0.25}`,
);
app.root.dataset["animation"] = `${Math.floor(Math.random() * 3) + 1}`;
renderAfterMove(app);
}

Expand Down

0 comments on commit ec53367

Please sign in to comment.