Fixed vines overlapping with themselves after being extended around the whole planet

This commit is contained in:
RealMelwei 2025-10-03 18:21:46 +02:00
parent c2104f2d24
commit d3a46ee779
2 changed files with 7 additions and 5 deletions

View file

@ -11,13 +11,16 @@ func _on_opened():
func spread():
for dir in [Vector2.UP, Vector2.DOWN, Vector2.RIGHT, Vector2.LEFT]:
if not vine.vine_locations.has(location + dir):
vine.vine_locations.append(location + dir)
if not vine.vine_locations.has(vec_mod(location + dir, grid.num_collumns)):
vine.vine_locations.append(vec_mod(location + dir, grid.num_collumns))
grow_to_next_bud(dir)
func grow_to_next_bud(dir):
var target_offset = Vector2(randf_range(60, 240), randf_range(60, 240))
var target_offset = Vector2(randf_range(60, 240), randf_range(90, 270))
var pos1 = grid.get_world_position(location, offset)
var pos2 = grid.get_world_position(location + dir, target_offset)
var num_seg = floor((pos1-pos2).length() / 96)
await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, true)
func vec_mod(vec : Vector2, modulus : float):
return Vector2(fposmod(vec.x, modulus), fposmod(vec.y, modulus))

View file

@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="1_wxnww"]
[ext_resource type="PackedScene" uid="uid://xrbh432lrjge" path="res://world/grass.tscn" id="2_abvrx"]
[ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://world/grid.gd" id="3_2bhor"]
[ext_resource type="Shader" uid="uid://ptqflyxta2qd" path="res://world/earth.gdshader" id="3_640fc"]
[ext_resource type="Shader" path="res://world/earth.gdshader" id="3_640fc"]
[ext_resource type="PackedScene" uid="uid://djawvtdwp423v" path="res://buildings/room_temple.tscn" id="3_nihcy"]
[ext_resource type="PackedScene" uid="uid://cmofmd0vf3hx3" path="res://buildings/room_haunted_house.tscn" id="4_ml5no"]
[ext_resource type="PackedScene" uid="uid://dliwqqmrxldjh" path="res://buildings/room_bear_trap.tscn" id="4_r4pw8"]
@ -43,6 +43,5 @@ script = ExtResource("3_2bhor")
ground_radius = 3000.0
cell_height = 300.0
num_collumns = 60
debug = true
packed_buildings = Array[PackedScene]([ExtResource("4_r4pw8"), ExtResource("4_ml5no"), ExtResource("6_640fc"), ExtResource("7_abvrx"), ExtResource("3_nihcy"), ExtResource("9_ej0af"), ExtResource("10_640fc")])
metadata/_custom_type_script = "uid://m3vyyfk8gnma"