From efa3f15ba4d24b32ea8681091edc9b3bc86266f7 Mon Sep 17 00:00:00 2001 From: Ileyan Al Jaaf <3003916@stud.hs-mannheim.de> Date: Thu, 28 Mar 2024 00:29:08 +0100 Subject: [PATCH] =?UTF-8?q?v.0.3,=20Unn=C3=B6tige=20Statements=20rausgenom?= =?UTF-8?q?men=20lol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.gd | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/game.gd b/game.gd index 33dcff1..66b8b5d 100644 --- a/game.gd +++ b/game.gd @@ -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: