Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Update canvas size and camera zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyAdam committed Feb 12, 2024
1 parent 75c4e42 commit 7fb8c96
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/client/src/app/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export function Canvas(params: Params) {
useEffect(() => {
if (!game) return;
game.setScreenSize(screen);
const canvas = canvasRef.current;
if (!canvas) return;
canvas.width = screen.width;
canvas.height = screen.height;
}, [game, screen]);

useEffect(() => {
Expand All @@ -120,8 +124,6 @@ export function Canvas(params: Params) {
<canvas
ref={canvasRef}
className="grid-bg h-full w-full"
height={screen.height}
width={screen.width}
/>
);
}
2 changes: 1 addition & 1 deletion packages/client/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function RootLayout({
}) {
return (
<SharedStateProvider>
<html lang="en" className="h-full">
<html lang="en" className="h-full text-[12px] sm:text-base">
<body className={`h-full font-sans ${inter.variable}`}>{children}</body>
</html>
</SharedStateProvider>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function HomePage() {
</div>
</div>
))}
{(api.scores?.length ?? 0 > 5) && (
{(api.scores?.length ?? 0) > 5 && (
<span className="opacity-40">
... {api.scores?.length ?? 0 - 5} more players
</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/lib/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Game {
private canvas: HTMLCanvasElement | null = null;
time: TimeManager;
isSprinting = false;
camera: Camera = { offset: { x: 0, y: 0 }, zoom: 2 };
camera: Camera = { offset: { x: 0, y: 0 }, zoom: 1.5 };
cursor: Position = { x: 0, y: 0 };
screen = { width: 0, height: 0 };
c: CanvasRenderingContext2D | undefined;
Expand Down

0 comments on commit 7fb8c96

Please sign in to comment.