/client/scripts/data/map.js
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
- define([
- 'jquery',
- 'underscore',
- 'backbone',
- 'util/PRNG', // Pseudo Random Number Generator
- 'util/SimplexNoise', // Simplex Noise
- 'models/planet.model'
- ], function($, _, Backbone, PRNG, SimplexNoise, planetModel){
- var entity = Backbone.Collection.extend({
- model:planetModel,
- initialize: function(){
- var n = 100; //number of spots
- this.PRNG = new PRNG("FUCK THIS SHIT, IAM GOING TO BE A POTATO");
- this.SimplexNoise = new SimplexNoise(this.PRNG);
- var imax = Math.floor(Math.sqrt(n)); // get max side length
- var x = 0;
- for(var i = 0; i< imax; i++){
- for(var j = 0; j< imax; j++){
- var h = this.SimplexNoise.noise(0.1*i, 0.1*j);
- if(h>0.5){
- this.add({id:x});
- x++;
- }
- }
- }
- }
- });
- return entity();
- });