Guest User

Untitled

a guest
Apr 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Setting Offset of Draggable DIV
  2. offset.left = Math.round((my.x*tile.width)-(screen.width/2));
  3.             if((my.y % 2) == 0){
  4.                 offset.left = Math.round((my.x*tile.width)-(screen.width/2)+(tile.width/2));
  5.             }
  6. offset.top  = Math.round((my.y*(tile.height/2))-(screen.height/2)+(tile.height/2));
  7.  
  8.      $('screen').append('<div class="map" style="left:'+(offset.left*-1)+'px;top:'+(offset.top*-1)+'px"></div>');
  9.            
  10. //Calculate Start X/Y End X/Y to draw tiles
  11.  var startX = Math.floor(offset.left/tile.width)-1; //+1 and -1 makes one line more than needed to display
  12.             var endX = Math.round((offset.left+screen.width)/tile.width)+1;
  13.             var startY =Math.floor(offset.top/tile.height)*2-1;
  14.             var endY =Math.round((offset.top+screen.height)/tile.height)*2+1;
  15.  
  16.  for(var y = startY;y<=endY;y++){
  17.                 for(var x= startX;x<=endX;x++){
  18. //draw tile
  19. }
  20. }
Add Comment
Please, Sign In to add comment