Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import kha.Assets;
- import kha.Framebuffer;
- import kha.Scheduler;
- import kha.System;
- import kha.math.Random;
- class Plant {
- static var soilAcidityRange:Array<Int> = [0, 100];
- static var hotTimeInSecsRange:Array<Int> = [31557600, 31557600 * 5];
- static var coldTimeInSecsRange:Array<Int> = [31557600, 31557600 * 5];
- static var rainGramsPerSecondRange:Array<Int> = [0, 1000];
- static var midHotTimeSunRadiationRange:Array<Int> = [0, 1000];
- static var midColdTimeSunRadiationRange:Array<Int> = [0, 1000];
- var secPercent:Int;
- var intHotTime:Bool = true;
- public function new(secPercent:Int, intHotTime:Bool = true, seed: Int = 22) { // Non randoms in constructor
- if (secPercent < 0 || secPercent > 100) {
- throw "secPercent must be in range of [0, 100]";
- }
- this.secPercent = secPercent;
- this.intHotTime = intHotTime;
- Random.init(seed);
- var soilAcidity = Random.getIn(Plant.soilAcidityRange[0], Plant.soilAcidityRange[1]);
- var hotTimeInSecs = Random.getIn(Plant.hotTimeInSecsRange[0], Plant.hotTimeInSecsRange[1]);
- var coldTimeInSecs = Random.getIn(Plant.coldTimeInSecsRange[0], Plant.coldTimeInSecsRange[1]);
- var rainGramsPerSecond = Random.getIn(Plant.rainGramsPerSecondRange[0], Plant.rainGramsPerSecondRange[1]);
- var midHotTimeSunRadiation = Random.getIn(Plant.midHotTimeSunRadiationRange[0], Plant.midHotTimeSunRadiationRange[1]);
- var midColdTimeSunRadiation = Random.getIn(Plant.midColdTimeSunRadiationRange[0], Plant.midColdTimeSunRadiationRange[1]);
- // Others I will generate random for now
- }
- }
- class Main {
- static function update():Void {}
- static function render(frames:Array<Framebuffer>):Void {
- // var g = backbuffer.g2;
- }
- public static function main() {
- var p = new Plant(20);
- /*System.start({title: "Project", width: 1024, height: 768}, function(_) {
- // Just loading everything is ok for small projects
- Assets.loadEverything(function() {
- // Avoid passing update/render directly,
- // so replacing them via code injection works
- Scheduler.addTimeTask(function() {
- update();
- }, 0, 1 / 60);
- System.notifyOnFrames(function(frames) {
- render(frames);
- });
- });
- });*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement