Skip to content

Instantly share code, notes, and snippets.

@melcor76

melcor76/main.js Secret

Last active December 3, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melcor76/0a36716c8e51e0a44d78b7388a62da70 to your computer and use it in GitHub Desktop.
Save melcor76/0a36716c8e51e0a44d78b7388a62da70 to your computer and use it in GitHub Desktop.
js-tetris - get canvas
const canvas = document.getElementById('board');
const ctx = canvas.getContext('2d');
// Calculate size of canvas from constants.
ctx.canvas.width = COLS * BLOCK_SIZE;
ctx.canvas.height = ROWS * BLOCK_SIZE;
// Scale blocks
ctx.scale(BLOCK_SIZE, BLOCK_SIZE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment