Godot upload

This commit is contained in:
csd4ni3l
2026-02-28 13:55:12 +01:00
commit 738a94093a
94 changed files with 1902 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
extends Sprite2D
func scale_to_window():
var window_size = get_viewport_rect().size
var texture_size = texture.get_size()
scale = window_size / texture_size
position = window_size / 2 # Center it (origin is top-left by default)
func _process(delta: float) -> void:
scale_to_window()

View File

@@ -0,0 +1 @@
uid://n4gqvy2ytjst

45
assets/scripts/blahaj.gd Normal file
View File

@@ -0,0 +1,45 @@
extends Sprite2D
var nearest_fish: Area2D
var last_eat = Time.get_ticks_msec()
func _process(delta: float) -> void:
if get_parent().get_meta("is_original", false):
return
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
var dist = global_position.distance_to(fish.global_position)
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)
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)

View File

@@ -0,0 +1 @@
uid://doambvkr7546i

View File

@@ -0,0 +1,6 @@
extends TextureButton
func _pressed() -> void:
if Globals.coins >= Globals.BLAHAJ_PRICE * (Globals.blahaj_upgrades + 1):
Globals.coins -= Globals.BLAHAJ_PRICE * (Globals.blahaj_upgrades + 1)
Globals.blahaj_upgrades += 1

View File

@@ -0,0 +1 @@
uid://xye8ey43chew

12
assets/scripts/bubble.gd Normal file
View File

@@ -0,0 +1,12 @@
extends Sprite2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if get_meta("is_original", false):
return
self.position.x += randf_range(-0.5, 0.5) * Globals.BUBBLE_SPEED * delta
self.position.y -= Globals.BUBBLE_SPEED * delta
if position.y < 0:
queue_free()

View File

@@ -0,0 +1 @@
uid://c02mfpu30mq5w

View File

@@ -0,0 +1,11 @@
extends Timer
func _on_timeout() -> void:
Globals.last_fish_per_second = Globals.fish_per_second
Globals.fish_per_second = 0
if Globals.all_hit > 0:
Globals.last_hit_percent = min((float(Globals.successful_hit) / float(Globals.all_hit)) * 100, 100.0)
else:
Globals.last_hit_percent = 0
Globals.successful_hit = 0
Globals.all_hit = 0

View File

@@ -0,0 +1 @@
uid://cprehixvgn0k1

View File

@@ -0,0 +1,4 @@
extends Button
func _pressed() -> void:
get_tree().change_scene_to_file("res://assets/scenes/credits.tscn")

View File

@@ -0,0 +1 @@
uid://qe15irthfjxd

View File

@@ -0,0 +1,4 @@
extends Button
func _pressed() -> void:
get_tree().change_scene_to_file("res://assets/scenes/main_menu.tscn")

View File

@@ -0,0 +1 @@
uid://65gtnts6kj5w

View File

@@ -0,0 +1,26 @@
extends Node2D
var changing_scene := false
var anim_start = Time.get_ticks_msec()
func spawn_bubble() -> void:
var new_bubble: Sprite2D = $bubble_to_clone.duplicate(15)
new_bubble.set_meta("is_original", false)
var new_bubble_size = new_bubble.texture.get_size()
new_bubble.position = Vector2(
randf_range(0, DisplayServer.window_get_size().x - new_bubble_size.x),
randf_range(0, DisplayServer.window_get_size().y - new_bubble_size.y)
)
add_child(new_bubble)
func _process(delta: float) -> void:
if Time.get_ticks_msec() - anim_start >= 5000:
get_tree().change_scene_to_file("res://assets/scenes/game.tscn")
func _ready() -> void:
var screen = DisplayServer.window_get_size()
var bubble_size = $bubble_to_clone.texture.get_size()
var cols = ceil(screen.x / bubble_size.x) + 1
var rows = ceil(screen.y / bubble_size.y) + 1
for i in range(cols * rows):
spawn_bubble()

View File

@@ -0,0 +1 @@
uid://bouh46cbivutc

View File

@@ -0,0 +1,143 @@
extends Area2D
@onready var sprite = $fish_button_to_clone # or whatever the sprite node is named
@onready var audio_player = get_node("/root/Main/ClickSoundManager")
var does_move = 1
var speed_scale = 1.0
var new_rotation: float
var is_reeling = false
var reel_speed = 800.0
var line_origin: Vector2
var line: Line2D
var hook_sprite: Sprite2D
var wobble = 0.0
var angle = randi() % 360
var last_bubble_spawn = Time.get_ticks_msec()
func get_size() -> Vector2:
if sprite.texture:
return sprite.texture.get_size() * sprite.scale
return Vector2.ZERO
func play_sound(path: String):
var player = AudioStreamPlayer.new()
add_child(player)
player.stream = load(path)
player.play()
player.finished.connect(player.queue_free)
func spawn_bubble() -> void:
var new_bubble: Sprite2D = $"/root/Main/bubble_to_clone".duplicate(15)
new_bubble.set_meta("is_original", false)
new_bubble.position = Vector2(
global_position.x * randf_range(0.95, 1.05),
global_position.y
)
get_parent().get_parent().get_parent().add_child(new_bubble)
func _physics_process(delta: float) -> void:
if get_meta("is_original", false):
return
var sz = get_size()
if is_reeling:
if Time.get_ticks_msec() - last_bubble_spawn >= 20:
last_bubble_spawn = Time.get_ticks_msec()
spawn_bubble()
global_position.y -= reel_speed * delta
global_position.x = line_origin.x # no offset
if line and is_instance_valid(line):
line.set_point_position(0, line_origin)
line.set_point_position(1, global_position)
if hook_sprite and is_instance_valid(hook_sprite):
hook_sprite.global_position = global_position - Vector2(0, get_size().y / 5)
if global_position.y + get_size().y <= 0:
_on_caught()
return
if does_move == 1:
var mouse = get_global_mouse_position()
var top_left = global_position - sz / 2
var rect = Rect2(top_left, sz)
if rect.has_point(mouse):
speed_scale = 0.6
else:
speed_scale = 1.0
new_rotation = angle - deg_to_rad(135)
if abs(new_rotation - rotation) > 0.01:
rotation = lerp_angle(rotation, new_rotation, 0.2)
else:
rotation = new_rotation
wobble += delta * 15.0
var wobble_angle = angle + sin(wobble) * 0.3
var wobble_dir = Vector2(cos(wobble_angle), sin(wobble_angle))
global_position += wobble_dir * Globals.FISH_SPEED * delta * speed_scale
new_rotation = wobble_angle - deg_to_rad(135)
if abs(new_rotation - rotation) > 0.01:
rotation = lerp_angle(rotation, new_rotation, 0.2)
else:
rotation = new_rotation
var screen_size = get_viewport_rect().size
if global_position.x < 0:
if is_instance_valid(line):
line.queue_free()
if is_instance_valid(hook_sprite):
hook_sprite.queue_free()
queue_free()
elif global_position.x > screen_size.x:
if is_instance_valid(line):
line.queue_free()
if is_instance_valid(hook_sprite):
hook_sprite.queue_free()
queue_free()
if global_position.y < 0:
global_position.y = -global_position.y
self.angle = -self.angle
elif global_position.y > screen_size.y:
global_position.y = 2 * screen_size.y - global_position.y
self.angle = -self.angle
func _on_input_event(_viewport, event, _shape_idx) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
_on_clicked()
func _on_clicked() -> void:
if is_reeling:
return
var fish_center = global_position
line_origin = Vector2(fish_center.x, 0)
line = Line2D.new()
line.width = 2.0
line.default_color = Color(0.6, 0.6, 0.6, 1.0)
line.top_level = true
line.points = PackedVector2Array([line_origin, fish_center])
add_child(line)
hook_sprite = Sprite2D.new()
hook_sprite.texture = load("res://assets/graphics/hook.png")
hook_sprite.top_level = true
hook_sprite.global_position = fish_center - Vector2(0, get_size().y / 5)
hook_sprite.scale = Vector2(1.5, 1.5)
add_child(hook_sprite)
is_reeling = true
does_move = 0
rotation = 0
play_sound("res://assets/sfx/splash.mp3")
func _on_caught() -> void:
Globals.coins += (1 + (Globals.sell_cost_upgrades * 0.5))
Globals.fish_per_second += 1
Globals.successful_hit += 1
if line and is_instance_valid(line):
line.queue_free()
if hook_sprite and is_instance_valid(hook_sprite):
hook_sprite.queue_free()
queue_free()

View File

@@ -0,0 +1 @@
uid://qp6v3st8ix3v

View File

View File

@@ -0,0 +1 @@
uid://ckp3u7iahsl3x

View File

@@ -0,0 +1,6 @@
extends Button
func _pressed() -> void:
if Globals.coins >= Globals.SPAWN_SPEED_PRICE * (Globals.spawn_speed_upgrades + 1):
Globals.coins -= Globals.SPAWN_SPEED_PRICE * (Globals.spawn_speed_upgrades + 1)
Globals.spawn_speed_upgrades += 1

View File

@@ -0,0 +1 @@
uid://cyc55s4f8xujd

View File

@@ -0,0 +1,72 @@
extends Node2D
@onready var fish_parent: Node2D = $fish_parent
@onready var coinText: RichTextLabel = $Control/coins_label
@onready var audio_player = $"ClickSoundManager"
var last_bubble = Time.get_ticks_msec()
func _input(event):
if event is InputEventMouseButton and event.pressed:
Globals.all_hit += 1
func play_sound(path: String):
var player = AudioStreamPlayer.new()
add_child(player)
player.stream = load(path)
player.play()
player.finished.connect(player.queue_free)
func spawn_blahaj() -> void:
var new_blahaj: Area2D = $blahaj_area2d.duplicate(15)
new_blahaj.set_meta("is_original", false)
var new_blahaj_size = new_blahaj.get_child(0).texture.get_size() * new_blahaj.get_child(0).scale
new_blahaj.position = Vector2(
randf_range(DisplayServer.window_get_size().x * 0.1, Globals.spawn_area.x - new_blahaj_size.x),
randf_range(DisplayServer.window_get_size().y * 0.1, Globals.spawn_area.y - new_blahaj_size.y)
)
add_child(new_blahaj)
func spawn_toucan() -> void:
var new_toucan: Area2D = $toucan_area2d.duplicate(15)
new_toucan.set_meta("is_original", false)
var new_toucan_size = new_toucan.get_child(0).texture.get_size()
new_toucan.position = Vector2(
randf_range(DisplayServer.window_get_size().x * 0.1, Globals.spawn_area.x - new_toucan_size.x),
-new_toucan_size.y * 2
)
add_child(new_toucan)
func spawn_bubble() -> void:
var new_bubble: Sprite2D = $bubble_to_clone.duplicate(15)
new_bubble.set_meta("is_original", false)
var new_bubble_size = new_bubble.texture.get_size()
new_bubble.position = Vector2(
randf_range(0, DisplayServer.window_get_size().x - new_bubble_size.x),
DisplayServer.window_get_size().y
)
add_child(new_bubble)
func _ready() -> void:
audio_player.play()
Globals.init_button($fish_parent/fish_area2d)
get_viewport().size_changed.connect(_on_window_resized)
var spawn_time: float = (1.0 / (4.0 + Globals.spawn_speed_upgrades))
$spawn_timer.wait_time = spawn_time
for i in Globals.blahaj_upgrades:
spawn_blahaj()
for i in Globals.toucan_upgrades:
spawn_toucan()
func _on_window_resized() -> void:
Globals.spawn_area = DisplayServer.window_get_size()
func _process(_delta: float) -> void:
coinText.text = "Coins: {coins}\nFish per second: {fish_per_second}\nHit rate: {hit_rate}%".format({"coins": Globals.coins, "fish_per_second": round(Globals.last_fish_per_second / 3.0), "hit_rate": round(Globals.last_hit_percent)})
if Time.get_ticks_msec() - last_bubble >= 100:
last_bubble = Time.get_ticks_msec()
spawn_bubble()

View File

@@ -0,0 +1 @@
uid://wwqm6xuj48lg

31
assets/scripts/globals.gd Normal file
View File

@@ -0,0 +1,31 @@
# In Globals
extends Node
var coins: int = 0
var fish_per_second: int = 0
var last_fish_per_second: int = 0
var spawn_area: Vector2
var fish_button_to_clone: Area2D
var successful_hit = 0
var all_hit = 0
var last_hit_percent = 0
var sell_cost_upgrades = 0
var spawn_speed_upgrades = 0
var blahaj_upgrades = 0
var toucan_upgrades = 1
const COD_TYPES := ["blue", "green", "orange", "pink", "purple", "yellow"]
const FISH_SPEED = 100
const BLAHAJ_SPEED = 150
const TOUCAN_SPEED = 250
const BUBBLE_SPEED = 100
const SELL_COST_PRICE = 225
const SPAWN_SPEED_PRICE = 300
const BLAHAJ_PRICE = 400
const TOUCAN_PRICE = 75
func init_button(button: Area2D):
fish_button_to_clone = button
spawn_area = Vector2(DisplayServer.window_get_size())

View File

@@ -0,0 +1 @@
uid://chyoc844old4i

View File

@@ -0,0 +1,4 @@
extends Button
func _pressed() -> void:
get_tree().change_scene_to_file("res://assets/scenes/cutscene.tscn")

View File

@@ -0,0 +1 @@
uid://bqw60tl4be18a

View File

@@ -0,0 +1,6 @@
extends Button
func _pressed() -> void:
if Globals.coins >= Globals.SELL_COST_PRICE * (Globals.sell_cost_upgrades + 1):
Globals.coins -= Globals.SELL_COST_PRICE * (Globals.sell_cost_upgrades + 1)
Globals.sell_cost_upgrades += 1

View File

@@ -0,0 +1 @@
uid://c14tjf3qlxdi

View File

@@ -0,0 +1,4 @@
extends TextureButton
func _pressed() -> void:
get_tree().change_scene_to_file("res://assets/scenes/shop.tscn")

View File

@@ -0,0 +1 @@
uid://24gsro7ny3g

View File

@@ -0,0 +1,4 @@
extends Button
func _pressed() -> void:
get_tree().change_scene_to_file("res://assets/scenes/game.tscn")

View File

@@ -0,0 +1 @@
uid://dpoooqbw6moto

View File

@@ -0,0 +1,8 @@
extends Control
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)})
$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)})

View File

@@ -0,0 +1 @@
uid://deoyoa417jjia

View File

@@ -0,0 +1,29 @@
extends Timer
@onready var fish_button_to_clone = get_node("../fish_parent/fish_area2d")
@onready var fish_parent = get_node("../fish_parent")
func get_sprite_size(sprite: Sprite2D) -> Vector2:
if sprite.texture:
if sprite.region_enabled:
return sprite.region_rect.size * sprite.scale
return sprite.texture.get_size() * sprite.scale
return Vector2.ZERO
func spawn() -> void:
var fish_area: Area2D = fish_button_to_clone.duplicate(15)
fish_area.get_child(0).texture = load("res://assets/graphics/{type}_cod.png".format({"type": Globals.COD_TYPES[randi() % Globals.COD_TYPES.size()]}))
fish_area.set_meta("is_original", false)
fish_area.visible = true
fish_area.get_child(0).visible = true
fish_parent.add_child(fish_area)
var fish_size = get_sprite_size(fish_button_to_clone.get_child(0))
fish_area.position = Vector2(
randf_range(0, Globals.spawn_area.x - fish_size.x),
randf_range(0, Globals.spawn_area.y - fish_size.y)
)
func _on_timeout() -> void:
spawn()

View File

@@ -0,0 +1 @@
uid://c8ys3ls826d21

55
assets/scripts/toucan.gd Normal file
View File

@@ -0,0 +1,55 @@
extends Sprite2D
var nearest_fish: Area2D
var last_eat = Time.get_ticks_msec()
func _process(delta: float) -> void:
if get_parent().get_meta("is_original", false):
return
if not Time.get_ticks_msec() - last_eat >= 700:
return
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
var dist = global_position.distance_to(fish.global_position)
if fish.global_position.y < (DisplayServer.window_get_size().y * 0.35) and dist < min_dist:
min_dist = dist
nearest_fish = fish
if not is_instance_valid(nearest_fish) or nearest_fish.position.y > (DisplayServer.window_get_size().y * 0.35):
respawn()
return
var direction = ((nearest_fish.global_position - global_position) * randf_range(0.9, 1.1)).normalized()
get_parent().position += direction * Globals.TOUCAN_SPEED * delta
get_parent().rotation = lerp_angle(get_parent().rotation, direction.angle(), 0.025)
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
area.queue_free()
respawn()
play_sound("res://assets/sfx/splash.mp3")
last_eat = Time.get_ticks_msec()
func play_sound(path: String):
var player = AudioStreamPlayer.new()
add_child(player)
player.stream = load(path)
player.play()
player.finished.connect(player.queue_free)
func respawn() -> void:
var new_toucan_size = self.texture.get_size()
get_parent().position = Vector2(
randf_range(DisplayServer.window_get_size().x * 0.1, Globals.spawn_area.x - new_toucan_size.x),
-new_toucan_size.y * 2
)

View File

@@ -0,0 +1 @@
uid://bqxust6gkydnx

View File

@@ -0,0 +1,6 @@
extends TextureButton
func _pressed() -> void:
if Globals.coins >= Globals.TOUCAN_PRICE * (Globals.toucan_upgrades + 1):
Globals.coins -= Globals.TOUCAN_PRICE * (Globals.toucan_upgrades + 1)
Globals.toucan_upgrades += 1

View File

@@ -0,0 +1 @@
uid://bm7jxybqhhny2