v.0.6.1
- Wheel Spin ist jetzt locked -> Man kann nicht mehrmals drehen -> Es kann nur bei einer 6 gedreht werden - Es kann nicht mehrmals gewürfelt werdenmain
parent
376dade17c
commit
42a002e5d2
19
game.gd
19
game.gd
|
@ -5,9 +5,13 @@ var player_states := ["Circle", "Cross"]
|
||||||
var won := ""
|
var won := ""
|
||||||
var sequence_needed = 4
|
var sequence_needed = 4
|
||||||
var _sequence = []
|
var _sequence = []
|
||||||
var enable_remove = true
|
var enable_remove = false
|
||||||
var move_allowed = true
|
var move_allowed = true
|
||||||
var zuege = 0
|
var zuege = 0
|
||||||
|
var wuerfeln_erlaubt = false
|
||||||
|
var wheel_spin_allowed = false
|
||||||
|
var active = Theme.new()
|
||||||
|
|
||||||
|
|
||||||
@onready var gui := $GUI as Node2D
|
@onready var gui := $GUI as Node2D
|
||||||
@onready var board := $Board as Board
|
@onready var board := $Board as Board
|
||||||
|
@ -21,10 +25,15 @@ var zuege = 0
|
||||||
@onready var sequenz = $GUI/Sequenz as Label
|
@onready var sequenz = $GUI/Sequenz as Label
|
||||||
@onready var schnick = $Schnick
|
@onready var schnick = $Schnick
|
||||||
@onready var numbers = $Numbers as TileMap
|
@onready var numbers = $Numbers as TileMap
|
||||||
|
@onready var spinButton = $GUI/WheelSpin as Button
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
current_player = 0
|
current_player = 0
|
||||||
|
zuege = 0
|
||||||
|
wuerfeln_erlaubt = false
|
||||||
|
move_allowed = true
|
||||||
|
wheel_spin_allowed = false
|
||||||
sequence_needed = 4
|
sequence_needed = 4
|
||||||
board.reset()
|
board.reset()
|
||||||
won = ""
|
won = ""
|
||||||
|
@ -51,6 +60,7 @@ func _process(_delta):
|
||||||
if board.set_state(new_pos, player_states[current_player]):
|
if board.set_state(new_pos, player_states[current_player]):
|
||||||
if zuege >= 1:
|
if zuege >= 1:
|
||||||
move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2)
|
move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2)
|
||||||
|
wuerfeln_erlaubt = true
|
||||||
zuege += 1
|
zuege += 1
|
||||||
won = _check_win()
|
won = _check_win()
|
||||||
if won=="":
|
if won=="":
|
||||||
|
@ -104,6 +114,7 @@ func _check_win() -> String:
|
||||||
|
|
||||||
#Generiert die Zufallszahl von 1-6
|
#Generiert die Zufallszahl von 1-6
|
||||||
func _roll_dice() -> int:
|
func _roll_dice() -> int:
|
||||||
|
wuerfeln_erlaubt = false
|
||||||
var zahl = randi() % 6 + 1
|
var zahl = randi() % 6 + 1
|
||||||
var animation_help
|
var animation_help
|
||||||
var zahl_davor
|
var zahl_davor
|
||||||
|
@ -121,16 +132,20 @@ func _roll_dice() -> int:
|
||||||
switch_to_schnick()
|
switch_to_schnick()
|
||||||
if zahl == 6:
|
if zahl == 6:
|
||||||
move_allowed = false
|
move_allowed = false
|
||||||
|
wheel_spin_allowed = true
|
||||||
|
|
||||||
return zahl
|
return zahl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Funktion um Knopf und Methode zu verbinden
|
#Funktion um Knopf und Methode zu verbinden
|
||||||
func _on_dice_button_pressed():
|
func _on_dice_button_pressed():
|
||||||
|
if wuerfeln_erlaubt:
|
||||||
move_allowed = true
|
move_allowed = true
|
||||||
_roll_dice()
|
_roll_dice()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Sucht sich für die entsprechende Augenzahl
|
#Sucht sich für die entsprechende Augenzahl
|
||||||
#die X und Y-Koordinaten in der Tilemap
|
#die X und Y-Koordinaten in der Tilemap
|
||||||
func _update_dice_sprite(result :int):
|
func _update_dice_sprite(result :int):
|
||||||
|
@ -204,6 +219,7 @@ func _on_test_pressed():
|
||||||
|
|
||||||
|
|
||||||
func _spin_the_wheel(result: int) -> void:
|
func _spin_the_wheel(result: int) -> void:
|
||||||
|
wheel_spin_allowed = false
|
||||||
move_allowed = true
|
move_allowed = true
|
||||||
ereignis.text = "Ereignis: "
|
ereignis.text = "Ereignis: "
|
||||||
if result <= 3:
|
if result <= 3:
|
||||||
|
@ -241,6 +257,7 @@ func _spin_the_wheel(result: int) -> void:
|
||||||
|
|
||||||
#Am Glücksrad drehen
|
#Am Glücksrad drehen
|
||||||
func _on_spin_the_wheel_pressed():
|
func _on_spin_the_wheel_pressed():
|
||||||
|
if wheel_spin_allowed:
|
||||||
var zahl = randi() % 100 + 1
|
var zahl = randi() % 100 + 1
|
||||||
_spin_the_wheel(zahl)
|
_spin_the_wheel(zahl)
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ rotation = 0.000312189
|
||||||
theme_override_font_sizes/font_size = 35
|
theme_override_font_sizes/font_size = 35
|
||||||
text = "Test"
|
text = "Test"
|
||||||
|
|
||||||
[node name="Spin the Wheel" type="Button" parent="GUI"]
|
[node name="WheelSpin" type="Button" parent="GUI"]
|
||||||
offset_left = 1351.0
|
offset_left = 1351.0
|
||||||
offset_top = 592.0
|
offset_top = 592.0
|
||||||
offset_right = 1581.0
|
offset_right = 1581.0
|
||||||
|
@ -113,6 +113,7 @@ theme_override_font_sizes/font_size = 60
|
||||||
text = "Player 1:"
|
text = "Player 1:"
|
||||||
|
|
||||||
[node name="Player1Sprite" type="Sprite2D" parent="GUI"]
|
[node name="Player1Sprite" type="Sprite2D" parent="GUI"]
|
||||||
|
texture_filter = 1
|
||||||
position = Vector2(412, 518.15)
|
position = Vector2(412, 518.15)
|
||||||
scale = Vector2(1.137, 1.05)
|
scale = Vector2(1.137, 1.05)
|
||||||
texture = ExtResource("3_0333r")
|
texture = ExtResource("3_0333r")
|
||||||
|
@ -128,6 +129,7 @@ theme_override_font_sizes/font_size = 60
|
||||||
text = "Player 2:"
|
text = "Player 2:"
|
||||||
|
|
||||||
[node name="Player2Sprite" type="Sprite2D" parent="GUI"]
|
[node name="Player2Sprite" type="Sprite2D" parent="GUI"]
|
||||||
|
texture_filter = 1
|
||||||
position = Vector2(412, 662.3)
|
position = Vector2(412, 662.3)
|
||||||
scale = Vector2(1.04, 1.05)
|
scale = Vector2(1.04, 1.05)
|
||||||
texture = ExtResource("3_0333r")
|
texture = ExtResource("3_0333r")
|
||||||
|
@ -202,6 +204,6 @@ text = "Nein"
|
||||||
[connection signal="pressed" from="GUI/RestartButton" to="." method="_on_restart_button_pressed"]
|
[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/DiceButton" to="." method="_on_dice_button_pressed"]
|
||||||
[connection signal="pressed" from="GUI/Test" to="." method="_on_test_pressed"]
|
[connection signal="pressed" from="GUI/Test" to="." method="_on_test_pressed"]
|
||||||
[connection signal="pressed" from="GUI/Spin the Wheel" to="." method="_on_spin_the_wheel_pressed"]
|
[connection signal="pressed" from="GUI/WheelSpin" to="." method="_on_spin_the_wheel_pressed"]
|
||||||
[connection signal="pressed" from="Schnick/Gewonnen" to="." method="_on_gewonnen_pressed"]
|
[connection signal="pressed" from="Schnick/Gewonnen" to="." method="_on_gewonnen_pressed"]
|
||||||
[connection signal="pressed" from="Schnick/Verloren" to="." method="_on_verloren_pressed"]
|
[connection signal="pressed" from="Schnick/Verloren" to="." method="_on_verloren_pressed"]
|
||||||
|
|
Loading…
Reference in New Issue