diff options
author | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 16:10:33 +0200 |
---|---|---|
committer | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 16:10:33 +0200 |
commit | d4a7159ddf728fbd6567c0e18963bc0ad580ad41 (patch) | |
tree | d8928f53218d3250386fd947f9fb7ba0ef5edc80 /godot | |
parent | 37569906966cc4cd33278c5e2ad0aae9755aee33 (diff) | |
parent | 226e2c15490a3aedde6fa244b4ff48fc1eddb4da (diff) | |
download | 2022-d4a7159ddf728fbd6567c0e18963bc0ad580ad41.tar.gz 2022-d4a7159ddf728fbd6567c0e18963bc0ad580ad41.tar.bz2 2022-d4a7159ddf728fbd6567c0e18963bc0ad580ad41.zip |
Merge branch 'main' of https://codeberg.org/code-your-friends/gmtk2022
Diffstat (limited to 'godot')
-rw-r--r-- | godot/assets/textures/circles.png | 3 | ||||
-rw-r--r-- | godot/assets/textures/circles.png.import | 3 | ||||
-rw-r--r-- | godot/scenes/Die.gd | 88 | ||||
-rw-r--r-- | godot/scenes/Die.tscn | 14 | ||||
-rw-r--r-- | godot/scenes/levels/MainMenu.tscn | 1 |
5 files changed, 92 insertions, 17 deletions
diff --git a/godot/assets/textures/circles.png b/godot/assets/textures/circles.png new file mode 100644 index 0000000..4e0f2a9 --- /dev/null +++ b/godot/assets/textures/circles.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb7e9f2f5de95391413875ac0dd0f720543dbf69fab1f9635ce60ea6006687ae +size 74928 diff --git a/godot/assets/textures/circles.png.import b/godot/assets/textures/circles.png.import new file mode 100644 index 0000000..1a9ac1c --- /dev/null +++ b/godot/assets/textures/circles.png.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5bd9f3320ba422578d5b451a13f83dacf76effedf87905570a549c540c964341 +size 909 diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd index c711cee..bae6c84 100644 --- a/godot/scenes/Die.gd +++ b/godot/scenes/Die.gd @@ -7,8 +7,11 @@ var camrot_v = 0 var camrot_v_locked_val = 0 var cam_v_min = -90 var cam_v_max = 90 -var sensitivity = 0.5 -var dice_is_moving = false +var sensitivity_cam = 0.5 +var sensitivity_charge = 2 +var dice_is_moving = true +var dice_is_still_since = 0 +var dice_still_timing = false var last_frame_position = Vector3(1.0,1.0,1.0) var mouse_origin = Vector2(0,0) var die_launch_force_magnitude = 0 @@ -18,10 +21,10 @@ var die_launch_force_multiplier = 0.05 var die_launch_force_magnitude_max = 1000 var left_pressed = false var mat -var target_bounce = 10 +var target_bounce = 1 var default_gravity = 2 var default_bounciness = 0 -var after_stroke = false +var after_stroke = true var curr_buff = buff.none @@ -41,10 +44,12 @@ func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) $CamRoot/Horizontal/Vertical/Camera.add_exception(self) $CamRoot.set_as_toplevel(true) + $PowerUI3D.set_as_toplevel(true) _game = get_node("/root/Game") mat = get_physics_material_override() mat.friction = 1 gravity_scale = default_gravity + $PowerUI3D/Arrow.hide() $PowerUI/PowerBar.hide() $PowerUI/PowerBar.max_value = die_launch_force_magnitude_max @@ -75,6 +80,8 @@ func _input(event): #mouse_origin = event.global_position die_launch_force_magnitude = 0 $PowerUI/PowerBar.show() + draw_arrow() + $PowerUI3D/Arrow.show() else: left_pressed = false @@ -86,19 +93,21 @@ func _input(event): if curr_buff != buff.ball: self.apply_torque_impulse(die_launch_force) $PowerUI/PowerBar.hide() + $PowerUI3D/Arrow.hide() _game.add_stroke() after_stroke = true #Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) # add one to counter if event is InputEventMouseMotion: - camrot_h += -event.relative.x * sensitivity + camrot_h += -event.relative.x * sensitivity_cam if left_pressed: camrot_v = camrot_v_locked_val - die_launch_force_magnitude += event.relative.y * sensitivity + die_launch_force_magnitude += event.relative.y * sensitivity_charge $PowerUI/PowerBar.value = die_launch_force_magnitude + draw_arrow() else: - camrot_v += -event.relative.y * sensitivity + camrot_v += -event.relative.y * sensitivity_cam func _physics_process(delta): @@ -109,22 +118,69 @@ func _physics_process(delta): $CamRoot.translation.x = translation.x $CamRoot.translation.y = translation.y + 5 $CamRoot.translation.z = translation.z + $PowerUI3D.translation.x = translation.x + $PowerUI3D.translation.y = translation.y + $PowerUI3D.translation.z = translation.z - if dice_is_moving == true and angular_velocity.length() < 0.1 and linear_velocity.length() < 0.1: - if curr_buff != buff.ball: - dice_is_moving = false - revert_current_buff() - if !after_stroke: - return + if dice_is_moving == true and dice_still_timing == false and angular_velocity.length() < 0.1 and linear_velocity.length() < 0.1: + print("stop morbin and start timing") + dice_is_still_since = OS.get_ticks_msec() + dice_still_timing = true + + elif dice_is_moving == false and after_stroke and (angular_velocity.length() >= 0.1 or linear_velocity.length() >= 0.1): + print("start morbin") + dice_still_timing = false + dice_is_moving = true + $PowerUI3D/SpriteCircles.hide() + + if after_stroke && dice_still_timing == true && (OS.get_ticks_msec() - dice_is_still_since) > 200: + print("stop timing while not morbin") + dice_is_moving = false after_stroke = false + dice_still_timing = false + $PowerUI3D/SpriteCircles.show() + revert_current_buff() var last_buff = curr_buff curr_buff = get_buff_from_upwards_side() if last_buff == curr_buff && curr_buff == buff.stroke: return apply_buff() - - elif dice_is_moving == false and angular_velocity.length() >= 0.1 and linear_velocity.length() >= 0.1: - dice_is_moving = true + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + var rot = $CamRoot/Horizontal/Vertical/Camera.get_global_transform().basis.get_euler() + $PowerUI3D.rotation_degrees.y = rad2deg(rot.y) + 180 + +func draw_arrow(): + var l = 1 + 5 * clamp(die_launch_force_magnitude, 0, die_launch_force_magnitude_max) / die_launch_force_magnitude_max + var vertices = PoolVector3Array([ + # base left + Vector3( 0.2, 0, 0), + Vector3( 0.2, 0, l), + Vector3(-0.2, 0, l), + # base right + Vector3( 0.2, 0, 0), + Vector3(-0.2, 0, l), + Vector3(-0.2, 0, 0), + # tip + Vector3( 0.4, 0, l), + Vector3(-0.0, 0, l + 0.4), + Vector3(-0.4, 0, l), + ]) + var st = SurfaceTool.new() + var m = SpatialMaterial.new() + var color = Color(0.9, 0.1, 0.1) + m.albedo_color = color + st.begin(Mesh.PRIMITIVE_TRIANGLES) + st.set_material(m) + for v in vertices.size(): + st.add_color(color) + st.add_uv(Vector2(0,0)) + st.add_vertex(vertices[v]) + var tmpMesh = Mesh.new() + st.commit(tmpMesh) + $PowerUI3D/Arrow.mesh = tmpMesh """ diff --git a/godot/scenes/Die.tscn b/godot/scenes/Die.tscn index 75f7223..5c96dbb 100644 --- a/godot/scenes/Die.tscn +++ b/godot/scenes/Die.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=10 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] +[ext_resource path="res://assets/textures/circles.png" type="Texture" id=3] [sub_resource type="PhysicsMaterial" id=7] friction = 0.0 @@ -147,3 +148,14 @@ margin_left = 64.0 margin_top = 44.0 margin_right = 1185.0 margin_bottom = 153.0 + +[node name="PowerUI3D" type="Spatial" parent="."] + +[node name="Arrow" type="MeshInstance" parent="PowerUI3D"] + +[node name="SpriteCircles" type="Sprite3D" parent="PowerUI3D"] +cast_shadow = 0 +opacity = 0.43 +pixel_size = 0.0071 +axis = 1 +texture = ExtResource( 3 ) diff --git a/godot/scenes/levels/MainMenu.tscn b/godot/scenes/levels/MainMenu.tscn index 5574b62..8b435df 100644 --- a/godot/scenes/levels/MainMenu.tscn +++ b/godot/scenes/levels/MainMenu.tscn @@ -58,6 +58,7 @@ script = ExtResource( 3 ) [node name="Camera" type="Camera" parent="."] transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 5, 0 ) +current = true [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] stream = ExtResource( 4 ) |