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

13
game.gd
View File

@ -3,8 +3,6 @@ extends Node2D
var current_player: int = 0 var current_player: int = 0
var player_states := ["Circle", "Cross"] var player_states := ["Circle", "Cross"]
var won := "" 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 @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 @onready var diceSprite = $GUI/DiceSprite as Sprite2D
# 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
@ -27,8 +23,6 @@ func _ready():
board.active = true board.active = true
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta): func _process(_delta):
if won == "": if won == "":
@ -49,9 +43,11 @@ func _process(_delta):
board.active = false board.active = false
func _on_restart_button_pressed(): func _on_restart_button_pressed():
_ready() _ready()
var _checks = [ var _checks = [
[Vector2i(-1,0), Vector2i(1,0)], [Vector2i(-1,0), Vector2i(1,0)],
[Vector2i(0,-1), Vector2i(0,1)], [Vector2i(0,-1), Vector2i(0,1)],
@ -74,6 +70,7 @@ func _check_win() -> String:
return state return state
return "" return ""
#Generiert die Zufallszahl von 1-6 #Generiert die Zufallszahl von 1-6
func _roll_dice(): func _roll_dice():
var zahl = randi() % 6 + 1 var zahl = randi() % 6 + 1
@ -81,16 +78,19 @@ func _roll_dice():
print(zahl) #Debug ausgabe, später löschen lol print(zahl) #Debug ausgabe, später löschen lol
return zahl return zahl
#Funktion um Knop und Methode zu verbinden #Funktion um Knop und Methode zu verbinden
func _on_dice_button_pressed(): func _on_dice_button_pressed():
_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):
diceSprite.region_rect.position.x = _get_dice_pos_x(result) diceSprite.region_rect.position.x = _get_dice_pos_x(result)
diceSprite.region_rect.position.y = _get_dice_pos_y(result) diceSprite.region_rect.position.y = _get_dice_pos_y(result)
#X-Koordinaten der Augenzahlen in der Tilemap #X-Koordinaten der Augenzahlen in der Tilemap
func _get_dice_pos_x(result: int) -> int: func _get_dice_pos_x(result: int) -> int:
match result: match result:
@ -102,6 +102,7 @@ func _get_dice_pos_x(result: int) -> int:
6: return 208 6: return 208
return 8 return 8
#Y-Koordinaten in der Tilemap #Y-Koordinaten in der Tilemap
func _get_dice_pos_y(result: int) -> int: func _get_dice_pos_y(result: int) -> int:
match result: match result: