From a1aca34d89d0afa7fe2f1586e7475a58ededba64 Mon Sep 17 00:00:00 2001 From: Daniel Lehmann <3004405@stud.hs-mannheim.de> Date: Thu, 28 Mar 2024 23:15:02 +0100 Subject: [PATCH] =?UTF-8?q?v.0.5=20Teile=20des=20Gl=C3=BCcksrades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit delete_row und delete_column funktionieren --- board/board.gd | 27 +++++++++++++++++++++++++++ game.gd | 4 ++++ project.godot | 1 + 3 files changed, 32 insertions(+) diff --git a/board/board.gd b/board/board.gd index 8b3f7a2..7398e23 100644 --- a/board/board.gd +++ b/board/board.gd @@ -76,3 +76,30 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2: else: i = i - 1 return Vector2(x_coord, y_coord) + +#Löscht eine Zeile nach dem Glücksrad ereignis +func delete_column(column: int) -> void: + for j in range((column - 2), -1, -1): + for i in range(-2, 4, 1): + var tile_map_layer = 1 + var tile_map_cell_position = Vector2i(i,j) + var tile_data = self.get_cell_tile_data(tile_map_layer, tile_map_cell_position) + if tile_data: + var tile_map_cell_source_id = self.get_cell_source_id(tile_map_layer, tile_map_cell_position); + var tile_map_cell_atlas_coords = self.get_cell_atlas_coords(tile_map_layer, tile_map_cell_position) + var tile_map_cell_alternative = self.get_cell_alternative_tile(tile_map_layer, tile_map_cell_position) + var new_tile_map_cell_position = Vector2i(i, j + 1) + self.set_cell(tile_map_layer, new_tile_map_cell_position, tile_map_cell_source_id, tile_map_cell_atlas_coords, tile_map_cell_alternative) + else: + #Falls kein Inhalt, leer setzten + self.set_cell(tile_map_layer, Vector2i(i, j + 1)) + +func delete_row(row: int) -> void: + var tile_map_layer = 1 + for i in range(6): + #Inhalt leer setzten + self.set_cell(tile_map_layer, Vector2i(row - 2, i)) + + + + diff --git a/game.gd b/game.gd index ac0aeaf..409e8d0 100644 --- a/game.gd +++ b/game.gd @@ -3,6 +3,7 @@ extends Node2D var current_player: int = 0 var player_states := ["Circle", "Cross"] var won := "" +var count = 0 @onready var board := $Board as Board @@ -33,6 +34,7 @@ func _process(_delta): var new_pos = board._calculate_drop_pos(grid_pos) if board.set_state(new_pos, player_states[current_player]): won = _check_win() + #count = count + 1 if won=="": current_player = 1 - current_player nextPlayer.region_rect.position.x = current_player * 300 @@ -42,6 +44,8 @@ func _process(_delta): wonPlayer.show() nextPlayer.hide() board.active = false + #if count > 7: + #board.delete_row(5) zum testen des entfernens diff --git a/project.godot b/project.godot index d6d8123..32832e0 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,7 @@ config/icon="res://icon.svg" window/size/viewport_width=1500 window/size/viewport_height=1000 +window/size/mode=2 [input]