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

Dynamic canvas size #6

Open
vinnyoodles opened this issue Jan 2, 2018 · 0 comments
Open

Dynamic canvas size #6

vinnyoodles opened this issue Jan 2, 2018 · 0 comments

Comments

@vinnyoodles
Copy link
Owner

Nobody likes playing on a small screen. The canvas should be large enough to play, but small enough so that it is not too pixelated. The canvas size should be a percentage of the screen and should adjust as the window size changes over time.

We'll have to update how we draw the frame.

var size_mod = <fraction of the original frame, this should be greater than 1>
context.drawImage(img, 0, 0, img.width * size_mod, img.height * size_mod);

We'll also have to update the initial canvas size to take into account the window.

function setCanvas(width, height) {
    var canvas = document.getElementById('canvas');
    var modifier = <fraction of the original frame, should be relative to the window size>
    canvas.width = width * modifier;
    canvas.height = height * modifier;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant