Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas resizing accordingly to windows size #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/game/Sketch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ interface StepAssets {
images: Map<Id, p5.Image>
audioMuted: boolean
gamePaused: boolean
width: number
height: number
menuSize: number
}

interface SoundAssets {
Expand All @@ -69,7 +72,9 @@ interface SoundAssets {
// ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

function step(assets: StepAssets) {
const { sketch, gameProject, interpreter, sounds, images, audioMuted, gamePaused } = assets
const { sketch, gameProject, interpreter, sounds, images, audioMuted, gamePaused, width, height, menuSize } = assets

resizeCanvas(width, height, menuSize)

if(!gamePaused) {
window.performance.mark('update-start')
Expand Down Expand Up @@ -222,8 +227,9 @@ const SketchComponent = ({ gameProject, evaluation: initialEvaluation, exit }: S
}

function draw(sketch: p5) {
const { width, height } = canvasResolution(interpreter)
if (!interpreter.object('wollok.game.game').get('running')!.innerBoolean!) setStop(true)
else step({ sketch, gameProject, interpreter, sounds, images, audioMuted, gamePaused })
else step({ sketch, gameProject, interpreter, sounds, images, audioMuted, gamePaused, width, height, menuSize })
}

function keyPressed(sketch: p5) {
Expand Down