Advertisement
ahmad_zizo

test2: arraycreator

Jan 26th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. var ArrayCreator = class({
  2. constructor: function(name,height,width){
  3. this.name = name;
  4. this.height = height;
  5. this.width = width;
  6. },
  7. create2DArray: function(){
  8. for (var i = 0; i < this.height; i++) {
  9. this.name[i] = [];
  10. }
  11. for (i = 0; i < this.h; i++) {
  12. for (var j = 0; j < this.width; j++) {
  13. this.name[i][j] = 0;
  14. }
  15. }
  16. }
  17. toBlocks: function(name2) {
  18. for (var i = 0; i < 2 * this.width + 1; i++) {
  19. this.name[0][i] = 1;
  20. this.name[2 * this.height][i] = 1;
  21. this.name[i][0] = 1;
  22. this.name[i][this.width * 2] = 1;
  23. }
  24. var x, y;
  25. for (i = 0; i < this.height; i++) {
  26. for (var j = 0; j < this.width; j++) {
  27. x = i * 2 + 1;
  28. y = j * 2 + 1;
  29. this.name[x + 1][y] = (name2[i][j] & S) === 0;
  30. if (name2[i][j] & E)
  31. this.name[x + 1][y + 1] = ((name2[i][j] | name2[i][j + 1]) & S) === 0;
  32. else
  33. this.name[x][y + 1] = this.name[x + 1][y + 1] = 1;
  34. }
  35. }
  36. }
  37.  
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement