Advertisement
Guest User

Untitled

a guest
Oct 8th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.19 KB | None | 0 0
  1. package;
  2.  
  3.  
  4. import kha.Assets;
  5. import kha.Framebuffer;
  6. import kha.Scheduler;
  7. import kha.System;
  8. import kha.math.Random;
  9.  
  10. class Plant {
  11.     static var soilAcidityRange:Array<Int> = [0, 100];
  12.     static var hotTimeInSecsRange:Array<Int> = [31557600, 31557600 * 5];
  13.     static var coldTimeInSecsRange:Array<Int> = [31557600, 31557600 * 5];
  14.     static var rainGramsPerSecondRange:Array<Int> = [0, 1000];
  15.     static var midHotTimeSunRadiationRange:Array<Int> = [0, 1000];
  16.     static var midColdTimeSunRadiationRange:Array<Int> = [0, 1000];
  17.  
  18.     var secPercent:Int;
  19.     var intHotTime:Bool = true;
  20.  
  21.     public function new(secPercent:Int, intHotTime:Bool = true, seed: Int = 22) { // Non randoms in constructor
  22.         if (secPercent < 0 || secPercent > 100) {
  23.             throw "secPercent must be in range of [0, 100]";
  24.         }
  25.  
  26.         this.secPercent = secPercent;
  27.         this.intHotTime = intHotTime;
  28.  
  29.         Random.init(seed);
  30.  
  31.         var soilAcidity = Random.getIn(Plant.soilAcidityRange[0], Plant.soilAcidityRange[1]);
  32.         var hotTimeInSecs = Random.getIn(Plant.hotTimeInSecsRange[0], Plant.hotTimeInSecsRange[1]);
  33.         var coldTimeInSecs = Random.getIn(Plant.coldTimeInSecsRange[0], Plant.coldTimeInSecsRange[1]);
  34.         var rainGramsPerSecond = Random.getIn(Plant.rainGramsPerSecondRange[0], Plant.rainGramsPerSecondRange[1]);
  35.         var midHotTimeSunRadiation = Random.getIn(Plant.midHotTimeSunRadiationRange[0], Plant.midHotTimeSunRadiationRange[1]);
  36.         var midColdTimeSunRadiation = Random.getIn(Plant.midColdTimeSunRadiationRange[0], Plant.midColdTimeSunRadiationRange[1]);
  37.  
  38.         // Others I will generate random for now
  39.     }
  40. }
  41.  
  42. class Main {
  43.     static function update():Void {}
  44.  
  45.     static function render(frames:Array<Framebuffer>):Void {
  46.         // var g = backbuffer.g2;
  47.     }
  48.  
  49.     public static function main() {
  50.         var p = new Plant(20);
  51.  
  52.         /*System.start({title: "Project", width: 1024, height: 768}, function(_) {
  53.             // Just loading everything is ok for small projects
  54.             Assets.loadEverything(function() {
  55.                 // Avoid passing update/render directly,
  56.                 // so replacing them via code injection works
  57.                 Scheduler.addTimeTask(function() {
  58.                     update();
  59.                 }, 0, 1 / 60);
  60.                 System.notifyOnFrames(function(frames) {
  61.                     render(frames);
  62.                 });
  63.             });
  64.         });*/
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement