diff --git a/Utils.gd b/Utils.gd index 9ab84cf..e5ae3f5 100644 --- a/Utils.gd +++ b/Utils.gd @@ -49,4 +49,4 @@ static func delete_children(node): static func log_line(obj: Node, msg: String): var time = Time.get_time_dict_from_system() var time_str = "%02d:%02d:%02d" % [time.hour, time.minute, time.second] - print("@%s [%s]: %s" % [time_str, obj.name, msg]) + diff --git a/base/BaseScene.gd b/base/BaseScene.gd index 0276bb0..d22b04b 100644 --- a/base/BaseScene.gd +++ b/base/BaseScene.gd @@ -30,7 +30,7 @@ var current_scene: Node = null: func move_to_island(): print("Starting game...") emit_signal("moving_to_island") - current_scene = load("res://island/Island.tscn").instantiate() + current_scene = preload("res://island/Island.tscn").instantiate() emit_signal("moved_to_island") ## Change the current scene to the main menu. @@ -38,7 +38,7 @@ func move_to_menu(): print("Going to the menu...") emit_signal("moving_to_menu") Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - current_scene = load("res://menu/Menu.tscn").instantiate() + current_scene = preload("res://menu/Menu.tscn").instantiate() current_scene.connect("play_pressed", move_to_island) emit_signal("moved_to_menu") diff --git a/island/Island.tscn b/island/Island.tscn index 8cf6cf0..6d091b2 100644 --- a/island/Island.tscn +++ b/island/Island.tscn @@ -37,9 +37,6 @@ sky = SubResource("Sky_j6hso") [node name="Island" type="Node3D"] -[node name="Player" parent="." instance=ExtResource("3_5378m")] -transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 3.896, 2.08165e-12) - [node name="Sea" parent="." instance=ExtResource("1_e0hpm")] metadata/_edit_lock_ = true @@ -47,6 +44,9 @@ metadata/_edit_lock_ = true transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 20, 0, -4) metadata/_edit_lock_ = true +[node name="Player" parent="." instance=ExtResource("3_5378m")] +transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 3.896, 2.08165e-12) + [node name="World" type="Node3D" parent="."] [node name="Environment" type="WorldEnvironment" parent="World"] @@ -235,6 +235,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 3, 59) [node name="Leafpile19" parent="CropTiles" instance=ExtResource("9_472aa")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 3, 60) +[node name="Leafpile22" parent="CropTiles" instance=ExtResource("9_472aa")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -26, 1, 33) + [node name="Produce" type="Node3D" parent="."] metadata/_edit_lock_ = true diff --git a/island/Temple.gd b/island/Temple.gd index ba6d551..ee96a63 100644 --- a/island/Temple.gd +++ b/island/Temple.gd @@ -1,5 +1,5 @@ extends Node3D - +class_name Temple var score: int = 0 var time: float = 0.0 @@ -7,16 +7,16 @@ var is_exploded: bool = false @export var size_per_prayer: float = 0.05 @export var pitch_per_prayer: float = 0.02 -@export var explode_at: int = 1 +@export var explode_at: int = 150 @export var explosion_scene: PackedScene = preload("res://island/FunnyExplosion.tscn") -@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(): + var player = Singletons.player if prayer_area.overlaps_body(player): if player.collected_fruit > 0: if not pineglasses_sound.playing: diff --git a/menu/Menu.gd b/menu/Menu.gd index b9da113..999c1eb 100644 --- a/menu/Menu.gd +++ b/menu/Menu.gd @@ -19,6 +19,5 @@ func _on_fetched_scores(): func _ready(): - print("Connecting fetched_scores to the Scores button") $"/root/BaseScene/ScoreboardContainer".connect("fetched_scores", _on_fetched_scores) $"/root/BaseScene/ScoreboardContainer".fetch_scores(false) diff --git a/menu/ScoreboardContainer.gd b/menu/ScoreboardContainer.gd index 039aa37..9b6672d 100644 --- a/menu/ScoreboardContainer.gd +++ b/menu/ScoreboardContainer.gd @@ -66,7 +66,6 @@ func fetch_scores(open_after: bool = false): func show_scores(): print("Displaying scores...") prev_mouse_mode = Input.mouse_mode as Input.MouseMode - print("Previous mouse mode was: ", prev_mouse_mode) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) visible = true diff --git a/player/Head.gd b/player/Head.gd index a6a6d4c..4c47094 100644 --- a/player/Head.gd +++ b/player/Head.gd @@ -9,6 +9,7 @@ var noiseRot := Vector3.ZERO var noiseCount := 0 @export var noiseAmp := 10.0 @export var noiseFreq := 100.0 +@onready var camera = $Viewport/CameraViewportContainer/GameViewport/Camera var mouseRot := Vector2.ZERO @@ -23,3 +24,7 @@ func _ready() -> void: func _input(event: InputEvent) -> void: if event is InputEventMouseMotion: mouseRot = event.relative + + +func _physics_process(_delta): + camera.global_transform = global_transform diff --git a/player/Player.gd b/player/Player.gd index d56f494..6dd9e71 100644 --- a/player/Player.gd +++ b/player/Player.gd @@ -22,8 +22,12 @@ const AIR_ACCELERATE = 100 # Hu/39.97 @onready var active_weapon: BaseWeapon: get: return OnHand.active_weapon -@onready var ammo_label = $HUD/AmmoLabel -@onready var fruit_label = $HUD/PineappleLabel +@onready var ammo_label: Label = $HUD/AmmoLabel +@onready var fruit_label: Label = $HUD/PineappleLabel +@onready var speed_label: Label = $HUD/SpeedLabel +@onready var timer_label: Label = $HUD/TimerLabel + +@onready var temple: Temple = $"/root/BaseScene/Island/Temple" var collected_fruit: int = 0: get: @@ -96,7 +100,7 @@ func _physics_process(delta): if active_weapon and active_weapon.ammoType != BaseWeapon.AmmoType.NONE: ammo_label.show() if active_weapon is PeaShooter: - ammo_label.text = "%d seeds left" % active_weapon.remaining + ammo_label.text = "%d seeds" % active_weapon.remaining else: ammo_label.hide() @@ -126,7 +130,11 @@ func _air_accelerate(wish_dir: Vector3, wish_speed: float, airaccelerate: float, func _process(_delta: float) -> void: - self.camera.global_transform = self.head.global_transform + speed_label.text = "%0.2f km/h" % velocity.length() + if temple != null: + timer_label.text = "%0.3f s" % temple.time + else: + timer_label.text = "" func _input(event): diff --git a/player/Player.tscn b/player/Player.tscn index dcfbc9c..ca86453 100644 --- a/player/Player.tscn +++ b/player/Player.tscn @@ -147,17 +147,22 @@ scale = Vector2(1.65, 1) metadata/_edit_lock_ = true [node name="PineappleLabel" type="Label" parent="HUD"] -layout_mode = 0 +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 anchor_top = 1.0 +anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 8.0 -offset_top = -26.0 -offset_right = 106.0 -offset_bottom = -8.0 +offset_left = -102.0 +offset_top = -22.0 +offset_right = -4.0 +offset_bottom = -4.0 +grow_horizontal = 0 grow_vertical = 0 theme = ExtResource("4_d7ru6") theme_override_font_sizes/font_size = 16 text = "0 harvested" +horizontal_alignment = 2 vertical_alignment = 2 [node name="AmmoLabel" type="Label" parent="HUD"] @@ -166,18 +171,48 @@ anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -103.0 -offset_top = -26.0 -offset_right = -8.0 -offset_bottom = -8.0 +offset_left = -99.0 +offset_top = -34.0 +offset_right = -4.0 +offset_bottom = -16.0 grow_horizontal = 0 grow_vertical = 0 theme = ExtResource("4_d7ru6") theme_override_font_sizes/font_size = 16 -text = "8888 seeds left" +text = "8888 seeds" horizontal_alignment = 2 vertical_alignment = 2 +[node name="TimerLabel" type="Label" parent="HUD"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = -34.0 +offset_right = 99.0 +offset_bottom = -16.0 +grow_vertical = 0 +theme = ExtResource("4_d7ru6") +theme_override_font_sizes/font_size = 16 +text = "0.000 s" +vertical_alignment = 2 + +[node name="SpeedLabel" type="Label" parent="HUD"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = -22.0 +offset_right = 99.0 +offset_bottom = -4.0 +grow_vertical = 0 +theme = ExtResource("4_d7ru6") +theme_override_font_sizes/font_size = 16 +text = "5.00 km/h" +vertical_alignment = 2 + [node name="Crosshair" type="ColorRect" parent="HUD"] material = SubResource("ShaderMaterial_2p6rt") layout_mode = 0 diff --git a/project.godot b/project.godot index 3836fa6..fc5a074 100644 --- a/project.godot +++ b/project.godot @@ -53,6 +53,11 @@ _global_script_classes=[{ "class": &"SinkArea", "language": &"GDScript", "path": "res://island/sinking/SinkArea.gd" +}, { +"base": "Node3D", +"class": &"Temple", +"language": &"GDScript", +"path": "res://island/Temple.gd" }] _global_script_class_icons={ "BaseScene": "", @@ -63,16 +68,18 @@ _global_script_class_icons={ "Player": "", "PlayerInputData": "", "ScoreBox": "", -"SinkArea": "" +"SinkArea": "", +"Temple": "" } [application] config/name="Pineapple Surf" -config/description="A bunnyhopping, retro-looking, first person seed shooters" +config/description="A bunnyhopping, retro-looking, first person seed shooter" run/main_scene="res://base/BaseScene.tscn" config/features=PackedStringArray("4.0", "GL Compatibility") boot_splash/bg_color=Color(0.231373, 0.490196, 0.309804, 1) +boot_splash/image="res://assets/pineglasses.png" config/icon="res://assets/pineglasses.png" [autoload]