From be1e8a658fec48d423d526a88a824d97da817dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melvin=20Wei=C3=9F?= Date: Fri, 3 Oct 2025 17:09:51 +0200 Subject: [PATCH] Some code cleanup --- vines_petals/bud.gd | 4 ++-- vines_petals/vine.gd | 8 +++++--- vines_petals/vine_inactive.png | Bin 982 -> 1078 bytes world/building_generator.gd | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/vines_petals/bud.gd b/vines_petals/bud.gd index 3886b59..1e4302e 100644 --- a/vines_petals/bud.gd +++ b/vines_petals/bud.gd @@ -1,5 +1,6 @@ class_name Bud extends VineNode signal opened +var img_path func _on_opened(): $AnimatedSprite2D.play("open") @@ -19,5 +20,4 @@ func grow_to_next_bud(dir): 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) - var path = "res://vines_petals/vine_active_green.png" - await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, path, true) + await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, true) diff --git a/vines_petals/vine.gd b/vines_petals/vine.gd index 7328597..7aa7046 100644 --- a/vines_petals/vine.gd +++ b/vines_petals/vine.gd @@ -3,8 +3,9 @@ var petal_location : Vector2 @export var vine_locations : Array[Vector2] @export var bud_resource : PackedScene @onready var grid : Grid = get_tree().get_root().get_node("main/Earth/Grid") +var img_path = "res://vines_petals/vine_active_green.png" -func draw_vine(pos1 : Vector2, pos2 : Vector2, img_path): +func draw_vine(pos1 : Vector2, pos2 : Vector2): var sprite = Sprite2D.new() get_tree().get_root().get_node("main").add_child(sprite) sprite.texture = ResourceLoader.load(img_path) @@ -12,8 +13,9 @@ func draw_vine(pos1 : Vector2, pos2 : Vector2, img_path): sprite.rotation = (pos1 - pos2).angle() + PI/2 sprite.scale *= (pos1 - pos2).length() * 1 / sprite.texture.get_width() sprite.scale.x = 3 + sprite.z_index = -1 -func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vector2, offset2 : Vector2, num_segments: int, img_path, grow_bud = false): +func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vector2, offset2 : Vector2, num_segments: int, grow_bud = false): var pos1 = grid.get_world_position(location1, offset1) var pos2 = grid.get_world_position(location2, offset2) var positions = [] @@ -28,7 +30,7 @@ func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vecto positions.append(center + offset) positions.append(pos2) for i in range(num_segments): - draw_vine(positions[i], positions[i+1], img_path) + draw_vine(positions[i], positions[i+1]) await get_tree().create_timer(0.2).timeout if grow_bud and location2.y > 0: spawn_bud(location2, offset2) diff --git a/vines_petals/vine_inactive.png b/vines_petals/vine_inactive.png index bc9de88393b98f6037be071305005e2dea615b9f..ac1712d405759cfe489d181e688f425afe07bf42 100644 GIT binary patch delta 832 zcmV-G1Hb&%2et^17YZ;41^@s6aIAQ5ks&Aw!TCd8$L(;7`Y2lQ*`1PDG`=EX z(;(5X7zrU3SV%0a#D<0V8zd4IR$^siMcCL7VIv4aq9P)`g;KP=p5L7ry>n*j_V%8s zNbZw7J!hKRd)}Gzp7WlmsZ-})(-^kZlEZ1Z1~=h<5PrZSW=;dH$9p)8BRGI3aVBPt zhi6cCTkas9!YSwo--~})PvdrezCnBN$me(gccTM*Z&uign2mbmX@f_8#AE0H-_zqR zX9xbow1Jg~_fh%LjLvDoiz|F!~fa@CDj~D<>B7xkaeunE}4nWZH5&>3u^x zfLB<5zyRNC3wzGlg=qfKC&=hhTXyf?a zoUr#-w5?V`$)_NM2DHhWfnu-eYv~NHBW8rH6OQ6t)N)JaLBTwujo(ZL$*4r@#`hQx zz?cWP46A1R<=AICXwS8p{t?xOwZSj{p!wE+esL9t`E0X!IHV`#kRYj)*?aK^+E3xL z>1fzT7%Iummti^Wcnj?SHWLn^J!rY#aVzGSu1t1A)%{19Hn_Zutr$?@WHg=wiH(v@clf$=l|-A+ z=pnVjrZkZN#7pcCx(Rym4lXQRRVev?;}5|1%D+hEc2&?#pagx2UrJX&>8=6avxC(2 zK};)3S{ZvV_#5AwTWTGn`MrVm;PN)+8MqrAzNW{~cAVUNf~C0yCxzpvLq~Z4S5Pmo zlY-tA&ZGVpprm_;o3UzYd3{p7Uw}FzDgga=MAJ~G&i{llzX6_81zR_e(yssu0000< KMNUMnLSTa0tB|t* delta 735 zcmV<50wDdi2-XLX7YZN<1^@s6b9#F8ks&Aw!vFvd!vV){sAQ2-b`D?w00031003YB z00031k=I&(OwYhbC6Cvj0007oNkl8$b$=&D$jUQ1H@H3rJun3|e zSV#)Npv4G^Vxbm-g_T(OXIN=tBUUzcqF|?pb}A}bL`1}I(fFCE+4ZG zJehaGCGWdC@6PO*wm7>eiDE`d2l)98Yo62i9&g}(6+D6gaCUhTHCTa4<`>ZFXFQJq zaMmVKgM;`7^Ab@QP|b~C1N zc4ZQOwWTW=+o9%D5kd)l%4VWAYQ`#q$-KeRWDLSNe29A7vVBlBFB#JpQ$RDS(T4FO zrVB9UF>b;+lkVPjIJSfSsMm~7>wMS||MEXtZ|xU1af;9Om?x9EQvr#aN}YWSf1`gF zzM6rq`)Rl*o-rs z6Kco{7#L@_Cy~%QqTUDm!<*4;UPye@bh^T~^;s5e zLd}=d4x7?^3J|YxJPtFA;sab;pLIC$XJ3G`t^Y{J?Y20~pay+`-|DmY=w1NM`bBDf z3iA#nJsC$a{u^gk)yKeSeea;3T;9hjGKq&V{mnWc+KxYdKf0 R%-R3|002ovPDHLkV1gABRnPzc diff --git a/world/building_generator.gd b/world/building_generator.gd index 358191e..d006a55 100644 --- a/world/building_generator.gd +++ b/world/building_generator.gd @@ -25,6 +25,7 @@ func _ready(): if initial_spawn_protection and 43 <= collumn and collumn <= 49: continue var building = randomize_building() + building.z_index = -2 if grid.add_building_to_collumn(building, collumn): break