Merge branch 'main' of https://git.zacharie-guet.fr/zacharie/seeding-planets
This commit is contained in:
@@ -9,8 +9,12 @@ extends Node
|
||||
@export var start_state: PlantData.State = PlantData.State.MATURE
|
||||
@export var random_state := false
|
||||
@export var end_state: PlantData.State = PlantData.State.MATURE
|
||||
@export var camera_speed := 1000.0
|
||||
|
||||
var input_dir := Vector2.ZERO
|
||||
|
||||
func _ready():
|
||||
%Speed.value = camera_speed
|
||||
%ZoomLevel.value = %Camera2D.zoom.x
|
||||
%N.value = n_to_generate
|
||||
%NPerRow.value = n_per_row
|
||||
@@ -19,10 +23,11 @@ func _ready():
|
||||
%RandomizeOffset.value = random_pos_offset
|
||||
generate_plants();
|
||||
|
||||
func _input(_event) -> void:
|
||||
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
%Camera2D.position += 1 / %Camera2D.zoom.x * 10 * input_dir
|
||||
func _unhandled_key_input(_event) -> void:
|
||||
input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
|
||||
func _process(delta):
|
||||
%Camera2D.position += 1 / %Camera2D.zoom.x * camera_speed * delta * input_dir
|
||||
|
||||
func generate_plants():
|
||||
for child in %Plants.get_children():
|
||||
@@ -111,3 +116,11 @@ func _on_random_age_toggled(toggled_on: bool) -> void:
|
||||
|
||||
func _on_end_age_value_changed(value: float) -> void:
|
||||
end_state = int(value) as PlantData.State
|
||||
|
||||
|
||||
func _on_speed_value_changed(value: float) -> void:
|
||||
camera_speed = value
|
||||
|
||||
|
||||
func _on_reset_speed_pressed() -> void:
|
||||
camera_speed = 1000
|
||||
|
||||
@@ -38,6 +38,8 @@ enum OriginType {BRANCH_ORIGIN, MUTATION_ORIGIN, BASE_LEAF_ORIGIN}
|
||||
@export var mutation_weight_gain := 1
|
||||
@export var seed_texture_sets: Array[SeedTextureSet]
|
||||
|
||||
@export var base_y_offset := -50.0
|
||||
|
||||
var rng := RandomNumberGenerator.new()
|
||||
var image: Image = Image.create_empty(IMAGE_WIDTH, IMAGE_HEIGHT, false, Image.FORMAT_RGBA8)
|
||||
var image_center: Vector2i = Vector2(0.5, 1) * Vector2(image.get_size())
|
||||
@@ -130,9 +132,8 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
mutation_weights.append(mutation_weight_base)
|
||||
|
||||
var flipped: bool = rng.randi() % 2 == 0
|
||||
flipped = false
|
||||
|
||||
var base_image_coord = blend_part(image_center, -base_part.root.position, base_part, flipped)
|
||||
var base_image_coord = blend_part(image_center, Vector2(0.0, base_y_offset), base_part, flipped)
|
||||
populate_part(parts_to_place, weight_per_origin_type, mutation_weights, base_part, base_image_coord, flipped)
|
||||
|
||||
texture = ImageTexture.create_from_image(image)
|
||||
|
||||
Reference in New Issue
Block a user