Compare commits

...

2 Commits

Author SHA1 Message Date
7253f41cee robot wanderer and liberation only once 2024-09-01 14:12:03 +00:00
e0293db640 Adding procedural textures to the ground 2024-09-01 15:30:51 +02:00
22 changed files with 405 additions and 29 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

BIN
assets/texture/sky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

View File

@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dtvde6oxrfuk1" uid="uid://c84bc7d0f8gtn"
path="res://.godot/imported/ground.jpg-2eec989771def1cab2ea361da548425a.ctex" path="res://.godot/imported/sky.png-797942cf14c3d3c2fe0d423f60874e07.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/texture/ground.jpg" source_file="res://assets/texture/sky.png"
dest_files=["res://.godot/imported/ground.jpg-2eec989771def1cab2ea361da548425a.ctex"] dest_files=["res://.godot/imported/sky.png-797942cf14c3d3c2fe0d423f60874e07.ctex"]
[params] [params]
@ -21,7 +21,7 @@ compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=true mipmaps/generate=false
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bkwi6yurko7gm"
path="res://.godot/imported/sol_gamejam_fleurs.png-6738458a238310dbe8f60c5cf63411e2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/texture/sol_gamejam_fleurs.png"
dest_files=["res://.godot/imported/sol_gamejam_fleurs.png-6738458a238310dbe8f60c5cf63411e2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6h5ieh6ba7re"
path="res://.godot/imported/sol_gamejam_mort.png-7c2094d2cb902ffcfaa9567b3e7302ae.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/texture/sol_gamejam_mort.png"
dest_files=["res://.godot/imported/sol_gamejam_mort.png-7c2094d2cb902ffcfaa9567b3e7302ae.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c85s1vwryvngb"
path="res://.godot/imported/sol_gamejam_normal.png-1de8f8345ab1c6fba1ed806c59d2001e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/texture/sol_gamejam_normal.png"
dest_files=["res://.godot/imported/sol_gamejam_normal.png-1de8f8345ab1c6fba1ed806c59d2001e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://qpdlnll5pihe"] [gd_scene load_steps=7 format=3 uid="uid://qpdlnll5pihe"]
[ext_resource type="Script" path="res://scripts/planter.gd" id="1_l7lry"] [ext_resource type="Script" path="res://scripts/planter.gd" id="1_l7lry"]
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="2_7h3ga"] [ext_resource type="Script" path="res://scripts/plant_type.gd" id="2_7h3ga"]
[ext_resource type="Resource" uid="uid://bgi2lo7kb3d2v" path="res://objects/plant_types/chardon.tres" id="3_lgbrc"] [ext_resource type="Resource" uid="uid://bgi2lo7kb3d2v" path="res://objects/plant_types/chardon.tres" id="3_lgbrc"]
[ext_resource type="Resource" uid="uid://dnahox31xqy6l" path="res://objects/plant_types/peuplier.tres" id="4_tmfl1"] [ext_resource type="Resource" uid="uid://dnahox31xqy6l" path="res://objects/plant_types/peuplier.tres" id="4_tmfl1"]
[ext_resource type="Resource" uid="uid://b6ufxuqdcgwmx" path="res://objects/plant_types/chene.tres" id="5_j34av"] [ext_resource type="Resource" uid="uid://b6ufxuqdcgwmx" path="res://objects/plant_types/chene.tres" id="5_j34av"]
[ext_resource type="PackedScene" uid="uid://bp3c63qgkmi6o" path="res://objects/Robot.tscn" id="6_of7ri"]
[node name="Planter" type="Node2D"] [node name="Planter" type="Node2D"]
y_sort_enabled = true y_sort_enabled = true
@ -14,3 +15,12 @@ plants = Array[ExtResource("2_7h3ga")]([ExtResource("3_lgbrc"), ExtResource("4_t
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
wait_time = 0.2 wait_time = 0.2
one_shot = true one_shot = true
[node name="Robot" parent="." instance=ExtResource("6_of7ri")]
position = Vector2(0, -64)
[node name="RobotSeed" type="Sprite2D" parent="Robot"]
position = Vector2(0, 63)
scale = Vector2(0.5, 0.5)
[connection signal="Planted" from="Robot" to="." method="_on_robot_planted"]

31
objects/Robot.tscn Normal file
View File

@ -0,0 +1,31 @@
[gd_scene load_steps=5 format=3 uid="uid://bp3c63qgkmi6o"]
[ext_resource type="Script" path="res://scripts/robot.gd" id="1_4eix8"]
[ext_resource type="Texture2D" uid="uid://b11jyrkhw7ebp" path="res://icon.svg" id="2_8ulyj"]
[ext_resource type="PackedScene" uid="uid://dyuqq8v1tckrv" path="res://objects/Wanderer.tscn" id="2_mhqh4"]
[sub_resource type="SpriteFrames" id="SpriteFrames_jlahh"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_8ulyj")
}],
"loop": true,
"name": &"Walk",
"speed": 5.0
}]
[node name="Robot" type="Node2D"]
script = ExtResource("1_4eix8")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_jlahh")
animation = &"Walk"
[node name="Planting" type="Timer" parent="."]
one_shot = true
[node name="Wanderer" parent="." node_paths=PackedStringArray("node_to_move") instance=ExtResource("2_mhqh4")]
node_to_move = NodePath("..")
[connection signal="timeout" from="Planting" to="." method="_on_planting_timeout"]

12
objects/Wanderer.tscn Normal file
View File

@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://dyuqq8v1tckrv"]
[ext_resource type="Script" path="res://scripts/wanderer.gd" id="1_53svd"]
[node name="Wanderer" type="Node"]
script = ExtResource("1_53svd")
[node name="NewTarget" type="Timer" parent="."]
one_shot = true
autostart = true
[connection signal="timeout" from="NewTarget" to="." method="_on_new_target_timeout"]

View File

@ -4,7 +4,7 @@
[ext_resource type="Theme" uid="uid://dnebunkx13tbr" path="res://assets/gui/Text.tres" id="2_n5opx"] [ext_resource type="Theme" uid="uid://dnebunkx13tbr" path="res://assets/gui/Text.tres" id="2_n5opx"]
[ext_resource type="Texture2D" uid="uid://dpfe11wn04ntd" path="res://assets/gui/icons/watering-soil.svg" id="3_4sryb"] [ext_resource type="Texture2D" uid="uid://dpfe11wn04ntd" path="res://assets/gui/icons/watering-soil.svg" id="3_4sryb"]
[ext_resource type="Texture2D" uid="uid://be2uusaqcpcpd" path="res://assets/gradients/Fertility.tres" id="4_5omu3"] [ext_resource type="Texture2D" uid="uid://be2uusaqcpcpd" path="res://assets/gradients/Fertility.tres" id="4_5omu3"]
[ext_resource type="PackedScene" uid="uid://qjwtbyq2c87m" path="res://objects/gui/Stats_area.tscn" id="4_wwqbk"] [ext_resource type="PackedScene" path="res://objects/gui/Stats_area.tscn" id="4_wwqbk"]
[ext_resource type="Texture2D" uid="uid://cwowpvsoo3dey" path="res://assets/gradients/Water.tres" id="5_hwfmn"] [ext_resource type="Texture2D" uid="uid://cwowpvsoo3dey" path="res://assets/gradients/Water.tres" id="5_hwfmn"]
[ext_resource type="Texture2D" uid="uid://dgo81cisfryi1" path="res://assets/gui/icons/soil-alt.svg" id="6_4k6c3"] [ext_resource type="Texture2D" uid="uid://dgo81cisfryi1" path="res://assets/gui/icons/soil-alt.svg" id="6_4k6c3"]
[ext_resource type="Texture2D" uid="uid://bdg3ep75da6xd" path="res://assets/gui/icons/tree.svg" id="8_i3l01"] [ext_resource type="Texture2D" uid="uid://bdg3ep75da6xd" path="res://assets/gui/icons/tree.svg" id="8_i3l01"]

View File

@ -1,23 +1,75 @@
[gd_scene load_steps=5 format=3 uid="uid://d3hul8b7hlmj7"] [gd_scene load_steps=14 format=3 uid="uid://d3hul8b7hlmj7"]
[ext_resource type="Script" path="res://scripts/map.gd" id="1_3np0o"] [ext_resource type="Script" path="res://scripts/map.gd" id="1_3np0o"]
[ext_resource type="PackedScene" uid="uid://6ferubyu2uy1" path="res://scenes/Scanners.tscn" id="1_6mlj0"] [ext_resource type="PackedScene" uid="uid://6ferubyu2uy1" path="res://scenes/Scanners.tscn" id="1_6mlj0"]
[ext_resource type="Texture2D" uid="uid://dtvde6oxrfuk1" path="res://assets/texture/ground.jpg" id="3_20ci8"] [ext_resource type="PackedScene" path="res://objects/Animal.tscn" id="4_pkphc"]
[ext_resource type="PackedScene" uid="uid://cj457q2fx5mim" path="res://objects/Animal.tscn" id="4_pkphc"] [ext_resource type="Texture2D" uid="uid://c84bc7d0f8gtn" path="res://assets/texture/sky.png" id="4_uy8vn"]
[ext_resource type="Texture2D" uid="uid://bkwi6yurko7gm" path="res://assets/texture/sol_gamejam_fleurs.png" id="5_6sl35"]
[ext_resource type="Shader" path="res://scripts/shaders/TextureSplit.gdshader" id="5_iqvbx"]
[ext_resource type="Texture2D" uid="uid://6h5ieh6ba7re" path="res://assets/texture/sol_gamejam_mort.png" id="6_wj5l3"]
[ext_resource type="Texture2D" uid="uid://c85s1vwryvngb" path="res://assets/texture/sol_gamejam_normal.png" id="7_iuq0o"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h3thu"]
shader = ExtResource("5_iqvbx")
shader_parameter/data_texture_size = null
shader_parameter/texture_low_threshold = 0.3
shader_parameter/texture_high_threshold = 0.7
shader_parameter/dimension = null
shader_parameter/texture_size = Vector2(384, 216)
shader_parameter/smooth_change_range = 0.15
shader_parameter/texture_low = ExtResource("6_wj5l3")
shader_parameter/texture_medium = ExtResource("7_iuq0o")
shader_parameter/texture_high = ExtResource("5_6sl35")
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_rhtup"]
load_path = "res://.godot/imported/normal.png-c44c610586e914477a8ee139158bfa7e.ctex"
[sub_resource type="Gradient" id="Gradient_u5wcm"]
offsets = PackedFloat32Array(1)
colors = PackedColorArray(0.481789, 0.481789, 0.481789, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_hwe6p"]
gradient = SubResource("Gradient_u5wcm")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4rqj7"]
shader = ExtResource("5_iqvbx")
shader_parameter/data_texture_size = Vector2(1000, 1000)
shader_parameter/texture_low_threshold = 0.3
shader_parameter/texture_high_threshold = 0.711
shader_parameter/dimension = 1
shader_parameter/texture_size = Vector2(100, 100)
shader_parameter/smooth_change_range = 0.0
shader_parameter/texture_medium = SubResource("GradientTexture1D_hwe6p")
[node name="Map" type="Node2D"] [node name="Map" type="Node2D"]
script = ExtResource("1_3np0o") script = ExtResource("1_3np0o")
[node name="Scanners" parent="." instance=ExtResource("1_6mlj0")] [node name="Scanners" parent="." instance=ExtResource("1_6mlj0")]
[node name="OutOfBound" type="Polygon2D" parent="."]
z_index = -3
texture_repeat = 2
texture = ExtResource("4_uy8vn")
texture_scale = Vector2(5, 5)
[node name="Ground" type="Polygon2D" parent="."] [node name="Ground" type="Polygon2D" parent="."]
z_index = -2
texture_repeat = 2
material = SubResource("ShaderMaterial_h3thu")
texture = SubResource("CompressedTexture2D_rhtup")
texture_scale = Vector2(5, 5)
[node name="Fertility" type="Polygon2D" parent="."]
visible = false
z_index = -1 z_index = -1
texture_repeat = 2 texture_repeat = 2
texture = ExtResource("3_20ci8") material = SubResource("ShaderMaterial_4rqj7")
color = Color(1, 1, 1, 0)
texture_scale = Vector2(5, 5) texture_scale = Vector2(5, 5)
polygon = PackedVector2Array(571, 76, 228, 282, 987, 657, 1379, 208) polygon = PackedVector2Array(27, 788, 54, 1452, 1715, 1163, 1439, -501, -416, -340)
[node name="Animals" type="Node" parent="."] [node name="Animals" type="Node2D" parent="."]
y_sort_enabled = true
[node name="Animal" parent="Animals" instance=ExtResource("4_pkphc")] [node name="Animal" parent="Animals" instance=ExtResource("4_pkphc")]
position = Vector2(2121, 394) position = Vector2(2121, 394)

View File

@ -3,13 +3,16 @@ extends Node2D
signal liberated signal liberated
@export var plant_need: String @export var plant_need: String
var libarated := false
func _on_area_2d_area_entered(area: Area2D) -> void: func _on_area_2d_area_entered(area: Area2D) -> void:
var plant = area.get_parent() var plant = area.get_parent()
if plant is Plant: if plant is Plant and not liberated:
if plant_need == plant.parameter.type: if plant_need == plant.parameter.type:
plant.grown.connect(tracked_plant_grew) plant.grown.connect(tracked_plant_grew)
func tracked_plant_grew(): func tracked_plant_grew():
if liberated:
return
print("Liberated !!") print("Liberated !!")
liberated.emit() liberated.emit()

View File

@ -16,7 +16,6 @@ func _process(delta):
if Input.is_action_pressed("grab"): if Input.is_action_pressed("grab"):
var grabbing_movement = mouse_last_global_position - get_global_mouse_position() var grabbing_movement = mouse_last_global_position - get_global_mouse_position()
print(grabbing_movement)
movement += grabbing_movement movement += grabbing_movement
var mouse_pos = get_viewport().get_mouse_position() var mouse_pos = get_viewport().get_mouse_position()

View File

@ -2,16 +2,31 @@ class_name Map
extends Node2D extends Node2D
const OUT_OF_BOUND_DIST = 2000
@export var n_animals_to_liberate := 4 @export var n_animals_to_liberate := 4
func _ready(): func _ready():
var map_size = GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO var map_size = GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO
$Ground.set_polygon(PackedVector2Array([ for polygon in [$Ground, $Fertility]:
Vector2(0,0), polygon.set_polygon(PackedVector2Array([
Vector2(map_size.x, 0), Vector2(0,0),
Vector2(map_size.x, map_size.y), Vector2(map_size.x, 0),
Vector2(0, map_size.y), Vector2(map_size.x, map_size.y),
Vector2(0, map_size.y),
]))
polygon.material.set_shader_parameter("data_texture", GameTerrain.texture)
polygon.material.set_shader_parameter(
"data_texture_size",
GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO
)
$OutOfBound.set_polygon(PackedVector2Array([
Vector2(-OUT_OF_BOUND_DIST,-OUT_OF_BOUND_DIST),
Vector2(map_size.x + OUT_OF_BOUND_DIST, -OUT_OF_BOUND_DIST),
Vector2(map_size.x + OUT_OF_BOUND_DIST, map_size.y + OUT_OF_BOUND_DIST),
Vector2(-OUT_OF_BOUND_DIST, map_size.y + OUT_OF_BOUND_DIST),
])) ]))
func _on_gui_scanner_selected(type : Scanners.Type): func _on_gui_scanner_selected(type : Scanners.Type):

View File

@ -8,6 +8,8 @@ const QUEUE_LENGTH := 6 # ENORME
@onready var plant_scene = preload("res://objects/Plant.tscn") @onready var plant_scene = preload("res://objects/Plant.tscn")
@onready var timer: Timer = $Timer @onready var timer: Timer = $Timer
@onready var robot: Robot = $Robot
@onready var robot_seed: Sprite2D = $Robot/RobotSeed
@export var plants: Array[PlantType] @export var plants: Array[PlantType]
@ -44,15 +46,21 @@ func take_next_seed() -> PlantType:
return plants[plant_ind] return plants[plant_ind]
func _unhandled_input(_event: InputEvent) -> void: func _unhandled_input(_event: InputEvent) -> void:
if Input.is_action_just_pressed("plant") : if Input.is_action_just_pressed("plant") :
var mouse_pos = camera.get_global_mouse_position() var mouse_pos = camera.get_global_mouse_position()
var click_on_map = GameTerrain.is_on_map(mouse_pos) var click_on_map = GameTerrain.is_on_map(mouse_pos)
if can_plant and click_on_map and timer.is_stopped(): if can_plant and click_on_map and robot.state == robot.MoveState.IDLE:
var chosen_type: PlantType = take_next_seed() var next_plant := plants[seed_queue.back()]
var plant = plant_scene.instantiate() robot_seed.texture = next_plant.seed_sprite
add_child(plant) robot.go_to(mouse_pos)
plant.init(chosen_type)
plant.plant(mouse_pos)
timer.start() func _on_robot_planted() -> void:
var chosen_type: PlantType = take_next_seed()
var plant = plant_scene.instantiate()
add_child(plant)
plant.init(chosen_type)
plant.plant(robot.position)
timer.start()
robot_seed.texture = null

47
scripts/robot.gd Normal file
View File

@ -0,0 +1,47 @@
class_name Robot
extends Node2D
enum MoveState { IDLE, MOVING, PLANTING }
const IDLE_SPEED := 75
const MOVE_SPEED := 500
const PLANTING_TIME := 1
const DIST_TO_PLANT_SQR := 100
signal Planted
@onready var wanderer: Wanderer = $Wanderer
@onready var planting: Timer = $Planting
var target_pos := Vector2()
var state := MoveState.IDLE
func _ready() -> void:
wanderer.speed = IDLE_SPEED
wanderer.move = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
match state:
MoveState.IDLE:
wanderer.move = true
MoveState.MOVING:
wanderer.move = false
position += position.direction_to(target_pos) * MOVE_SPEED * delta
if position.distance_squared_to(target_pos) < DIST_TO_PLANT_SQR:
state = MoveState.PLANTING
planting.start(PLANTING_TIME)
MoveState.PLANTING:
wanderer.move = false
func go_to(new_target_pos: Vector2):
state = MoveState.MOVING
target_pos = new_target_pos
func _on_planting_timeout() -> void:
Planted.emit()
state = MoveState.IDLE

View File

@ -0,0 +1,57 @@
shader_type canvas_item;
#define pow2(x) (x * x)
#define iResolution 1.0/SCREEN_PIXEL_SIZE
uniform sampler2D data_texture;
uniform vec2 data_texture_size;
uniform sampler2D texture_low : filter_nearest, repeat_enable;
uniform float texture_low_threshold : hint_range(0, 1) = 0.3;
uniform sampler2D texture_medium : filter_nearest, repeat_enable;
uniform sampler2D texture_high : filter_nearest, repeat_enable;
uniform float texture_high_threshold : hint_range(0, 1) = 0.7;
uniform int dimension;
uniform vec2 texture_size = vec2(100,100);
uniform float smooth_change_range = 0.15;
varying vec2 vert;
void vertex() {
vert = VERTEX;
}
void fragment() {
vec4 pixel_color = texture(data_texture, vert/data_texture_size);
float value = pixel_color.x;
if (dimension == 1) value = pixel_color.y;
if (dimension == 2) value = pixel_color.z;
vec4 color = texture(texture_medium, vert/texture_size);
if (value < texture_low_threshold)
color =
min(
(texture_low_threshold - value) / smooth_change_range,
1.0
) * texture(texture_low, vert/texture_size)
+ (1.0 - min(
(texture_low_threshold - value) / smooth_change_range,
1.0
)
) * texture(texture_medium, vert/texture_size);
if (value > texture_high_threshold)
color =
min(
(value - texture_high_threshold) / smooth_change_range,
1.0
) * texture(texture_high, vert/texture_size)
+ (1.0 - min(
(value - texture_high_threshold) / smooth_change_range,
1.0
)
) * texture(texture_medium, vert/texture_size);
COLOR = color;
}

View File

@ -151,11 +151,29 @@ func get_stat(
func setup_texture( func setup_texture(
levels : Vector3i levels : Vector3i
): ):
var water_noise := generate_noise()
var fertility_noise := generate_noise()
for x in range(0, TERRAIN_SIZE.x) : for x in range(0, TERRAIN_SIZE.x) :
for y in range(0, TERRAIN_SIZE.y): for y in range(0, TERRAIN_SIZE.y):
set_pixel(Vector2i(x,y), levels) set_pixel(
Vector2i(x,y),
Vector3i(
color_value_to_level(water_noise.get_noise_2d(x, y)),
color_value_to_level(fertility_noise.get_noise_2d(x, y)/2),
-5
)
)
update_texture() update_texture()
func generate_noise() -> Noise:
var noise := FastNoiseLite.new()
noise.seed = randi()
noise.fractal_lacunarity = 1
noise.frequency = 0.005
return noise
func update_texture(): func update_texture():
texture.update(image) texture.update(image)

22
scripts/wanderer.gd Normal file
View File

@ -0,0 +1,22 @@
class_name Wanderer
extends Node
const DIST_FROM_MOUSE := 1000.0
@onready var new_target: Timer = $NewTarget
@export var node_to_move: Node2D
@export var speed := 75
@export var move := false
@export var wait_time_min := 1.0
@export var wait_time_max := 2.0
var target_pos := Vector2()
func _process(delta: float) -> void:
if move:
node_to_move.position += node_to_move.position.direction_to(target_pos) * speed * delta
func _on_new_target_timeout() -> void:
target_pos = get_viewport().get_camera_2d().get_global_mouse_position() + (Vector2.RIGHT * DIST_FROM_MOUSE).rotated(randf_range(0, PI))
new_target.start(randf_range(wait_time_min, wait_time_max))