Advertisement
Guest User

Untitled

a guest
Oct 9th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.42 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.     var soilAcidity: Int;
  22.     var hotTimeInSecs: Int;
  23.     var coldTimeInSecs: Int;
  24.     var rainGramsPerSecond: Int;
  25.     var midHotTimeSunRadiation: Int;
  26.     var midColdTimeSunRadiation: Int;
  27.  
  28.     public function new(secPercent:Int, intHotTime:Bool = true, seed: Int = 22) { // Non randoms in constructor
  29.         if (secPercent < 0 || secPercent > 100) {
  30.             throw "secPercent must be in range of [0, 100]";
  31.         }
  32.  
  33.         this.secPercent = secPercent;
  34.         this.intHotTime = intHotTime;
  35.  
  36.         Random.init(seed);
  37.  
  38.         this.soilAcidity = Random.getIn(Plant.soilAcidityRange[0], Plant.soilAcidityRange[1]);
  39.         this.hotTimeInSecs = Random.getIn(Plant.hotTimeInSecsRange[0], Plant.hotTimeInSecsRange[1]);
  40.         this.coldTimeInSecs = Random.getIn(Plant.coldTimeInSecsRange[0], Plant.coldTimeInSecsRange[1]);
  41.         this.rainGramsPerSecond = Random.getIn(Plant.rainGramsPerSecondRange[0], Plant.rainGramsPerSecondRange[1]);
  42.         this.midHotTimeSunRadiation = Random.getIn(Plant.midHotTimeSunRadiationRange[0], Plant.midHotTimeSunRadiationRange[1]);
  43.         this.midColdTimeSunRadiation = Random.getIn(Plant.midColdTimeSunRadiationRange[0], Plant.midColdTimeSunRadiationRange[1]);
  44.     }
  45.  
  46.     public function outputPlantData(){
  47.         // Pats vieglakais
  48.     }
  49. }
  50.  
  51. class Main {
  52.     static function update():Void {}
  53.  
  54.     static function render(frames:Array<Framebuffer>):Void {
  55.         // var g = backbuffer.g2;
  56.     }
  57.  
  58.     public static function main() {
  59.         var p = new Plant(20);
  60.         p.outputPlantData();
  61.  
  62.         /*System.start({title: "Project", width: 1024, height: 768}, function(_) {
  63.             // Just loading everything is ok for small projects
  64.             Assets.loadEverything(function() {
  65.                 // Avoid passing update/render directly,
  66.                 // so replacing them via code injection works
  67.                 Scheduler.addTimeTask(function() {
  68.                     update();
  69.                 }, 0, 1 / 60);
  70.                 System.notifyOnFrames(function(frames) {
  71.                     render(frames);
  72.                 });
  73.             });
  74.         });*/
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement