PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/client/scripts/data/map.js

https://bitbucket.org/Fenchurch/isoel
JavaScript | 39 lines | 29 code | 10 blank | 0 comment | 3 complexity | acf826320a713ae15b6fbd0fd3f213de MD5 | raw file
Possible License(s): GPL-2.0, WTFPL, MIT, BSD-3-Clause, Apache-2.0, 0BSD
  1. define([
  2. 'jquery',
  3. 'underscore',
  4. 'backbone',
  5. 'util/PRNG', // Pseudo Random Number Generator
  6. 'util/SimplexNoise', // Simplex Noise
  7. 'models/planet.model'
  8. ], function($, _, Backbone, PRNG, SimplexNoise, planetModel){
  9. var entity = Backbone.Collection.extend({
  10. model:planetModel,
  11. initialize: function(){
  12. var n = 100; //number of spots
  13. this.PRNG = new PRNG("FUCK THIS SHIT, IAM GOING TO BE A POTATO");
  14. this.SimplexNoise = new SimplexNoise(this.PRNG);
  15. var imax = Math.floor(Math.sqrt(n)); // get max side length
  16. var x = 0;
  17. for(var i = 0; i< imax; i++){
  18. for(var j = 0; j< imax; j++){
  19. var h = this.SimplexNoise.noise(0.1*i, 0.1*j);
  20. if(h>0.5){
  21. this.add({id:x});
  22. x++;
  23. }
  24. }
  25. }
  26. }
  27. });
  28. return entity();
  29. });