mirror of
https://github.com/csd4ni3l/fishy-fingers.git
synced 2026-03-10 08:59:17 +01:00
Fix blahaj movement, rotation and fix shop showing 1 per upgrade instead of 0.5
This commit is contained in:
@@ -139,7 +139,7 @@ script = ExtResource("13_fc420")
|
||||
position = Vector2(-3.333374, 11.648682)
|
||||
shape = SubResource("RectangleShape2D_fc420")
|
||||
|
||||
[node name="blahaj_area2d" type="Area2D" parent="." unique_id=1258170752]
|
||||
[node name="blahaj_area2d" type="Area2D" parent="." unique_id=1258170752 groups=["blahaj"]]
|
||||
position = Vector2(-1141, 498)
|
||||
metadata/is_original = true
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
extends Sprite2D
|
||||
|
||||
var nearest_fish: Area2D
|
||||
var last_eat = Time.get_ticks_msec()
|
||||
var flip_timer: float = 0.0
|
||||
var flip_delay: float = 0.15
|
||||
var current_direction: Vector2 = Vector2.ZERO
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if get_parent().get_meta("is_original", false):
|
||||
@@ -9,7 +11,6 @@ func _process(delta: float) -> void:
|
||||
|
||||
var min_dist: float = INF
|
||||
nearest_fish = null
|
||||
|
||||
for fish in get_node("/root/Main/fish_parent").get_children():
|
||||
if not is_instance_of(fish, Area2D):
|
||||
continue
|
||||
@@ -17,29 +18,49 @@ func _process(delta: float) -> void:
|
||||
if dist < min_dist:
|
||||
min_dist = dist
|
||||
nearest_fish = fish
|
||||
|
||||
if not is_instance_valid(nearest_fish):
|
||||
return
|
||||
|
||||
var direction = ((nearest_fish.global_position - global_position) * randf_range(0.9, 1.1)).normalized()
|
||||
get_parent().position += direction * Globals.BLAHAJ_SPEED * delta
|
||||
get_parent().rotation = lerp_angle(get_parent().rotation, direction.angle(), 0.01)
|
||||
var chase = (nearest_fish.global_position - global_position).normalized()
|
||||
|
||||
var separation = Vector2.ZERO
|
||||
for blahaj in get_node("/root/Main").get_children():
|
||||
if blahaj == get_parent():
|
||||
continue
|
||||
if not blahaj.is_in_group("blahaj"):
|
||||
continue
|
||||
var diff = get_parent().global_position - blahaj.global_position
|
||||
var dist = diff.length()
|
||||
if dist < 100.0 and dist > 0.0:
|
||||
separation += diff.normalized() * (100.0 - dist) / 100.0
|
||||
|
||||
# Blend chase and separation, separation weighted more when close
|
||||
var desired = (chase + separation * 2.0).normalized()
|
||||
|
||||
# Smoothly steer current_direction toward desired
|
||||
current_direction = current_direction.lerp(desired, 8.0 * delta).normalized()
|
||||
|
||||
var speed = Globals.BLAHAJ_SPEED
|
||||
if separation.length() > 0.5:
|
||||
speed *= 2.5
|
||||
|
||||
get_parent().position += current_direction * speed * delta
|
||||
get_parent().rotation = 0.0
|
||||
|
||||
var target_scale_x = -1 if current_direction.x < 0 else 1
|
||||
if target_scale_x != get_parent().scale.x:
|
||||
flip_timer += delta
|
||||
if flip_timer >= flip_delay:
|
||||
get_parent().scale.x = target_scale_x
|
||||
flip_timer = 0.0
|
||||
else:
|
||||
flip_timer = 0.0
|
||||
|
||||
if not Time.get_ticks_msec() - last_eat >= 500:
|
||||
return
|
||||
|
||||
last_eat = Time.get_ticks_msec()
|
||||
|
||||
for area: Area2D in get_parent().get_overlapping_areas():
|
||||
if area.is_in_group("fish"):
|
||||
Globals.coins += (1 + Globals.sell_cost_upgrades)
|
||||
Globals.fish_per_second += 1
|
||||
play_sound("res://assets/sfx/splash.mp3")
|
||||
area.queue_free()
|
||||
|
||||
func play_sound(path: String):
|
||||
var player = AudioStreamPlayer.new()
|
||||
add_child(player)
|
||||
player.stream = load(path)
|
||||
player.play()
|
||||
player.finished.connect(player.queue_free)
|
||||
|
||||
@@ -11,7 +11,7 @@ var all_hit = 0
|
||||
var last_hit_percent = 0
|
||||
var sell_cost_upgrades = 0
|
||||
var spawn_speed_upgrades = 0
|
||||
var blahaj_upgrades = 0
|
||||
var blahaj_upgrades = 5
|
||||
var toucan_upgrades = 1
|
||||
|
||||
const COD_TYPES := ["blue", "green", "orange", "pink", "purple", "yellow"]
|
||||
|
||||
@@ -4,5 +4,5 @@ func _process(delta: float) -> void:
|
||||
$coins_label.text = "Coins: {coins}".format({"coins": Globals.coins})
|
||||
$toucan_label.text = "Toucan\nOwned: {owned}\nCost: {cost}$".format({"owned": Globals.toucan_upgrades, "cost": Globals.TOUCAN_PRICE * (Globals.toucan_upgrades + 1)})
|
||||
$blahaj_label.text = "Blahaj\nOwned: {owned}\nCost: {cost}$".format({"owned": Globals.blahaj_upgrades, "cost": Globals.BLAHAJ_PRICE * (Globals.blahaj_upgrades + 1)})
|
||||
$sell_cost_upgrade.text = "Sell cost upgrade\n(+1$)\nOwned: {owned}\nCost: {cost}$".format({"owned": Globals.sell_cost_upgrades, "cost": Globals.SELL_COST_PRICE * (Globals.sell_cost_upgrades + 1)})
|
||||
$sell_cost_upgrade.text = "Sell cost upgrade\n(+0.5$)\nOwned: {owned}\nCost: {cost}$".format({"owned": Globals.sell_cost_upgrades, "cost": Globals.SELL_COST_PRICE * (Globals.sell_cost_upgrades + 1)})
|
||||
$fish_spawn_upgrade.text = "Fish Spawn Speed upgrade\n(+ 1 fish/s)\nOwned: {owned}\nCost: {cost}$".format({"owned": Globals.spawn_speed_upgrades, "cost": Globals.SPAWN_SPEED_PRICE * (Globals.spawn_speed_upgrades + 1)})
|
||||
|
||||
Reference in New Issue
Block a user