From 8ae0289271e20a1fabd94882b32beb5828111e0c Mon Sep 17 00:00:00 2001 From: Ileyan <3003916@stud.hs-mannheim.de> Date: Fri, 29 Mar 2024 18:09:51 +0100 Subject: [PATCH] =?UTF-8?q?v.0.5.2:=20Test=20button=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.gd | 9 +++++++-- game.tscn | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/game.gd b/game.gd index 9e815d0..7362f2e 100644 --- a/game.gd +++ b/game.gd @@ -31,7 +31,7 @@ func _process(_delta): if won == "": if Input.is_action_just_pressed("Click"): var grid_pos = board.gridpos_at_mouse() - if board.get_state(grid_pos) == board.empty_state: + if board.get_state(Vector2(grid_pos.x, 0)) == board.empty_state: var new_pos = board._calculate_drop_pos(grid_pos) if board.set_state(new_pos, player_states[current_player]): won = _check_win() @@ -101,7 +101,7 @@ func _roll_dice(): return zahl -#Funktion um Knop und Methode zu verbinden +#Funktion um Knopf und Methode zu verbinden func _on_dice_button_pressed(): _roll_dice() @@ -138,6 +138,7 @@ func _get_dice_pos_y(result: int) -> int: #Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert func _five_wins() -> void: + print("5 Gewinnt aktiv") #Debug five_wins = true #Nach dem Glücksradereignis tauschen die Spieler die Symbole @@ -152,3 +153,7 @@ func _instant_win(): wonPlayer.show() nextPlayer.hide() board.active = false + +#Zum Testen der Events +func _on_test_pressed(): + _five_wins() diff --git a/game.tscn b/game.tscn index a70d1d8..e82ba27 100644 --- a/game.tscn +++ b/game.tscn @@ -84,5 +84,14 @@ offset_bottom = 640.0 theme_override_font_sizes/font_size = 30 text = "Würfeln" +[node name="Test" type="Button" parent="GUI"] +offset_left = 24.0 +offset_top = 16.0 +offset_right = 248.0 +offset_bottom = 112.0 +theme_override_font_sizes/font_size = 35 +text = "Test" + [connection signal="pressed" from="GUI/RestartButton" to="." method="_on_restart_button_pressed"] [connection signal="pressed" from="GUI/DiceButton" to="." method="_on_dice_button_pressed"] +[connection signal="pressed" from="GUI/Test" to="." method="_on_test_pressed"]