Skip to content

Commit

Permalink
Better lose animation
Browse files Browse the repository at this point in the history
  • Loading branch information
j-m committed Nov 16, 2020
1 parent 609c7b8 commit b53bbdf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 17 deletions.
17 changes: 1 addition & 16 deletions src/components/Playing/End/Lost.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
import React from 'react'
import Confetti from 'react-confetti'

var tweenFunctions = require('tween-functions')

const Lost: React.FunctionComponent = ()=> {
return (
<Confetti
recycle={false}
numberOfPieces={100}
tweenDuration={5000}
tweenFunction={tweenFunctions.linear}
drawShape={context => {
context.font = '2rem serif'
context.textAlign = "center"
context.textBaseline = "middle";
context.fillText('💩', 0, 0)
}}
/>
<div id="lost"/>
)
}

Expand Down
1 change: 0 additions & 1 deletion src/components/Playing/End/Won.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Confetti from 'react-confetti'
const Won: React.FunctionComponent = ()=> {
return (
<Confetti
recycle={false}
numberOfPieces={800}
tweenDuration={5000}
/>
Expand Down
44 changes: 44 additions & 0 deletions src/components/Playing/End/lost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,25 @@ code {
.error {
color:red;
}

#lost{
position: absolute;
top:0;
right:0;
left:0;
bottom:0;

z-index: -1;
opacity: 0;
animation: fadeIn 3s forwards;

background-image: url(./components/Playing/End/lost.svg);
background-repeat: repeat;
background-size: 50rem 50rem;
background-position: 0 0;
}

@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 0.2; }
}

0 comments on commit b53bbdf

Please sign in to comment.