v.0.3, Unnötige Statements rausgenommen lol

main
Ileyan Al Jaaf 2024-03-28 00:29:08 +01:00
parent 3226da488f
commit efa3f15ba4
1 changed files with 9 additions and 8 deletions

17
game.gd
View File

@ -3,8 +3,6 @@ extends Node2D
var current_player: int = 0
var player_states := ["Circle", "Cross"]
var won := ""
var tile_size : Vector2 = Vector2(32, 32) # Annahme: 32x32 Pixel pro Tile
var tileset_texture : Texture = preload("res://assets/sprites.png")
@onready var board := $Board as Board
@ -14,8 +12,6 @@ var tileset_texture : Texture = preload("res://assets/sprites.png")
@onready var diceSprite = $GUI/DiceSprite as Sprite2D
# Called when the node enters the scene tree for the first time.
func _ready():
current_player = 0
@ -27,8 +23,6 @@ func _ready():
board.active = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if won == "":
@ -49,9 +43,11 @@ func _process(_delta):
board.active = false
func _on_restart_button_pressed():
_ready()
var _checks = [
[Vector2i(-1,0), Vector2i(1,0)],
[Vector2i(0,-1), Vector2i(0,1)],
@ -59,7 +55,7 @@ var _checks = [
[Vector2i(-1,1), Vector2i(1,-1)],
]
func _check_win() -> String:
for cell in board.get_used_cells(board.layer_by_name[board.state_layer]):
var state = board.get_state(cell)
@ -74,6 +70,7 @@ func _check_win() -> String:
return state
return ""
#Generiert die Zufallszahl von 1-6
func _roll_dice():
var zahl = randi() % 6 + 1
@ -81,16 +78,19 @@ func _roll_dice():
print(zahl) #Debug ausgabe, später löschen lol
return zahl
#Funktion um Knop und Methode zu verbinden
func _on_dice_button_pressed():
_roll_dice()
#Sucht sich für die entsprechende Augenzahl
#die X und Y-Koordinaten in der Tilemap
func _update_dice_sprite(result :int):
diceSprite.region_rect.position.x = _get_dice_pos_x(result)
diceSprite.region_rect.position.y = _get_dice_pos_y(result)
#X-Koordinaten der Augenzahlen in der Tilemap
func _get_dice_pos_x(result: int) -> int:
match result:
@ -102,6 +102,7 @@ func _get_dice_pos_x(result: int) -> int:
6: return 208
return 8
#Y-Koordinaten in der Tilemap
func _get_dice_pos_y(result: int) -> int:
match result: