diff --git a/Battle Pong/GameSettings.gd b/Battle Pong/GameSettings.gd index d1475837190b8896ae27ffe77fca43fcae15da0e..68109b6f51d00ec4443ff6dc54f513b7d3d06f32 100644 --- a/Battle Pong/GameSettings.gd +++ b/Battle Pong/GameSettings.gd @@ -2,6 +2,7 @@ extends Node export var rendering_enabled = false export var learn_with_images = true +export var trainings_mode_enabled = false var game_playtime_per_step diff --git a/Battle Pong/Main.gd b/Battle Pong/Main.gd index e6331942ebf67d085db8e2f5518602f2e64b3ca5..293e7430418be2d0040bdfc0765d96a98b5383c4 100644 --- a/Battle Pong/Main.gd +++ b/Battle Pong/Main.gd @@ -254,12 +254,20 @@ func _on_data(id): return_value = get_return_value_as_utf8_JSON() _server.get_peer(id).put_packet(return_value) pass - if(next_step_player_one and next_step_player_two): + if($"/root/GameSettings".trainings_mode_enabled): + if(($"/root/GameSettings".trainer_position == "Left" and next_step_player_two) or ($"/root/GameSettings".trainer_position == "Right" and next_step_player_one)): + unpause() + $PlayerOne.run(game_playtime_per_step) + $PlayerTwo.run(game_playtime_per_step) + ball.run(game_playtime_per_step) + timeout() + elif(next_step_player_one and next_step_player_two): unpause() $PlayerOne.run(game_playtime_per_step) $PlayerTwo.run(game_playtime_per_step) ball.run(game_playtime_per_step) timeout() + func get_observarion(): return {"PlayerOne":{"X":$PlayerOne.position.x,"Y":$PlayerOne.position.y}, "PlayerTwo":{"X":$PlayerTwo.position.x,"Y":$PlayerTwo.position.y}, "ball":ball.get_observation()} @@ -334,3 +342,8 @@ func unpause(): $PlayerOne.set_pause(false) $PlayerTwo.set_pause(false) + +# Wenn Trainerfunktion aktiv ist wird für einen menschlichen Spieler der Playtimer gestartet und die Eingabe +func _on_Playtimer_timeout(): + + pass # Replace with function body. diff --git a/Battle Pong/Main.tscn b/Battle Pong/Main.tscn index 804fb3c80b00779c5b5433de80de94b16fbca3dc..92314128a94f3ee4083e02600ff43288c6f285c7 100644 --- a/Battle Pong/Main.tscn +++ b/Battle Pong/Main.tscn @@ -79,5 +79,9 @@ __meta__ = { [node name="WallBottom" parent="." instance=ExtResource( 3 )] position = Vector2( 0, 600 ) + +[node name="Playtimer" type="Timer" parent="."] +one_shot = true [connection signal="hit" from="PlayerTwo" to="." method="_on_PlayerTwo_hit"] [connection signal="hit" from="PlayerOne" to="." method="_on_PlayerOne_hit"] +[connection signal="timeout" from="Playtimer" to="." method="_on_Playtimer_timeout"] diff --git a/Battle Pong/MainMenu.gd b/Battle Pong/MainMenu.gd index f879f3ee688cb0d2c7148f2ec925050d9e5b08c5..6b66d933ecfde2333e08bbfbd05e063023e1508b 100644 --- a/Battle Pong/MainMenu.gd +++ b/Battle Pong/MainMenu.gd @@ -18,13 +18,15 @@ func _on_but_local_two_player_pressed(): func _on_but_two_re_with_images_pressed(): $"/root/GameSettings".rendering_enabled = true $"/root/GameSettings".learn_with_images = true + $"/root/GameSettings".trainings_mode_enabled = false get_tree().change_scene("res://Main.tscn") - pass # Replace with function body. + func _on_but_two_re_with_position_pressed(): $"/root/GameSettings".rendering_enabled = $vbox_two_learner/HBoxContainer/cb_rendering_enabled.is_pressed() $"/root/GameSettings".learn_with_images = false + $"/root/GameSettings".trainings_mode_enabled = false if not $"/root/GameSettings".rendering_enabled: $vbox_two_learner.hide() $lbl_game_running.show() @@ -33,7 +35,7 @@ func _on_but_two_re_with_position_pressed(): yield(VisualServer, "frame_post_draw") print("Rendering is disabled") get_tree().change_scene("res://Main.tscn") - pass # Replace with function body. + func _on_cb_rendering_enabled_pressed(): @@ -43,18 +45,23 @@ func _on_cb_rendering_enabled_pressed(): else: $lbl_game_running.show() print($"/root/GameSettings".rendering_enabled) - pass # Replace with function body. + func _on_but_trainer_with_images_pressed(): - - pass # Replace with function body. + $"/root/GameSettings".rendering_enabled = true + $"/root/GameSettings".learn_with_images = true + $"/root/GameSettings".trainings_mode_enabled = true + func _on_but_trainer_with_position_pressed(): - pass # Replace with function body. + $"/root/GameSettings".rendering_enabled = true + $"/root/GameSettings".learn_with_images = false + $"/root/GameSettings".trainings_mode_enabled = true + func _on_but_settings_pressed(): get_tree().change_scene("res://SettingsWindow.tscn") - pass # Replace with function body. +