1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-25 09:14:18 +00:00
pineapple-surf/island/Temple.gd

66 lines
1.7 KiB
GDScript3
Raw Normal View History

2023-01-09 04:11:00 +00:00
extends Node3D
2023-01-09 10:06:02 +00:00
var score: int = 0
var time: float = 0.0
2023-01-09 11:10:51 +00:00
var is_exploded: bool = false
@export var size_per_prayer: float = 0.05
@export var pitch_per_prayer: float = 0.02
2023-01-09 05:28:32 +00:00
@export var explode_at: int = 150
@export var explosion_scene: PackedScene = preload("res://island/FunnyExplosion.tscn")
2023-01-09 04:11:00 +00:00
@onready var player: Player = Singletons.player
@onready var prayer_area: Area3D = $PrayerArea
@onready var pineglasses: MeshInstance3D = $Pineglasses
@onready var pineglasses_sound: AudioStreamPlayer3D = $Pineglasses/Growth
func try_to_collect_fruit():
2023-01-09 04:11:00 +00:00
if prayer_area.overlaps_body(player):
if player.collected_fruit > 0:
if not pineglasses_sound.playing:
pineglasses_sound.play()
player.collected_fruit -= 1
score += 1
2023-01-09 04:11:00 +00:00
pineglasses.scale += Vector3(size_per_prayer, size_per_prayer, size_per_prayer)
pineglasses_sound.pitch_scale += pitch_per_prayer
else:
if pineglasses_sound.playing:
pineglasses_sound.stop()
else:
if pineglasses_sound.playing:
pineglasses_sound.stop()
2023-01-09 05:29:17 +00:00
# "is it gonna explode tho"
# --Ichi
func try_to_explode():
2023-01-09 11:10:51 +00:00
if not is_exploded and score >= explode_at:
is_exploded = true
var explosion = explosion_scene.instantiate()
var explosion_sound = explosion.get_node("ExplosionSound")
2023-01-09 09:39:47 +00:00
explosion.position = pineglasses.position + Vector3.UP
explosion.scale = pineglasses.scale
explosion_sound.connect("finished", win)
add_child(explosion)
func win():
print("YOU WIN!")
2023-01-09 10:06:02 +00:00
print("Time: ", time)
2023-01-09 16:43:16 +00:00
Singletons.time = time
# get_tree().change_scene_to_file("res://base/BaseScene.tscn")
queue_free()
2023-01-09 10:06:02 +00:00
func _process(delta):
2023-01-09 11:10:51 +00:00
if not is_exploded:
2023-01-09 10:06:02 +00:00
time += delta
func _physics_process(_delta):
try_to_collect_fruit()
try_to_explode()