-
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.
- Loading branch information
1 parent
ad08ede
commit 6c4e4ec
Showing
33 changed files
with
689 additions
and
221 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a { | ||
color: inherit; | ||
text-decoration: none; | ||
} |
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,25 +1,28 @@ | ||
// App.tsx | ||
|
||
import { | ||
createBrowserRouter, | ||
RouterProvider | ||
createBrowserRouter, | ||
RouterProvider | ||
} from 'react-router-dom' | ||
import { Game } from './Game' | ||
import { Home } from './Home' | ||
import './App.css' | ||
import { CssBaseline } from '@material-ui/core' | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: <Home /> | ||
}, | ||
{ | ||
path: '/gitclicker', | ||
element: <Game /> | ||
} | ||
{ | ||
path: '/', | ||
element: <Home /> | ||
}, | ||
{ | ||
path: '/gitclicker', | ||
element: <Game /> | ||
} | ||
]) | ||
|
||
export default function App() { | ||
return ( | ||
<RouterProvider router={router} /> | ||
) | ||
return ( | ||
<> | ||
<CssBaseline /> | ||
<RouterProvider router={router} /> | ||
</> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
.game { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: flex-start; | ||
} | ||
|
||
.game .left { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding: 2rem 5rem; | ||
margin: 4rem 2rem; | ||
} | ||
|
||
.game .center { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
flex: 1; | ||
padding: 2rem 5rem; | ||
margin: 4rem 0; | ||
} | ||
|
||
.game .right { | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1; | ||
align-items: flex-start; | ||
padding: 2rem 2rem; | ||
margin: 4rem 2rem; | ||
} |
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,78 @@ | ||
import { useEffect, useState } from 'react' | ||
import './Game.css' | ||
import { Paper } from '@material-ui/core' | ||
import { Gitcoin } from '../Gitcoin' | ||
import { Score } from '../Score' | ||
import { Store } from '../Store' | ||
import items from '../../items.ts' | ||
import { Item, OwnedItems } from '../../type' | ||
import { Navbar } from '../layout/Navbar' | ||
import { Skills } from '../Skills' | ||
|
||
export function Game() { | ||
const [lines, setLines] = useState(0) | ||
const [linesPerMillisecond, setLinesPerMillisecond] = useState(0) | ||
|
||
const [ownedItems, setOwnedItems] = useState<OwnedItems>({}) | ||
|
||
useEffect(() => { | ||
const interval = setInterval(() => { | ||
setLines(lines + linesPerMillisecond) | ||
}, 100) | ||
|
||
return () => clearInterval(interval) | ||
}, [lines, linesPerMillisecond]) | ||
|
||
useEffect(() => { | ||
let count = 0 | ||
|
||
Object.keys(ownedItems).forEach(name => { | ||
const item = items.find(element => element.name === name) | ||
|
||
if(item != null) { | ||
count += item.linesPerMillisecond * ownedItems[name] | ||
} | ||
}) | ||
|
||
setLinesPerMillisecond(count) | ||
}, [ownedItems]) | ||
|
||
|
||
const handleClick = () => { | ||
setLines(lines + 1) | ||
} | ||
|
||
const handleBuy = (item: Item) => { | ||
setLines(lines - item.price) | ||
setOwnedItems({ | ||
...ownedItems, | ||
[item.name]: (ownedItems[item.name] || 0) + 1 | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<Navbar /> | ||
<main className="game"> | ||
<Paper elevation={3} className="left"> | ||
<Score | ||
lines={Math.ceil(lines)} | ||
linesPerSecond={Math.ceil(linesPerMillisecond * 10)} | ||
/> | ||
<Gitcoin onClick={handleClick} /> | ||
</Paper> | ||
|
||
<Paper elevation={3} className="center"> | ||
<Skills skills={ownedItems} /> | ||
</Paper> | ||
|
||
<Paper elevation={3} className="right"> | ||
<Store | ||
lines={Math.ceil(lines)} | ||
onBuy={handleBuy} | ||
/> | ||
</Paper> | ||
</main> | ||
</> | ||
) | ||
} |
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 @@ | ||
export { Game } from './Game' |
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 @@ | ||
export { Gitcoin } from './Gitcoin' |
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,13 +1,50 @@ | ||
// ./src/components/Home.tsx | ||
|
||
import Button from '@material-ui/core/Button' | ||
import Grid from '@material-ui/core/Grid' | ||
import Typography from '@material-ui/core/Typography' | ||
import { makeStyles } from '@material-ui/core/styles' | ||
import Container from '@material-ui/core/Container' | ||
import { Navbar } from './layout/Navbar' | ||
import { Link } from 'react-router-dom' | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
heroContent: { | ||
backgroundColor: theme.palette.background.paper, | ||
padding: theme.spacing(8, 0, 6), | ||
}, | ||
heroButtons: { | ||
marginTop: theme.spacing(4), | ||
}, | ||
})) | ||
|
||
export function Home() { | ||
return ( | ||
<div> | ||
<h1 className="main-title">Welcome to gitclicker!</h1> | ||
const classes = useStyles() | ||
|
||
<Link to="/gitclicker">Start a new Game</Link> | ||
</div> | ||
return ( | ||
<> | ||
<Navbar /> | ||
<main> | ||
<div className={classes.heroContent}> | ||
<Container maxWidth="sm"> | ||
<Typography component="h1" variant="h2" align="center" color="textPrimary" gutterBottom> | ||
Gitclicker | ||
</Typography> | ||
<Typography variant="h5" align="center" color="textSecondary" paragraph> | ||
Dogs have boundless enthusiasm but no sense of shame. I should have a dog as a life coach. | ||
</Typography> | ||
<div className={classes.heroButtons}> | ||
<Grid container spacing={2} justifyContent="center"> | ||
<Grid item> | ||
<Link to="/gitclicker"> | ||
<Button variant="contained" color="primary"> | ||
Play | ||
</Button> | ||
</Link> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
</Container> | ||
</div> | ||
</main> | ||
</> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.