@@ -32,15 +32,15 @@ const DIRECTION_TICKS = {
32
32
LEFT : ( x , y ) => ( { x : x - 1 , y } ) ,
33
33
} ;
34
34
35
- const isPosition = ( x , y , diffX , diffY ) =>
36
- x === diffX && y === diffY ;
37
-
38
35
const getRandomCoordinate = ( ) =>
39
36
( {
40
37
x : Math . floor ( Math . random ( ) * GRID_SIZE ) ,
41
38
y : Math . floor ( Math . random ( ) * GRID_SIZE ) ,
42
39
} ) ;
43
40
41
+ const isPosition = ( x , y , diffX , diffY ) =>
42
+ x === diffX && y === diffY ;
43
+
44
44
// TODO make own some, use compose
45
45
const isSnake = ( x , y , snakeCoordinates ) => {
46
46
for ( var i = 0 ; i < snakeCoordinates . length ; i ++ ) {
@@ -81,15 +81,15 @@ const applySnakePosition = (prevState) => {
81
81
} ;
82
82
} ;
83
83
84
+ const getIsSnakeEating = ( { snake, snack } ) =>
85
+ isPosition ( snake . coordinates [ 0 ] . x , snake . coordinates [ 0 ] . y , snack . coordinate . x , snack . coordinate . y ) ;
86
+
84
87
const doChangeDirection = ( direction ) => ( ) => ( {
85
88
controls : {
86
89
direction,
87
90
} ,
88
91
} ) ;
89
92
90
- const getIsSnakeEating = ( { snake, snack } ) =>
91
- isPosition ( snake . coordinates [ 0 ] . x , snake . coordinates [ 0 ] . y , snack . coordinate . x , snack . coordinate . y ) ;
92
-
93
93
class App extends Component {
94
94
constructor ( props ) {
95
95
super ( props ) ;
0 commit comments