diff options
author | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 02:33:03 +0200 |
---|---|---|
committer | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 02:33:03 +0200 |
commit | 0e6b438cbb8d894c5d4d31a50a6e87a89d230b91 (patch) | |
tree | c9e6cf1dba7907cd3909e82ead95e770db3e7b7d /godot/scenes | |
parent | 612e037bc85b815865c6019eb9be87d731e14d30 (diff) | |
download | 2022-0e6b438cbb8d894c5d4d31a50a6e87a89d230b91.tar.gz 2022-0e6b438cbb8d894c5d4d31a50a6e87a89d230b91.tar.bz2 2022-0e6b438cbb8d894c5d4d31a50a6e87a89d230b91.zip |
very scuffed detection which way the die faces
the mapping of the buffs might be incorrect
Diffstat (limited to 'godot/scenes')
-rw-r--r-- | godot/scenes/Die.gd | 82 | ||||
-rw-r--r-- | godot/scenes/Die.tscn | 32 |
2 files changed, 100 insertions, 14 deletions
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd index 407f248..62d1d99 100644 --- a/godot/scenes/Die.gd +++ b/godot/scenes/Die.gd @@ -1,4 +1,4 @@ -extends Spatial +extends RigidBody const Game = preload("res://scenes/Game.gd") @@ -14,6 +14,10 @@ var dragging = false var mouse_origin = Vector2(0,0) var dice_launch_force = 0 +var mat +var target_bounce = 1 +var previous_bounciness = 0 + var _game: Game = null # Called when the node enters the scene tree for the first time. @@ -22,9 +26,13 @@ func _ready(): $CamRoot/Horizontal/Vertical/Camera.add_exception(self) $CamRoot.set_as_toplevel(true) _game = get_node("/root/Game") + mat = get_physics_material_override() + previous_bounciness = mat.get_bounce() + ball() + -func _input(event): +func _input(event): if event is InputEventKey: if event.scancode == KEY_TAB: if event.is_pressed(): @@ -51,11 +59,8 @@ func _input(event): elif dragging and not event.pressed: dragging = false Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - - - - - + + func _physics_process(delta): camrot_v = clamp(camrot_v, cam_v_min, cam_v_max) @@ -69,6 +74,9 @@ func _physics_process(delta): dice_is_moving = true else: dice_is_moving = false + + if angular_velocity.length() == 0: + get_upwards_side() last_frame_position = Vector3(translation.x, translation.y, translation.x) @@ -76,3 +84,63 @@ func _physics_process(delta): # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass + + +""" +BUFFS +""" + +func get_upwards_side(): + var forward = -global_transform.basis.z + + var up = forward.angle_to(Vector3.UP) + var down = forward.angle_to(Vector3.DOWN) + var left = forward.angle_to(Vector3.LEFT) + var right = forward.angle_to(Vector3.RIGHT) + var forw = forward.angle_to(Vector3.FORWARD) + var back = forward.angle_to(Vector3.BACK) + + # 0 = ball, 1 = phase, 2 = bounce + var dictionary = { + up: 0, + down: 1, + left: 2, + right: 0, + forw: 1, + back: 2 + } + + var smallest = dictionary.keys().min() + return dictionary[smallest] + + +func extra_stroke(): + _game.revoke_stroke() + + +func bounciness(): + mat.set_bounce(target_bounce) + + +func bounciness_revert(): + mat.set_bounce(previous_bounciness) + + +func phase(): + set_collision_layer_bit(2, false) + + +func phase_revert(): + set_collision_layer_bit(2, true) + + +func ball(): + $BallShape.show() + $BallShape.set_process(true) + $BallShape.disabled = false + + +func ball_revert(): + $BallShape.hide() + $BallShape.set_process(false) + $BallShape.disabled = true diff --git a/godot/scenes/Die.tscn b/godot/scenes/Die.tscn index 813f7b7..2d73734 100644 --- a/godot/scenes/Die.tscn +++ b/godot/scenes/Die.tscn @@ -1,8 +1,13 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://scenes/Die.gd" type="Script" id=1] [ext_resource path="res://assets/game_objects/W8baseColor_Mat.material" type="Material" id=2] +[sub_resource type="PhysicsMaterial" id=3] + +[sub_resource type="ConvexPolygonShape" id=2] +points = PoolVector3Array( -0.0850063, -0.879389, -0.0282584, 0.0288993, 0.929375, 0.0289349, 0.0288993, 0.929375, -0.0289349, 0.929367, -0.0289314, 0.0289314, -0.0289784, -0.0289338, 0.929338, -0.929369, 0.028929, 0.028929, 0.0288993, -0.0289349, -0.929375, 0.0288993, -0.929375, 0.0289349, -0.0850063, 0.0282584, -0.879389, 0.0282247, 0.084959, 0.87945, 0.857489, 0.056933, -0.0855785, -0.879454, -0.0849424, 0.0282549, 0.0570775, -0.885814, -0.0571088, 0.0570775, -0.0571088, 0.885814, -0.0571532, 0.885743, -0.0571043, -0.0571532, 0.885743, 0.0571043, 0.0570775, 0.0571088, -0.885814, -0.885806, -0.057097, -0.057097, 0.879446, 0.0849494, 0.0282572, 0.857335, -0.0571018, -0.0855632, -0.0571532, 0.0571043, 0.885743, -0.0571532, -0.885743, 0.0571043, -0.885806, 0.057097, -0.057097, -0.0571532, -0.0571043, -0.885743, 0.0570775, 0.0571088, 0.885814, -0.0571532, -0.885743, -0.0571043, -0.0571532, 0.0571043, -0.885743, 0.0570775, -0.885814, 0.0571088, 0.0570775, 0.885814, 0.0571088, -0.0571532, -0.0571043, 0.885743, -0.885806, 0.057097, 0.057097, 0.0570775, 0.885814, -0.0571088, 0.0570775, -0.0571088, -0.885814, 0.857335, -0.0571018, 0.0855632, -0.885806, -0.057097, 0.057097, 0.857489, 0.056933, 0.0855785, 0.929425, 0.0287513, -0.0289333, 0.929367, -0.0289314, -0.0289314, -0.0289784, 0.929338, -0.0289338, 0.0288993, 0.0289349, -0.929375, -0.929369, -0.028929, -0.028929, -0.0283039, -0.87942, -0.0849561, 0.084933, 0.0282608, 0.879461, -0.0289784, 0.929338, 0.0289338, -0.0289784, -0.0289338, -0.929338, -0.0289784, 0.0289338, 0.929338, 0.0288993, -0.0289349, 0.929375, 0.0288993, -0.929375, -0.0289349, -0.0289784, -0.929338, 0.0289338, -0.929369, 0.028929, -0.028929, -0.0283039, 0.0849561, -0.87942, -0.879454, -0.0282549, 0.0849424, 0.879512, 0.0280816, 0.0849558, 0.879446, -0.0849494, -0.0282572, -0.0282988, -0.822574, 0.141805, 0.17021, 0.0280745, -0.794261, -0.879454, 0.0849424, -0.0282549, -0.0283039, 0.87942, 0.0849561, 0.0282247, 0.87945, -0.084959, 0.0282247, -0.084959, -0.87945, -0.879454, -0.0282549, -0.0849424, -0.0850063, 0.0282584, 0.879389, -0.0850063, 0.879389, 0.0282584, 0.084933, -0.0282608, 0.879461 ) + [sub_resource type="ArrayMesh" id=1] resource_name = "W8_Cone" surfaces/0 = { @@ -18,19 +23,32 @@ surfaces/0 = { "vertex_count": 68 } -[sub_resource type="ConvexPolygonShape" id=2] -points = PoolVector3Array( -0.0850063, -0.879389, -0.0282584, 0.0288993, 0.929375, 0.0289349, 0.0288993, 0.929375, -0.0289349, 0.929367, -0.0289314, 0.0289314, -0.0289784, -0.0289338, 0.929338, -0.929369, 0.028929, 0.028929, 0.0288993, -0.0289349, -0.929375, 0.0288993, -0.929375, 0.0289349, -0.0850063, 0.0282584, -0.879389, 0.0282247, 0.084959, 0.87945, 0.857489, 0.056933, -0.0855785, -0.879454, -0.0849424, 0.0282549, 0.0570775, -0.885814, -0.0571088, 0.0570775, -0.0571088, 0.885814, -0.0571532, 0.885743, -0.0571043, -0.0571532, 0.885743, 0.0571043, 0.0570775, 0.0571088, -0.885814, -0.885806, -0.057097, -0.057097, 0.879446, 0.0849494, 0.0282572, 0.857335, -0.0571018, -0.0855632, -0.0571532, 0.0571043, 0.885743, -0.0571532, -0.885743, 0.0571043, -0.885806, 0.057097, -0.057097, -0.0571532, -0.0571043, -0.885743, 0.0570775, 0.0571088, 0.885814, -0.0571532, -0.885743, -0.0571043, -0.0571532, 0.0571043, -0.885743, 0.0570775, -0.885814, 0.0571088, 0.0570775, 0.885814, 0.0571088, -0.0571532, -0.0571043, 0.885743, -0.885806, 0.057097, 0.057097, 0.0570775, 0.885814, -0.0571088, 0.0570775, -0.0571088, -0.885814, 0.857335, -0.0571018, 0.0855632, -0.885806, -0.057097, 0.057097, 0.857489, 0.056933, 0.0855785, 0.929425, 0.0287513, -0.0289333, 0.929367, -0.0289314, -0.0289314, -0.0289784, 0.929338, -0.0289338, 0.0288993, 0.0289349, -0.929375, -0.929369, -0.028929, -0.028929, -0.0283039, -0.87942, -0.0849561, 0.084933, 0.0282608, 0.879461, -0.0289784, 0.929338, 0.0289338, -0.0289784, -0.0289338, -0.929338, -0.0289784, 0.0289338, 0.929338, 0.0288993, -0.0289349, 0.929375, 0.0288993, -0.929375, -0.0289349, -0.0289784, -0.929338, 0.0289338, -0.929369, 0.028929, -0.028929, -0.0283039, 0.0849561, -0.87942, -0.879454, -0.0282549, 0.0849424, 0.879512, 0.0280816, 0.0849558, 0.879446, -0.0849494, -0.0282572, -0.0282988, -0.822574, 0.141805, 0.17021, 0.0280745, -0.794261, -0.879454, 0.0849424, -0.0282549, -0.0283039, 0.87942, 0.0849561, 0.0282247, 0.87945, -0.084959, 0.0282247, -0.084959, -0.87945, -0.879454, -0.0282549, -0.0849424, -0.0850063, 0.0282584, 0.879389, -0.0850063, 0.879389, 0.0282584, 0.084933, -0.0282608, 0.879461 ) +[sub_resource type="SphereShape" id=4] + +[sub_resource type="SphereMesh" id=5] [node name="Die" type="RigidBody"] +collision_mask = 3 +physics_material_override = SubResource( 3 ) script = ExtResource( 1 ) -[node name="Cone" type="MeshInstance" parent="."] +[node name="CollisionShape" type="CollisionShape" parent="."] +shape = SubResource( 2 ) + +[node name="Cone" type="MeshInstance" parent="CollisionShape"] mesh = SubResource( 1 ) -skeleton = NodePath("../..") +skeleton = NodePath("../../..") material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="."] -shape = SubResource( 2 ) +[node name="BallShape" type="CollisionShape" parent="."] +visible = false +shape = SubResource( 4 ) +disabled = true + +[node name="Ball" type="MeshInstance" parent="BallShape"] +mesh = SubResource( 5 ) +skeleton = NodePath("../..") +material/0 = null [node name="CamRoot" type="Spatial" parent="."] |