parent
cdff133584
commit
a1aca34d89
|
@ -76,3 +76,30 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2:
|
||||||
else: i = i - 1
|
else: i = i - 1
|
||||||
|
|
||||||
return Vector2(x_coord, y_coord)
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
4
game.gd
4
game.gd
|
@ -3,6 +3,7 @@ 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 count = 0
|
||||||
|
|
||||||
|
|
||||||
@onready var board := $Board as Board
|
@onready var board := $Board as Board
|
||||||
|
@ -33,6 +34,7 @@ func _process(_delta):
|
||||||
var new_pos = board._calculate_drop_pos(grid_pos)
|
var new_pos = board._calculate_drop_pos(grid_pos)
|
||||||
if board.set_state(new_pos, player_states[current_player]):
|
if board.set_state(new_pos, player_states[current_player]):
|
||||||
won = _check_win()
|
won = _check_win()
|
||||||
|
#count = count + 1
|
||||||
if won=="":
|
if won=="":
|
||||||
current_player = 1 - current_player
|
current_player = 1 - current_player
|
||||||
nextPlayer.region_rect.position.x = current_player * 300
|
nextPlayer.region_rect.position.x = current_player * 300
|
||||||
|
@ -42,6 +44,8 @@ func _process(_delta):
|
||||||
wonPlayer.show()
|
wonPlayer.show()
|
||||||
nextPlayer.hide()
|
nextPlayer.hide()
|
||||||
board.active = false
|
board.active = false
|
||||||
|
#if count > 7:
|
||||||
|
#board.delete_row(5) zum testen des entfernens
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
window/size/viewport_width=1500
|
window/size/viewport_width=1500
|
||||||
window/size/viewport_height=1000
|
window/size/viewport_height=1000
|
||||||
|
window/size/mode=2
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue