Last active
December 30, 2022 18:52
-
-
Save andresgcarmona/519854bf447185ddcee2cd8fb9921564 to your computer and use it in GitHub Desktop.
HTML5 Game Development Canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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