@@ -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-
3835const 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
4545const 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+
8487const 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-
9393class App extends Component {
9494 constructor ( props ) {
9595 super ( props ) ;
0 commit comments