Advertisement
GabeLinux

Web - 5 - 1

Jan 30th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const WIDTH = 720
  2. const HEIGHT = 480
  3.  
  4. const canvas = document.querySelector('#game')
  5. canvas.width = WIDTH
  6. canvas.height = HEIGHT
  7.  
  8. const ctx = canvas.getContext('2d')
  9.  
  10. const backdrop = new Image()
  11. backdrop.src = 'images/backdrop.png'
  12.  
  13. backdrop.addEventListener('load', () => {
  14.   drawImages()
  15. })
  16.  
  17. function drawImages() {
  18.   ctx.drawImage(backdrop, 0, 0, WIDTH, HEIGHT)
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement