Advertisement
Guest User

Code

a guest
Oct 19th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tileSize = 16;
  2. var planks = "image";
  3. var world = [];
  4. var canvas, ctx;
  5. function init(){
  6.     canvas = $("<canvas id = 'canvas'></canvas>")[0];
  7.     ctx = canvas.getContext('2d');
  8.     ctx.imageSmoothingEnabled = false;
  9.     $('body').append(canvas);
  10.     $('body').css({
  11.         "overflow": "hidden"
  12.     });
  13.     $('canvas').css({
  14.         "width": $(window).width(),
  15.         "height": $(window).height(),
  16.         "position": "absolute",
  17.         "top": "0",
  18.         "left": "0",
  19.         "image-rendering": "optimizeSpeed"
  20.     });
  21.     generateWorld();
  22. }
  23. function draw(loc, x, y){
  24.     var img = new Image();
  25.     img.src = "./textures/" + loc + ".png";
  26.     img.width = tileSize;
  27.     img.height = tileSize;
  28.     ctx.drawImage(img, x, y);
  29.     console.log(img);
  30. }
  31. function generateWorld(){
  32.     for(x = 0; x < 1920; x++){
  33.         world[x] = new Array();
  34.         for(y = 0; y < 1080; y++){
  35.             world[x][y] = 1;
  36.         }
  37.     }
  38. }
  39. function main(){
  40.     init();
  41.     for(x = 0; x < 120; x++){
  42.         for(y = 0; y < 60; y++){
  43.             draw(image, x * tileSize, y * tileSize);
  44.         }
  45.     }
  46. }
  47. $(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement