Compare commits

..

No commits in common. "8c1b431f84966040208f715d92003311640c255f" and "5f6e7a3e8ec68af5b790bf226e62cd0257f36290" have entirely different histories.

9 changed files with 16 additions and 87 deletions

View File

@ -8,8 +8,4 @@ CMKY: https://www.shadertoy.com/view/MltBW4
Fresnel: https://godotshaders.com/snippet/fresnel/ Fresnel: https://godotshaders.com/snippet/fresnel/
Code: Code:
occlussion shader: https://www.reddit.com/r/godot/comments/rww6e9/comment/hrfa51g/?utm_source=share&utm_medium=web2x&context=3 occlussion shader: https://www.reddit.com/r/godot/comments/rww6e9/comment/hrfa51g/?utm_source=share&utm_medium=web2x&context=3
Sound:
billiard-clack: https://freesound.org/people/Za-Games/sounds/539854/

Binary file not shown.

View File

@ -1,24 +0,0 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://c5v6c6x05lqg3"
path="res://.godot/imported/billiard-clack.wav-3f99ec74be11d1cb465d3dc06a94b10f.sample"
[deps]
source_file="res://audio/billiard-clack.wav"
dest_files=["res://.godot/imported/billiard-clack.wav-3f99ec74be11d1cb465d3dc06a94b10f.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -4,8 +4,7 @@ extends Node3D
@export var initial_target: Node3D @export var initial_target: Node3D
var target: Targetable = null var target: Targetable = null
@export var sensitivity := 0.01 @export var sensitivity := 0.01
@export var charge_time := 1.7 @export var charge_time := 2
@export var min_charge := 0.2
func _ready(): func _ready():
set_target(initial_target) set_target(initial_target)
@ -14,53 +13,26 @@ func get_charge():
return %radial_ui.charge_amount return %radial_ui.charge_amount
func _input(event): func _input(event):
var billiard := target.get_billiard()
if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0: if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0:
rotate_view(event.relative*sensitivity) rotate_view(event.relative*sensitivity)
if event.is_action_released("charge") and not billiard.can_hit and charge_tween != null: if event.is_action("charge"):
release()
if event.is_action_pressed("charge") and billiard.can_hit and charge_tween == null:
charge(event.get_action_strength("charge")) charge(event.get_action_strength("charge"))
func _process(_delta): func _process(_delta):
transform.origin = target.global_position transform.origin = target.global_position
camera.global_position = %camera_spot.global_position camera.global_position = %camera_spot.global_position
camera.look_at(target.global_position) camera.look_at(target.global_position)
if get_charge() >= 1.0:
cancel_charge()
func cancel_charge():
%radial_ui.set_charge(0.0)
%ChargeSound.stop()
if charge_tween != null:
charge_tween.kill()
charge_tween = null
var billiard := target.get_billiard()
billiard.can_hit = true
func release():
if get_charge() <= min_charge:
cancel_charge()
return
%ChargeReleaseSound.volume_db = get_charge() * 12
%ChargeReleaseSound.play()
var billiard := target.get_billiard()
billiard.hit((target.global_position - %camera_spot.global_position).normalized())
%radial_ui.set_charge(0.0)
%ChargeSound.stop()
if charge_tween != null:
charge_tween.kill()
charge_tween = null
var charge_tween: Tween = null var charge_tween: Tween = null
func charge(_amount: float): func charge(amount: float):
var billiard := target.get_billiard()
billiard.can_hit = false
if charge_tween != null: if charge_tween != null:
charge_tween.kill() charge_tween.kill()
if amount == 0.0:
%radial_ui.set_charge(0.0)
$AudioStreamPlayer.stop()
return
charge_tween = create_tween() charge_tween = create_tween()
charge_tween.tween_method(%radial_ui.set_charge, 0.0, 1.0, charge_time) charge_tween.tween_method(%radial_ui.set_charge, 0.0, 1.0, charge_time)
%ChargeSound.play() $AudioStreamPlayer.play()
func rotate_view(amount: Vector2): func rotate_view(amount: Vector2):
rotate_y(-amount.x) rotate_y(-amount.x)

View File

@ -1,9 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://drmb4sitb74fx"] [gd_scene load_steps=4 format=3 uid="uid://drmb4sitb74fx"]
[ext_resource type="Script" path="res://control_scheme/controller.gd" id="1_h3pjb"] [ext_resource type="Script" path="res://control_scheme/controller.gd" id="1_h3pjb"]
[ext_resource type="PackedScene" uid="uid://p2n48c8st55d" path="res://control_scheme/radial_ui.tscn" id="2_qidcb"] [ext_resource type="PackedScene" uid="uid://p2n48c8st55d" path="res://control_scheme/radial_ui.tscn" id="2_qidcb"]
[ext_resource type="AudioStream" uid="uid://ckhf7ksthi053" path="res://audio/charge.wav" id="3_exgm6"] [ext_resource type="AudioStream" uid="uid://ckhf7ksthi053" path="res://audio/charge.wav" id="3_exgm6"]
[ext_resource type="AudioStream" uid="uid://c5v6c6x05lqg3" path="res://audio/billiard-clack.wav" id="4_12r5s"]
[node name="controller" type="Node3D"] [node name="controller" type="Node3D"]
top_level = true top_level = true
@ -19,10 +18,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
[node name="radial_ui" parent="." instance=ExtResource("2_qidcb")] [node name="radial_ui" parent="." instance=ExtResource("2_qidcb")]
unique_name_in_owner = true unique_name_in_owner = true
[node name="ChargeSound" type="AudioStreamPlayer" parent="."] [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
unique_name_in_owner = true
stream = ExtResource("3_exgm6") stream = ExtResource("3_exgm6")
[node name="ChargeReleaseSound" type="AudioStreamPlayer" parent="."]
unique_name_in_owner = true
stream = ExtResource("4_12r5s")

View File

@ -6,9 +6,6 @@ class_name Targetable
static func is_targetable(node: Node3D) -> Targetable: static func is_targetable(node: Node3D) -> Targetable:
return node.get_node_or_null("is_targetable") return node.get_node_or_null("is_targetable")
func get_billiard() -> Billiard:
return get_parent()
func make_target(): func make_target():
walk_meshes_post_order(self.get_parent(), change_all_materials) walk_meshes_post_order(self.get_parent(), change_all_materials)

View File

@ -33,8 +33,7 @@ _subresources={
"PATH:grape2": { "PATH:grape2": {
"generate/physics": true, "generate/physics": true,
"physics/body_type": 1, "physics/body_type": 1,
"physics/shape_type": 4, "physics/shape_type": 1
"primitive/radius": 0.03
} }
} }
} }

View File

@ -1,7 +1 @@
extends RigidBody3D extends RigidBody3D
class_name Billiard
var can_hit = true
func hit(impulse: Vector3):
apply_central_impulse(impulse)

View File

@ -22,10 +22,11 @@ camera = NodePath("Camera3D")
initial_target = NodePath("../grape") initial_target = NodePath("../grape")
[node name="Camera3D" type="Camera3D" parent="controller" index="1"] [node name="Camera3D" type="Camera3D" parent="controller" index="1"]
current = true
[node name="grape" parent="." index="4" instance=ExtResource("3_gijly")] [node name="billiard" parent="." index="4" instance=ExtResource("3_gijly")]
[node name="grape" parent="." index="5" instance=ExtResource("3_gijly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56762, 0.385236) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56762, 0.385236)
[node name="grape2" parent="." index="5" instance=ExtResource("3_gijly")] [node name="grape2" parent="." index="6" instance=ExtResource("3_gijly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.60495, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.60495, 0)