GUI ein bissl umpositioniert.
_remove_enemy_tile hinzugefügt und im testbutton veranckert. wollte aber nicht mit mouse click funktionieren
main
Daniel Lehmann 2024-03-29 19:36:21 +01:00
parent e8ea30068a
commit dfe1ab5083
3 changed files with 67 additions and 56 deletions

View File

@ -4,6 +4,7 @@ class_name Board
var tile_by_name := {}
var layer_by_name := {}
var tile_map_layer = 1
@export var state_layer: String = "States"
@export var board_layer: String = "Board"
@ -81,7 +82,6 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2:
func delete_column(column: int) -> void:
for j in range((column - 3), -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:
@ -95,12 +95,23 @@ func delete_column(column: int) -> void:
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 (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, Vector2i(row - 3, i))
func _clear_enemy_tile(grid_pos: Vector2) -> void:
var true_position = grid_pos + Vector2(-2, 0) #Minus 2 weil über einen Klick und nicht über einen Würfel
self.set_cell(tile_map_layer, true_position)
for i in range(true_position.y - 1, -1, -1 ):
var tile_map_cell_position = Vector2i(true_position.x, i)
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(true_position.x, i + 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(true_position.x, i + 1))

View File

@ -4,7 +4,6 @@ var current_player: int = 0
var player_states := ["Circle", "Cross"]
var won := ""
var five_wins = false
var count = 0
@onready var board := $Board as Board
@ -47,9 +46,6 @@ func _process(_delta):
wonPlayer.show()
nextPlayer.hide()
board.active = false
#if count > 7:
#board.delete_row(5) zum testen des entfernens
func _on_restart_button_pressed():
@ -166,4 +162,4 @@ func _instant_win():
#Zum Testen der Events
func _on_test_pressed():
_instant_win()
board._clear_enemy_tile(Vector2(0,5))

View File

@ -8,116 +8,120 @@
script = ExtResource("1_g1ie7")
[node name="Nummerierung links" parent="." instance=ExtResource("1_ym80r")]
position = Vector2(419, 240)
position = Vector2(375, 232)
layer_0/tile_data = PackedInt32Array(65533, 1, 3, 131069, 65537, 3, 196605, 131073, 3, 262141, 196609, 3, 327677, 65537, 4, 393213, 131073, 4, 65534, 1, 3, -2, 1, 3, -1, 65537, 3, -65536, 131073, 3, -65535, 196609, 3, -65534, 65537, 4, -65533, 131073, 4)
[node name="Board" parent="." instance=ExtResource("1_ym80r")]
position = Vector2(419, 240)
position = Vector2(375, 232)
layer_0/tile_data = PackedInt32Array(65537, 1, 0, 131073, 1, 0, 131074, 1, 0, 0, 1, 0, 65536, 1, 0, 131072, 1, 0, 1, 1, 0, 2, 1, 0, 65538, 1, 0, 65534, 1, 0, 131070, 1, 0, 131071, 1, 0, 196607, 1, 0, 65535, 1, 0, 196606, 1, 0, 262142, 1, 0, 327678, 1, 0, 393214, 1, 0, 393215, 1, 0, 327680, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 262147, 1, 0, 196611, 1, 0, 131075, 1, 0, 65539, 1, 0, 3, 1, 0, 196610, 1, 0, 262146, 1, 0, 262145, 1, 0, 196609, 1, 0, 262144, 1, 0, 196608, 1, 0, 327679, 1, 0, 262143, 1, 0)
[node name="GUI" type="Node2D" parent="."]
[node name="Title" type="Label" parent="GUI"]
offset_left = 560.0
offset_top = 36.0
offset_right = 941.0
offset_bottom = 108.0
offset_left = 834.0
offset_top = 2.0
offset_right = 1215.0
offset_bottom = 74.0
theme_override_font_sizes/font_size = 40
text = "Tic Tac Toe Extreme"
metadata/_edit_use_anchors_ = true
[node name="NextPlayer" type="Sprite2D" parent="GUI"]
position = Vector2(1176, 232)
scale = Vector2(1.31, 1.3)
position = Vector2(1107.63, 239.75)
scale = Vector2(1.0075, 0.995)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(0, 100, 100, 100)
[node name="NextPlayerLabel" type="Label" parent="GUI"]
offset_left = 960.0
offset_top = 193.0
offset_right = 1090.0
offset_bottom = 262.0
offset_left = 875.0
offset_top = 208.5
offset_right = 1005.0
offset_bottom = 277.5
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 45
text = "Next:"
metadata/_edit_use_anchors_ = true
[node name="WonPlayer" type="Sprite2D" parent="GUI"]
position = Vector2(1179, 400.5)
scale = Vector2(1.3, 1.3)
position = Vector2(1106, 341.5)
scale = Vector2(0.999999, 0.995)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(0, 100, 100, 100)
[node name="WonPlayerLabel" type="Label" parent="GUI"]
offset_left = 967.0
offset_top = 369.5
offset_right = 1091.0
offset_bottom = 438.5
offset_left = 877.0
offset_top = 309.5
offset_right = 1048.0
offset_bottom = 378.5
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 45
text = "Won:"
text = "Winner:"
metadata/_edit_use_anchors_ = true
[node name="DiceSprite" type="Sprite2D" parent="GUI"]
position = Vector2(1224, 576)
position = Vector2(1197, 538)
scale = Vector2(1.26596, 1.2191)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(207, 410, 85, 85)
[node name="RestartButton" type="Button" parent="GUI"]
offset_left = 896.0
offset_top = 688.0
offset_right = 1125.0
offset_bottom = 808.0
offset_left = 866.0
offset_top = 707.0
offset_right = 1095.0
offset_bottom = 827.0
theme_override_colors/font_color = Color(1, 0, 0, 1)
theme_override_font_sizes/font_size = 30
text = "Restart"
metadata/_edit_use_anchors_ = true
[node name="DiceButton" type="Button" parent="GUI"]
offset_left = 896.0
offset_top = 520.0
offset_right = 1128.0
offset_bottom = 640.0
offset_left = 865.0
offset_top = 480.0
offset_right = 1097.0
offset_bottom = 600.0
theme_override_font_sizes/font_size = 30
text = "Würfeln"
metadata/_edit_use_anchors_ = true
[node name="Test" type="Button" parent="GUI"]
offset_left = 24.0
offset_top = 16.0
offset_right = 248.0
offset_bottom = 112.0
offset_left = 872.0
offset_top = 605.0
offset_right = 1096.0
offset_bottom = 701.0
theme_override_font_sizes/font_size = 35
text = "Test"
[node name="Player1Label" type="Label" parent="GUI"]
offset_left = 1344.0
offset_top = 193.0
offset_right = 1530.0
offset_bottom = 256.0
offset_left = 164.0
offset_top = 45.0
offset_right = 350.0
offset_bottom = 108.0
theme_override_font_sizes/font_size = 45
text = "Player 1:"
metadata/_edit_use_anchors_ = true
[node name="Player1Sprite" type="Sprite2D" parent="GUI"]
position = Vector2(1624, 232)
scale = Vector2(1.3, 1.3)
position = Vector2(403, 79.1)
scale = Vector2(0.767647, 0.709302)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(8, 108, 85, 86)
[node name="Player2Label" type="Label" parent="GUI"]
offset_left = 1344.0
offset_top = 370.0
offset_right = 1530.0
offset_bottom = 433.0
offset_left = 498.0
offset_top = 45.1
offset_right = 684.0
offset_bottom = 108.1
theme_override_font_sizes/font_size = 45
text = "Player 2:"
metadata/_edit_use_anchors_ = true
[node name="Player2Sprite" type="Sprite2D" parent="GUI"]
position = Vector2(1624, 392)
scale = Vector2(1.3, 1.3)
position = Vector2(735.388, 78.0625)
scale = Vector2(0.688662, 0.696221)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(307, 108, 86, 86)