This commit is contained in:
karl 2019-11-24 15:39:10 +01:00
commit 30a2d18dbe
4 changed files with 61 additions and 51 deletions

View File

@ -89,20 +89,23 @@ func _process_input():
if Input.is_action_pressed("move_right"): if Input.is_action_pressed("move_right"):
input_movement_vector.x += 1 input_movement_vector.x += 1
# look around with controller
var look = Vector2()
look.x = -Input.get_action_strength("cam_move_left") + Input.get_action_strength("cam_move_right")
look.y = +Input.get_action_strength("cam_move_down") - Input.get_action_strength("cam_move_up")
#Logger.info("look at: " + String(look))
_camera.rotate_x(deg2rad(look.y * -1))
self.rotate_y(deg2rad(look.x * -1))
# Prevent player from doing a purzelbaum
_camera.rotation_degrees.x = clamp(_camera.rotation_degrees.x, -70, 70)
# look around with mouse # look around with mouse
_dir = Vector3() _dir = Vector3()
var camera_transform = _camera.get_global_transform() var camera_transform = _camera.get_global_transform()
_dir += -camera_transform.basis.z * input_movement_vector.y _dir += -camera_transform.basis.z * input_movement_vector.y
_dir += camera_transform.basis.x * input_movement_vector.x _dir += camera_transform.basis.x * input_movement_vector.x
# look around with controller
#var look = Vector2()
#look.x = -Input.get_action_strength("cam_move_left") + Input.get_action_strength("cam_move_right")
#look.y = +Input.get_action_strength("cam_move_down") - Input.get_action_strength("cam_move_up")
##Logger.info("look at: " + String(look))
##Input.warp_mouse_position(look)
#look_at(Vector3(look.x, look.y, 1), Vector3.UP)
# jumping # jumping
if Input.is_action_just_pressed("move_jump") and is_on_floor(): if Input.is_action_just_pressed("move_jump") and is_on_floor():
_vel.y = JUMP_SPEED _vel.y = JUMP_SPEED

View File

@ -80,6 +80,7 @@ unit_db = -10.0
pitch_scale = 1.5 pitch_scale = 1.5
[node name="HUD" parent="." instance=ExtResource( 4 )] [node name="HUD" parent="." instance=ExtResource( 4 )]
gameover_sound_path = NodePath("../GameOverSound")
collect_sound_path = NodePath("../CollectSound") collect_sound_path = NodePath("../CollectSound")
[node name="GameOverSound" type="AudioStreamPlayer" parent="."] [node name="GameOverSound" type="AudioStreamPlayer" parent="."]

View File

@ -84,8 +84,8 @@ func _endGame (value):
Collector.Clear() Collector.Clear()
_popup.get_node("LabelWon").visible = value _popup.get_node("CenterContainer/Container/LabelWon").visible = value
_popup.get_node("LabelFail").visible = !value _popup.get_node("CenterContainer/Container/LabelFail").visible = !value
_popup.get_node("PanelWon").visible = value _popup.get_node("PanelWon").visible = value
_popup.get_node("PanelFail").visible = !value _popup.get_node("PanelFail").visible = !value

View File

@ -6,66 +6,72 @@
margin_right = 40.0 margin_right = 40.0
margin_bottom = 40.0 margin_bottom = 40.0
script = ExtResource( 1 ) script = ExtResource( 1 )
popup_nodepath = NodePath("../HUD/Popup") popup_nodepath = NodePath("Popup")
gameover_sound_path = NodePath("../GameOverSound")
container_path = NodePath("GridContainer") container_path = NodePath("GridContainer")
[node name="Popup" type="Popup" parent="."] [node name="Popup" type="Popup" parent="."]
editor/display_folded = true
visible = true visible = true
margin_left = 383.0 anchor_right = 1.0
margin_top = 187.0 anchor_bottom = 1.0
margin_right = 530.0
margin_bottom = 289.0
[node name="PanelFail" type="Panel" parent="Popup"] [node name="PanelFail" type="Panel" parent="Popup"]
modulate = Color( 0.996078, 0, 0, 1 ) modulate = Color( 0.996078, 0, 0, 1 )
margin_left = -383.0 anchor_right = 1.0
margin_top = -187.36 anchor_bottom = 1.0
margin_right = 641.0
margin_bottom = 412.64
[node name="PanelWon" type="Panel" parent="Popup"] [node name="PanelWon" type="Panel" parent="Popup"]
modulate = Color( 0.0313726, 0, 0.996078, 1 ) modulate = Color( 0.0313726, 0, 0.996078, 1 )
margin_left = -383.0 anchor_right = 1.0
margin_top = -187.36 anchor_bottom = 1.0
margin_right = 641.0
margin_bottom = 412.64
[node name="LabelWon" type="Label" parent="Popup"] [node name="CenterContainer" type="CenterContainer" parent="Popup"]
margin_left = 87.064 anchor_right = 1.0
margin_top = 24.4867 anchor_bottom = 1.0
margin_right = 169.064
margin_bottom = 72.4867
text = "Gratulations!
You Won!" [node name="Container" type="Control" parent="Popup/CenterContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 20.0
margin_bottom = 20.0
[node name="LabelFail" type="Label" parent="Popup"] [node name="LabelFail" type="Label" parent="Popup/CenterContainer/Container"]
margin_left = 88.9828 margin_left = 10.0
margin_top = 28.0094 margin_top = -24.0
margin_right = 168.983 margin_right = 80.0
margin_bottom = 76.0094 margin_bottom = 24.0
text = " You died! text = " You died!
Game over" Game over"
[node name="Button" type="Button" parent="Popup"] [node name="LabelWon" type="Label" parent="Popup/CenterContainer/Container"]
margin_left = 86.5054 margin_left = 10.0
margin_top = 144.902 margin_top = -24.0
margin_right = 179.505 margin_right = 92.0
margin_bottom = 181.902 margin_bottom = 24.0
text = "play again" text = "Gratulations!
[node name="ProgressBar" type="ProgressBar" parent="."] You Won!"
margin_left = 410.651
margin_top = 560.551 [node name="Button" type="Button" parent="Popup/CenterContainer/Container"]
margin_right = 614.651 margin_left = -33.0
margin_bottom = 582.551 margin_top = 49.0
step = 1.0 margin_right = 120.0
value = 100.0 margin_bottom = 126.0
text = "play again"
[node name="GridContainer" type="GridContainer" parent="."] [node name="GridContainer" type="GridContainer" parent="."]
margin_right = 250.0 margin_right = 250.0
margin_bottom = 150.0 margin_bottom = 150.0
[connection signal="pressed" from="Popup/Button" to="." method="_on_Button_pressed"]
[node name="ProgressBar" type="ProgressBar" parent="."]
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = 405.248
margin_top = 613.044
margin_right = 615.248
margin_bottom = 658.044
rect_min_size = Vector2( 250, 45 )
step = 1.0
value = 100.0
[connection signal="pressed" from="Popup/CenterContainer/Container/Button" to="." method="_on_Button_pressed"]