Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. function Boulder(x,y,width,height,img)
  2. {
  3. this.x = x;
  4. this.y = y;
  5. this.width = width;
  6. this.height = height;
  7. this.img = img;
  8.  
  9. this.draw = function(){
  10. ctx.drawImage(this.img, this.x, this.y, this.width, this.height);
  11. }
  12. }
  13.  
  14. var boulderArray = [];
  15.  
  16. function createBoulders()
  17. {
  18. boulderArray.push(new Boulder(canvas.width/2, 50, 50,50,boulderImg),
  19. new Boulder(canvas.width/2, 220, 50,50,boulderImg)
  20. );
  21. }
  22. createBoulders();
  23.  
  24. boulderArray.forEach(draw);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement