Skip to content

Commit 3658a98

Browse files
committed
Add score
1 parent 10a61fc commit 3658a98

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

pages/index.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Page extends React.Component {
7373
super()
7474
this.state = {
7575
dots: [],
76+
score: 0,
7677
floatingDots: [this.newDot(4, 1), this.newDot(5, 0)],
7778
level: 2,
7879
blocksKilled: 0
@@ -185,6 +186,7 @@ class Page extends React.Component {
185186
}
186187
l.forEach((d, i) => {
187188
keep[d.x][d.y] = false
189+
this.state.score += ((newColoredDot.type + 1) * 5)
188190
})
189191
this.state.blocksKilled++
190192
}
@@ -447,12 +449,26 @@ class Page extends React.Component {
447449
background: '#fff'
448450
}}
449451
>
450-
<div style={{
451-
position: 'relative',
452-
width: '100%',
453-
paddingBottom: '100%',
454-
height: 0
455-
}} />
452+
<div
453+
style={{
454+
position: 'relative',
455+
width: '100%',
456+
paddingBottom: '100%',
457+
height: 0
458+
}}
459+
/>
460+
<div
461+
style={{
462+
position: 'absolute',
463+
fontFamily: 'Open sans, sans-serif',
464+
color: '#aaa',
465+
fontWeight: 'bold',
466+
left: '5%',
467+
top: '5%'
468+
}}
469+
>
470+
SCORE: { this.state.score }
471+
</div>
456472
<div
457473
style={{
458474
display: this.state.gameover ? 'block' : 'none',

0 commit comments

Comments
 (0)