From 9adf009a21d6ebd5028c9f5fc72ae4d09358928c Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Fri, 10 Jan 2025 14:55:26 -0700 Subject: [PATCH] Velocity & damping are reset between shots --- levels/debug_level/debug_level.tscn | 1 - src/equipment/balls/physics_ball/game_ball.gd | 7 +++- .../balls/physics_ball/physics_ball.tscn | 10 ++++- src/game/game.gd | 6 +++ src/player/debug_player.tres | 1 + src/player/shot_setup/ball_point.gd | 1 + .../shot_hud/ball_selector/ball_selector.gd | 1 + .../effects/explosion/explosion_effect.tscn | 38 ++++++++++++------- .../effects/explosion/intensity_curve.tres | 5 +++ src/world/world.tscn | 4 +- 10 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 src/world/effects/explosion/intensity_curve.tres diff --git a/levels/debug_level/debug_level.tscn b/levels/debug_level/debug_level.tscn index 9ebf1b7..7d01ffd 100644 --- a/levels/debug_level/debug_level.tscn +++ b/levels/debug_level/debug_level.tscn @@ -442,7 +442,6 @@ spawn_turns = 1 [node name="ExplosionEffect" parent="Course" instance=ExtResource("16_xufks")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 274.103, 5.01502, 286.299) -visible = false [node name="CityBuildings" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 129.404, -9.53674e-07, 309.4) diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 0719275..2a35a46 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -6,6 +6,7 @@ signal entered_water ## Types of game balls enum Type { + DEBUG = -1, NONE, BASIC, PLASMA, @@ -221,12 +222,14 @@ func _on_sleeping_state_changed() -> void: if sleeping: # Trigger to reassign on wake _awake = false + linear_velocity = Vector3.ZERO + angular_velocity = Vector3.ZERO + linear_damp = 0.0 + angular_damp = 0.0 func _manual_sleep() -> void: freeze = true - linear_velocity = Vector3.ZERO - angular_velocity = Vector3.ZERO manual_sleep_timer.start() diff --git a/src/equipment/balls/physics_ball/physics_ball.tscn b/src/equipment/balls/physics_ball/physics_ball.tscn index 9dfb13e..274079b 100644 --- a/src/equipment/balls/physics_ball/physics_ball.tscn +++ b/src/equipment/balls/physics_ball/physics_ball.tscn @@ -35,10 +35,13 @@ script/source = "extends Control const COLOR_X := Color(1, 0, 0) const COLOR_Y := Color(0, 1, 0) const COLOR_Z := Color(0, 0, 1) +const COLOR_VELOCITY := Color.ORANGE const COLOR_MAGNUS := Color.CYAN +const VELOCITY_SCALE := 0.5 const MAGNUS_SCALE := 3 const WIDTH := 4 +@export var draw_velocity := true @export var draw_reoriented_basis := true @export var draw_magnus_effect := true @export var draw_gravity_basis := true @@ -54,6 +57,11 @@ func _process(_delta: float) -> void: func _draw() -> void: var camera := get_viewport().get_camera_3d() var start := camera.unproject_position(physics_ball.global_position) + + if draw_velocity: + var end := camera.unproject_position(physics_ball.global_position + physics_ball.linear_velocity * VELOCITY_SCALE) + draw_line(start, end, COLOR_VELOCITY, WIDTH) + if draw_reoriented_basis and physics_ball._last_contact_normal != null: var basis := physics_ball.get_reoriented_basis() var end_x := camera.unproject_position(physics_ball.global_position + basis.x) @@ -190,8 +198,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = SubResource("GDScript_p4v7o") -draw_reoriented_basis = false draw_magnus_effect = false +draw_gravity_basis = false [node name="SFX" type="Node3D" parent="."] unique_name_in_owner = true diff --git a/src/game/game.gd b/src/game/game.gd index a3e498c..f997e50 100644 --- a/src/game/game.gd +++ b/src/game/game.gd @@ -89,6 +89,12 @@ func _finish_scene_load(instance: Node) -> void: func _process(_delta: float) -> void: + # REMOVEME + if Input.is_action_just_pressed("ui_page_up"): + Engine.time_scale *= 2.0 + if Input.is_action_just_pressed("ui_page_down"): + Engine.time_scale *= 0.5 + if _loading_resources and not loading_screen.visible: loader_transition.play("fade_in") diff --git a/src/player/debug_player.tres b/src/player/debug_player.tres index 714245e..4209273 100644 --- a/src/player/debug_player.tres +++ b/src/player/debug_player.tres @@ -16,6 +16,7 @@ iron = ExtResource("2_piku2") wedge = ExtResource("5_wm4ae") putter = ExtResource("3_tytwr") _balls = { +-1: -1, 1: -1, 2: 5, 3: -1, diff --git a/src/player/shot_setup/ball_point.gd b/src/player/shot_setup/ball_point.gd index aca354f..1ec8f39 100644 --- a/src/player/shot_setup/ball_point.gd +++ b/src/player/shot_setup/ball_point.gd @@ -6,6 +6,7 @@ signal ball_changed(ball: GameBall) ## Scenes for each type of ball. const SCENE_MAP: Dictionary = { + GameBall.Type.DEBUG: preload("res://src/equipment/balls/debug_ball/debug_ball.tscn"), GameBall.Type.BASIC: preload("res://src/equipment/balls/physics_ball/physics_ball.tscn"), GameBall.Type.PLASMA: preload("res://src/equipment/balls/plasma_ball/plasma_ball.tscn"), GameBall.Type.BRICK: preload("res://src/equipment/balls/brick/brick.tscn"), diff --git a/src/ui/shot_hud/ball_selector/ball_selector.gd b/src/ui/shot_hud/ball_selector/ball_selector.gd index 62f09c3..2eda77e 100644 --- a/src/ui/shot_hud/ball_selector/ball_selector.gd +++ b/src/ui/shot_hud/ball_selector/ball_selector.gd @@ -4,6 +4,7 @@ class_name BallSelector extends Control const TWEEN_TIME := 0.2 const Y_OFFSET := { + GameBall.Type.DEBUG: 0, GameBall.Type.NONE: 50, GameBall.Type.BASIC: 18, GameBall.Type.PLASMA: -14, diff --git a/src/world/effects/explosion/explosion_effect.tscn b/src/world/effects/explosion/explosion_effect.tscn index ef43d09..e517301 100644 --- a/src/world/effects/explosion/explosion_effect.tscn +++ b/src/world/effects/explosion/explosion_effect.tscn @@ -1,38 +1,46 @@ -[gd_scene load_steps=8 format=3 uid="uid://c6k44l0mnq3o1"] +[gd_scene load_steps=10 format=3 uid="uid://c6k44l0mnq3o1"] + +[ext_resource type="Curve" uid="uid://b5vptoxuq3dwb" path="res://src/world/effects/explosion/intensity_curve.tres" id="1_rxjwh"] [sub_resource type="Gradient" id="Gradient_tuj3x"] -offsets = PackedFloat32Array(0, 0.0850112, 0.693512, 0.760626) -colors = PackedColorArray(3, 3, 3, 1, 2, 2, 0.6, 1, 1, 0.0623333, 0.03, 1, 0, 0, 0, 1) +offsets = PackedFloat32Array(0, 0.148459, 0.29972, 0.840336) +colors = PackedColorArray(1, 0.0623333, 0.03, 1, 1, 1, 1, 1, 1, 1, 0.3, 1, 0.08736, 0.09, 0.0702, 1) [sub_resource type="GradientTexture1D" id="GradientTexture1D_d6li3"] gradient = SubResource("Gradient_tuj3x") -[sub_resource type="Curve" id="Curve_oo5uu"] -_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0842105, 1), 0.0, 0.0, 0, 0, Vector2(0.246316, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +[sub_resource type="Curve" id="Curve_kl03u"] +max_value = 3.0 +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.145, 3), 0.0, 0.0, 0, 0, Vector2(0.566, 3), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] point_count = 4 +[sub_resource type="CurveTexture" id="CurveTexture_auv7e"] +curve = SubResource("Curve_kl03u") + [sub_resource type="CurveTexture" id="CurveTexture_quj8c"] -curve = SubResource("Curve_oo5uu") +curve = ExtResource("1_rxjwh") [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_hjkte"] -lifetime_randomness = 0.52 -emission_shape = 3 -emission_box_extents = Vector3(1, 1, 1) +lifetime_randomness = 0.6 direction = Vector3(0, 0, 0) spread = 180.0 -initial_velocity_min = 4.0 +initial_velocity_min = -4.0 initial_velocity_max = 4.0 gravity = Vector3(0, 0, 0) -scale_min = 0.3 +scale_min = 0.75 +scale_max = 1.5 scale_curve = SubResource("CurveTexture_quj8c") color_ramp = SubResource("GradientTexture1D_d6li3") +emission_curve = SubResource("CurveTexture_auv7e") turbulence_enabled = true +turbulence_noise_strength = 0.2 +turbulence_noise_scale = 4.0 turbulence_noise_speed = Vector3(1, 1, 1) -turbulence_noise_speed_random = 1.41 [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fliyi"] +shading_mode = 0 vertex_color_use_as_albedo = true -emission_enabled = true +disable_receive_shadows = true billboard_mode = 3 billboard_keep_scale = true particles_anim_h_frames = 1 @@ -45,7 +53,9 @@ radius = 1.0 height = 2.0 [node name="ExplosionEffect" type="GPUParticles3D"] -lifetime = 0.7 +emitting = false +amount = 48 +one_shot = true explosiveness = 0.92 fixed_fps = 60 interpolate = false diff --git a/src/world/effects/explosion/intensity_curve.tres b/src/world/effects/explosion/intensity_curve.tres new file mode 100644 index 0000000..bb423b9 --- /dev/null +++ b/src/world/effects/explosion/intensity_curve.tres @@ -0,0 +1,5 @@ +[gd_resource type="Curve" format=3 uid="uid://b5vptoxuq3dwb"] + +[resource] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.145455, 1), 0.0, 0.0, 0, 0, Vector2(0.566234, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 4 diff --git a/src/world/world.tscn b/src/world/world.tscn index 3ac97a4..84221aa 100644 --- a/src/world/world.tscn +++ b/src/world/world.tscn @@ -2,8 +2,8 @@ [ext_resource type="Script" path="res://src/world/world.gd" id="1_ybjyx"] [ext_resource type="Script" path="res://src/player/world_player.gd" id="2_e743i"] -[ext_resource type="PackedScene" uid="uid://cvs546kk7t7aw" path="res://levels/terrain_test/terrain_test.tscn" id="2_hbpi4"] [ext_resource type="Script" path="res://src/ui/world_ui.gd" id="2_imewa"] +[ext_resource type="PackedScene" uid="uid://bm2o3mex10v11" path="res://levels/debug_level/debug_level.tscn" id="2_qsk3q"] [ext_resource type="Resource" uid="uid://crock3revdn73" path="res://src/player/debug_player.tres" id="3_pyw81"] [ext_resource type="Script" path="res://src/world/play_manager/practice_manager.gd" id="5_yk526"] [ext_resource type="PackedScene" uid="uid://byvjsvavbg5xe" path="res://src/ui/menus/pause_menu/pause_menu.tscn" id="7_0gd42"] @@ -155,7 +155,7 @@ _data = { [node name="World" type="Node" groups=["WorldGroup"]] script = ExtResource("1_ybjyx") -initial_level = ExtResource("2_hbpi4") +initial_level = ExtResource("2_qsk3q") manager = SubResource("Resource_hpydy") [node name="Level" type="Node3D" parent="."]