Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Visualization from './Visualization';
import HackerTyper from './HackerTyper';
import FidgetSpinner from './FidgetSpinner';
import FlappyBrick from './flappy-brick/FlappyBrick';
import Race from './Race';
import './App.css';

class App extends Component {
Expand Down Expand Up @@ -113,6 +114,12 @@ class App extends Component {
return <FlappyBrick speed={this.getAverageGamma()} />;
};

renderRace = _ => {
const { data } = this.state;
document.body.style = 'background: white;';
return <Race data={data} speed={this.getAverageAlpha()} />;
};

renderDemoType = _ => {
const { demoType } = this.state;
switch (demoType) {
Expand All @@ -122,6 +129,8 @@ class App extends Component {
return this.renderFidgetSpinner();
case 'flappybrick':
return this.renderFlappyBrick();
case 'race':
return this.renderRace();
default:
return this.renderVisualization();
}
Expand Down Expand Up @@ -164,6 +173,12 @@ class App extends Component {
>
<div className="flappybrick">Flappy Brick</div>
</li>
<li
className={`${demoType === 'race' ? 'active' : ''}`}
onClick={this.handleDemoTypeChange}
>
<div className="race">Race</div>
</li>
<li style={{ float: `right`, display: `flex` }}>
<div onClick={this.subscribeToMuse} disabled={status}>
Connect
Expand Down
58 changes: 58 additions & 0 deletions src/Race.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import styled, { css, keyframes } from 'styled-components';
import c1 from './chow.jpg';
import c2 from './kiser2.jpg';
import rd from './road.jpg';

const movement = keyframes`
from {
transform: translateX(0);
}

to {
transform: translateX(100vw);
}
`;

const animation = props =>
css`
${movement} ${props.speed}s linear infinite;
`;

const Translate = styled.div`
display: inline-block;
animation: ${props => animation(props)};
padding: 2rem 1rem;
font-size: 1.2rem;
height: auto;
align-self: flex-end;
`;

const Kachow = styled.img`
height: 200px;
width: 300px;
`;

const RaceTrack = styled.div`
display: flex;
background-image: url(${rd});
flex-direction: column-reverse:
alight-items: flex-end;
width: 100vw;
height: 720px;
`;

function Race(props) {
return (
<RaceTrack>
<Translate speed={props.speed}>
<Kachow src={c1} />
</Translate>
<Translate speed={20}>
<Kachow src={c2} />
</Translate>
</RaceTrack>
);
}

export default Race;
Binary file added src/chow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/kiser2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/road.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.