Skip to content

Instantly share code, notes, and snippets.

@andresgcarmona
Last active December 30, 2022 18:52
Show Gist options
  • Save andresgcarmona/519854bf447185ddcee2cd8fb9921564 to your computer and use it in GitHub Desktop.
Save andresgcarmona/519854bf447185ddcee2cd8fb9921564 to your computer and use it in GitHub Desktop.
HTML5 Game Development Canvas
const setup = function() {
var body = document.getElementById('body');
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
body.appendChild(canvas);
const onImageLoad = function() {
console.log('Image loaded!...');
ctx.drawImage(img, 192, 192);
};
img = new Image();
img.onload = onImageLoad;
img.src = '/media/img/gamedev/ralphyrobot.png';
};
setup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment