Skip to content

Commit b590666

Browse files
changed size of controlsBtn
1 parent 11d1e7e commit b590666

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/components/layout/SnakeGame.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const SnakeGame = () => {
66
const { gameStatus } = useSnake();
77

88
return (
9-
<div className="max-h-screen min-h-screen w-screen bg-slate-300">
9+
<div className="max-h-dvh min-h-dvh w-full bg-slate-300">
1010
{/* game home screen */}
1111
{gameStatus === "idle" && <GameHomeScreen />}
1212

src/components/reusable/GameBtnControls.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const GameBtnControls = ({
99
}) => {
1010
return (
1111
<div className="bntControls flex w-full flex-col items-center justify-center py-4">
12-
<div className="grid w-1/3 grid-cols-3 grid-rows-3 place-content-center place-items-center rounded-md border-2 border-purple-700 p-2 text-slate-300">
12+
<div className="grid grid-cols-3 grid-rows-3 place-content-center place-items-center rounded-md border-2 border-purple-700 p-2 text-slate-300">
1313
<ControlBtn
1414
rotate={0}
1515
handleControlsBtnClick={handleControlsBtnClick}
@@ -79,6 +79,7 @@ const ControlBtn = ({
7979
fill="currentColor"
8080
viewBox="0 0 56 56"
8181
transform={`rotate(${rotate + 90})`}
82+
width={80}
8283
>
8384
<path d="M 46.6445 11.7109 C 46.6445 9.9766 45.3320 8.8984 43.2695 8.8984 L 12.7305 8.8750 C 10.6914 8.8750 9.3555 9.9531 9.3555 11.6875 C 9.3555 12.6250 9.7773 13.3984 10.2695 14.3828 L 24.8711 44.5000 C 25.8554 46.4922 26.7695 47.1250 28.0117 47.1250 C 29.2305 47.1250 30.1445 46.4922 31.1289 44.5000 L 45.7305 14.3828 C 46.2227 13.4219 46.6445 12.6484 46.6445 11.7109 Z"></path>
8485
</svg>

src/components/snake/GamePlayBoard.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const GamePlayBoard = () => {
3131
const snakeRef = useRef(isSnakeRunning);
3232

3333
// variables
34-
let cellSize = CanvasWidth / 20;
34+
let cellSize = CanvasWidth / 16;
3535
let snake = [
3636
{ x: cellSize * 5, y: cellSize * 4 },
3737
{ x: cellSize * 4, y: cellSize * 4 },
3838
{ x: cellSize * 3, y: cellSize * 4 },
3939
];
40-
let snakeFood = { x: cellSize * 10, y: cellSize * 10 };
40+
let snakeFood = { x: cellSize * 7, y: cellSize * 7 };
4141
let snakeColor = 0;
4242
let frame = 0;
4343

@@ -56,7 +56,7 @@ const GamePlayBoard = () => {
5656
snakeColor,
5757
});
5858

59-
if (frame % 10 === 0) {
59+
if (frame % 8 === 0) {
6060
const newHeadPosition = calculateNewHeadPosition();
6161

6262
snake.unshift(newHeadPosition);
@@ -106,9 +106,9 @@ const GamePlayBoard = () => {
106106
// if snake touches to the boundary of canvas
107107
if (
108108
snakeHead.x < 0 ||
109-
snakeHead.x > CanvasWidth ||
109+
snakeHead.x >= CanvasWidth ||
110110
snakeHead.y < 0 ||
111-
snakeHead.y > CanvasWidth
111+
snakeHead.y >= CanvasWidth
112112
) {
113113
gameOver();
114114
return;
@@ -293,7 +293,7 @@ const GamePlayBoard = () => {
293293
};
294294

295295
return (
296-
<div className="gameScreen flex min-h-screen flex-col justify-between gap-2 border bg-gray-800">
296+
<div className="gameScreen flex max-h-svh min-h-svh w-full flex-col justify-between gap-2 overflow-hidden border bg-gray-800">
297297
{/* Game score and controls */}
298298
<div className="scores flex min-h-[50px] w-full justify-between border border-slate-500 p-2">
299299
{/* Back and sound controls */}

vite.config.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { defineConfig } from 'vite'
2-
import react from '@vitejs/plugin-react'
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7-
})
7+
server: {
8+
host: "0.0.0.0",
9+
port: 5173,
10+
},
11+
});

0 commit comments

Comments
 (0)