diff --git a/src/useCursor/useCursor.ts b/src/useCursor/useCursor.ts index d18648a..c3ae358 100755 --- a/src/useCursor/useCursor.ts +++ b/src/useCursor/useCursor.ts @@ -15,15 +15,18 @@ export function useCursor( const lastMovedDirectionRef = useRef("up"); const nextDirectionRef = useRef(null); - const initSnake = () => { - const centerR = Math.floor(rows / 2); - const centerC = Math.floor(cols / 2); - - const initialBody: SnakeBody = [ - { r: centerR, c: centerC }, - { r: centerR + 1, c: centerC }, - { r: centerR + 2, c: centerC }, - ]; + const initSnake = () => { + const centerR = Math.floor(rows / 2); + const centerC = Math.floor(cols / 2); + + const initialBody: SnakeBody = [ + { r: centerR, c: centerC }, + { r: centerR + 1, c: centerC }, + { r: centerR + 2, c: centerC }, + { r: centerR + 3, c: centerC }, + { r: centerR + 4, c: centerC }, + { r: centerR + 5, c: centerC }, + ]; setSnakeBody(initialBody); snakeBodyRef.current = initialBody; diff --git a/src/useGame/useSnake.ts b/src/useGame/useSnake.ts index 4264a4c..76d9b46 100755 --- a/src/useGame/useSnake.ts +++ b/src/useGame/useSnake.ts @@ -15,14 +15,17 @@ export function useSnake( const lastMovedDirectionRef = useRef("up"); const initSnake = () => { - const centerR = Math.floor(rows / 2); - const centerC = Math.floor(cols / 2); - - const initialBody: SnakeBody = [ - { r: centerR, c: centerC }, - { r: centerR + 1, c: centerC }, - { r: centerR + 2, c: centerC }, - ]; + const centerR = Math.floor(rows / 2); + const centerC = Math.floor(cols / 2); + + const initialBody: SnakeBody = [ + { r: centerR, c: centerC }, + { r: centerR + 1, c: centerC }, + { r: centerR + 2, c: centerC }, + { r: centerR + 3, c: centerC }, + { r: centerR + 4, c: centerC }, + { r: centerR + 5, c: centerC }, + ]; setSnakeBody(initialBody); snakeBodyRef.current = initialBody;