Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

100 lignes
2.0 KiB

  1. define([
  2. 'js/system/globals'
  3. ], function (
  4. globals
  5. ) {
  6. let mRandom = Math.random.bind(Math);
  7. let customRenderer = null;
  8. const renderCustomLoginBg = async (renderer, path) => {
  9. if (!customRenderer) {
  10. await (new Promise(res => {
  11. require([path], loadedModule => {
  12. customRenderer = loadedModule;
  13. res();
  14. });
  15. }));
  16. }
  17. customRenderer(renderer);
  18. };
  19. const renderLoginBackground = renderer => {
  20. const { loginBgGeneratorPath } = globals.clientConfig;
  21. if (loginBgGeneratorPath) {
  22. renderCustomLoginBg(renderer, loginBgGeneratorPath);
  23. return;
  24. }
  25. const { width, height, layers } = renderer;
  26. renderer.setPosition({
  27. x: 0,
  28. y: 0
  29. }, true);
  30. let w = Math.ceil(width / scale) + 1;
  31. let h = Math.ceil(height / scale) + 1;
  32. const midX = ~~(w / 2);
  33. const midY = ~~(h / 2);
  34. const rGrass = 10;
  35. const rBeach = 2;
  36. const rShallow = 3;
  37. const noiseFactor = 3;
  38. let container = layers.tileSprites;
  39. for (let i = 0; i < w; i++) {
  40. for (let j = 0; j < h; j++) {
  41. let tile = 5;
  42. let distance = Math.sqrt(Math.pow(i - midX, 2) + Math.pow(j - midY, 2));
  43. if (distance < rGrass + (Math.random() * noiseFactor))
  44. tile = 3;
  45. else if (distance < rGrass + rBeach + (Math.random() * noiseFactor))
  46. tile = 4;
  47. else if (distance < rGrass + rBeach + rShallow + (Math.random() * noiseFactor))
  48. tile = 53;
  49. let alpha = mRandom();
  50. if ([5, 53].indexOf(tile) > -1)
  51. alpha *= 2;
  52. if (Math.random() < 0.3) {
  53. tile = {
  54. 5: 6,
  55. 3: 0,
  56. 4: 1,
  57. 53: 54
  58. }[tile];
  59. }
  60. let sprite = new PIXI.Sprite(renderer.getTexture('sprites', tile));
  61. alpha = Math.min(Math.max(0.15, alpha), 0.65);
  62. sprite.alpha = alpha;
  63. sprite.position.x = i * scale;
  64. sprite.position.y = j * scale;
  65. sprite.width = scale;
  66. sprite.height = scale;
  67. if (mRandom() < 0.5) {
  68. sprite.position.x += scale;
  69. sprite.scale.x = -scaleMult;
  70. }
  71. container.addChild(sprite);
  72. }
  73. }
  74. };
  75. return renderLoginBackground;
  76. });