Skip to content

Commit d384e57

Browse files
committed
Make max level dots dissapear
1 parent 9aa6482 commit d384e57

File tree

1 file changed

+56
-39
lines changed

1 file changed

+56
-39
lines changed

pages/index.js

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,31 @@ const Dot = ({x, y, type, floating}) => (
3737
)
3838

3939
const Levels = ({current}) => {
40-
return <div style={{
41-
position: 'absolute',
42-
left: `-${width / colors.length + 10}px`,
43-
top: 0,
44-
display: 'flex',
45-
flexDirection: 'column-reverse'
46-
}}>
47-
{colors.map((c, i) => {
48-
return <div key={c} style={{
49-
background: c,
50-
opacity: current >= i ? 1 : 0.2,
51-
width: `${width / colors.length}px`,
52-
height: `${width / colors.length}px`
53-
}} />
54-
})}
55-
</div>
40+
return (
41+
<div
42+
style={{
43+
position: 'absolute',
44+
left: `-${width / colors.length + 10}px`,
45+
top: 0,
46+
display: 'flex',
47+
flexDirection: 'column-reverse'
48+
}}
49+
>
50+
{colors.map((c, i) => {
51+
return (
52+
<div
53+
key={c}
54+
style={{
55+
background: c,
56+
opacity: current >= i ? 1 : 0.2,
57+
width: `${width / colors.length}px`,
58+
height: `${width / colors.length}px`
59+
}}
60+
/>
61+
)
62+
})}
63+
</div>
64+
)
5665
}
5766

5867
class Page extends React.Component {
@@ -152,19 +161,24 @@ class Page extends React.Component {
152161
for (let j = -1; j < 7; j++) {
153162
const l = checkTile(map[i][j])
154163
if (l.length > 2) {
155-
const newColoredDot = l.reduce((min, d) => {
156-
if (d.y > min.y) return d
157-
if (d.y === min.y && d.x < min.x) return d
158-
return min
159-
}, {x: 10, y: -2})
164+
const newColoredDot = l.reduce(
165+
(min, d) => {
166+
if (d.y > min.y) return d
167+
if (d.y === min.y && d.x < min.x) return d
168+
return min
169+
},
170+
{x: 10, y: -2}
171+
)
160172

161-
freshDots.push(
162-
this.newDotAt(
163-
newColoredDot.x,
164-
newColoredDot.y,
165-
newColoredDot.type + 1
173+
if (newColoredDot.type !== colors.length - 1) {
174+
freshDots.push(
175+
this.newDotAt(
176+
newColoredDot.x,
177+
newColoredDot.y,
178+
newColoredDot.type + 1
179+
)
166180
)
167-
)
181+
}
168182
l.forEach((d, i) => {
169183
keep[d.x][d.y] = false
170184
})
@@ -392,18 +406,20 @@ class Page extends React.Component {
392406
background: '#fff'
393407
}}
394408
>
395-
<div style={{
396-
display: this.state.gameover ? 'block' : 'none',
397-
position: 'absolute',
398-
left: '50%',
399-
top: '50%',
400-
transform: 'translate(-50%, -50%)',
401-
fontSize: '50px',
402-
fontFamily: 'Open sans, sans-serif',
403-
whiteSpace: 'nowrap',
404-
color: '#d50000',
405-
fontWeight: 'bold'
406-
}}>
409+
<div
410+
style={{
411+
display: this.state.gameover ? 'block' : 'none',
412+
position: 'absolute',
413+
left: '50%',
414+
top: '50%',
415+
transform: 'translate(-50%, -50%)',
416+
fontSize: '50px',
417+
fontFamily: 'Open sans, sans-serif',
418+
whiteSpace: 'nowrap',
419+
color: '#d50000',
420+
fontWeight: 'bold'
421+
}}
422+
>
407423
GAME OVER
408424
</div>
409425
<Levels current={this.state.level} />
@@ -427,3 +443,4 @@ class Page extends React.Component {
427443
}
428444

429445
export default () => <Page />
446+

0 commit comments

Comments
 (0)