extends Sprite2D var WidthBottom:float = 280 var WidthTop:float = 170 var max_height:float = -220 var min_height:float = 135 var rng = RandomNumberGenerator.new() var pos = null func _ready(): new_pos() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): pass func new_pos(): pos = generate_pos() self.set_position(pos) var scale_targ = calc_scale(pos.y) self.scale.x = scale_targ self.scale.y = scale_targ print("pos: " + str(pos) + " scale: " + str(scale)) func generate_pos(): var HeightMod = rng.randf_range(0, 1) var Rand_y = (1 - HeightMod) * (max_height - min_height) + min_height var WidthCurrent = HeightMod * (WidthBottom - WidthTop) + WidthTop var Rand_x = rng.randf_range(-1, 1) * WidthCurrent return Vector2(Rand_x, Rand_y) func calc_scale(y): var proportional = (y + 200) / 300 var converted_value = 1 + (proportional * 0.5) return converted_value