Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tileSize = 16;
- var planks = "image";
- var world = [];
- var canvas, ctx;
- function init(){
- canvas = $("<canvas id = 'canvas'></canvas>")[0];
- ctx = canvas.getContext('2d');
- ctx.imageSmoothingEnabled = false;
- $('body').append(canvas);
- $('body').css({
- "overflow": "hidden"
- });
- $('canvas').css({
- "width": $(window).width(),
- "height": $(window).height(),
- "position": "absolute",
- "top": "0",
- "left": "0",
- "image-rendering": "optimizeSpeed"
- });
- generateWorld();
- }
- function draw(loc, x, y){
- var img = new Image();
- img.src = "./textures/" + loc + ".png";
- img.width = tileSize;
- img.height = tileSize;
- ctx.drawImage(img, x, y);
- console.log(img);
- }
- function generateWorld(){
- for(x = 0; x < 1920; x++){
- world[x] = new Array();
- for(y = 0; y < 1080; y++){
- world[x][y] = 1;
- }
- }
- }
- function main(){
- init();
- for(x = 0; x < 120; x++){
- for(y = 0; y < 60; y++){
- draw(image, x * tileSize, y * tileSize);
- }
- }
- }
- $(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement