Skip to content

Commit 856d76e

Browse files
committed
refactor
1 parent 870600f commit 856d76e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/App.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ const DIRECTION_TICKS = {
3232
LEFT: (x, y) => ({ x: x - 1, y }),
3333
};
3434

35-
const isPosition = (x, y, diffX, diffY) =>
36-
x === diffX && y === diffY;
37-
3835
const getRandomCoordinate = () =>
3936
({
4037
x: Math.floor(Math.random() * GRID_SIZE),
4138
y: Math.floor(Math.random() * GRID_SIZE),
4239
});
4340

41+
const isPosition = (x, y, diffX, diffY) =>
42+
x === diffX && y === diffY;
43+
4444
// TODO make own some, use compose
4545
const isSnake = (x, y, snakeCoordinates) => {
4646
for (var i = 0; i < snakeCoordinates.length; i++) {
@@ -81,15 +81,15 @@ const applySnakePosition = (prevState) => {
8181
};
8282
};
8383

84+
const getIsSnakeEating = ({ snake, snack }) =>
85+
isPosition(snake.coordinates[0].x, snake.coordinates[0].y, snack.coordinate.x, snack.coordinate.y);
86+
8487
const doChangeDirection = (direction) => () => ({
8588
controls: {
8689
direction,
8790
},
8891
});
8992

90-
const getIsSnakeEating = ({ snake, snack }) =>
91-
isPosition(snake.coordinates[0].x, snake.coordinates[0].y, snack.coordinate.x, snack.coordinate.y);
92-
9393
class App extends Component {
9494
constructor(props) {
9595
super(props);

0 commit comments

Comments
 (0)