v.0.7: fml

Bugfixes lol
main
Ileyan Al Jaaf 2024-04-01 23:09:32 +02:00
parent 37d1a0e1ab
commit 9f910aba7d
4 changed files with 50 additions and 55 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cxsd3rd3k3eaj"
path="res://.godot/imported/skull.png-b3e3a5526e5abbe508c3491f9d549a8b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/skull.png"
dest_files=["res://.godot/imported/skull.png-b3e3a5526e5abbe508c3491f9d549a8b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -16,11 +16,10 @@ var off_limits: String = ""
func _ready():
print("Initializing board...")
_index_atlas_coordinates_by_name()
_index_layers_by_name()
$Highlight.size = tile_set.tile_size
print("Tiles: ", ", ".join(tile_by_name.keys()))
func get_state(grid_pos: Vector2) -> String:
@ -82,7 +81,7 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2:
#Löscht eine Zeile nach dem Glücksrad ereignis
func delete_column(column: int) -> void:
for i in range(-2, 4, 1):
self.set_cell(tile_map_layer, Vector2i(i, column - 1), 1, Vector2i(1, 2), 0)
self.set_cell(tile_map_layer, Vector2i(i, column - 1), 1, Vector2i(3,0), 0)
await get_tree().create_timer(0.25).timeout
#Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, Vector2i(i, column - 1))
@ -94,9 +93,6 @@ func delete_column(column: int) -> void:
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)
print(tile_map_cell_source_id)
print(tile_map_cell_atlas_coords)
print(tile_map_cell_alternative)
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)
if j == 0:
@ -106,13 +102,13 @@ func delete_column(column: int) -> void:
self.set_cell(tile_map_layer, Vector2i(i, j + 1))
func delete_row(row: int) -> void:
for i in range(6):
self.set_cell(tile_map_layer, Vector2i(row - 3, i), 1, Vector2i(1, 2), 0)
self.set_cell(tile_map_layer, Vector2i(row - 3, i), 1, Vector2i(3,0), 0)
await get_tree().create_timer(0.25).timeout
#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:
self.set_cell(tile_map_layer, grid_pos)
self.set_cell(tile_map_layer, grid_pos, 1, Vector2i(1, 2), 0)
self.set_cell(tile_map_layer, grid_pos, 1, Vector2i(3,0), 0)
await get_tree().create_timer(0.25).timeout
#Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, grid_pos)

59
game.gd
View File

@ -41,7 +41,7 @@ func _ready():
sequence_needed = 4
board.reset()
won = ""
ereignis.text = "Ereignis: "
ereignis.text = ""
sequenz.text = "4 - Gewinnt!"
wonPlayer.hide()
nextPlayer.region_rect.position.x = current_player * 300
@ -61,27 +61,40 @@ func _process(_delta):
if Input.is_action_just_pressed("Click") and move_allowed:
var grid_pos = board.gridpos_at_mouse()
if enable_remove:
print(grid_pos)
board._clear_enemy_tile(grid_pos)
enable_remove = false
elif board.get_state(Vector2(grid_pos.x, 0)) == board.empty_state:
var new_pos = board._calculate_drop_pos(grid_pos)
if board.set_state(new_pos, player_states[current_player]):
if zuege >= 1:
move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2)
move_allowed = false
wuerfeln_erlaubt = true
zuege += 1
blindBoard.visible = false
ereignis.text = ""
won = _check_win()
if won=="":
switch_player()
else:
print("Winner: ", won)
wonPlayer.region_rect.position.x = player_states.find(won) * 300
if won == player_states[0]:
print(str(_sequence))
_sequence = _sort_array(_sequence)
print(str(_sequence))
var umgerechnet = _umrechnung(_sequence)
_sequence = _lol(umgerechnet, _sequence)
print(str(umgerechnet))
print(str(_sequence))
for tile in _sequence:
board.set_cell(1, tile, 1, Vector2i(0, 2), 0)
else:
print(str(_sequence))
_sequence = _sort_array(_sequence)
print(str(_sequence))
var umgerechnet = _umrechnung(_sequence)
_sequence = _lol(umgerechnet, _sequence)
print(str(umgerechnet))
print(str(_sequence))
for tile in _sequence:
board.set_cell(1, tile, 1, Vector2i(3, 2), 0)
wonPlayer.show()
@ -121,10 +134,37 @@ func _check_win() -> String:
break
_sequence.append(Vector2i(cell + check[0] * (i + j)))
if same:
return state
return ""
func _sort_array(arr :Array) -> Array:
arr.sort_custom(func(a,b): return a < b)
return arr
func _umrechnung(arr :Array) -> Array:
var newArr = []
for i in range(1,arr.size()-1,1):
newArr.append(arr[i-1]-arr[i])
return newArr
#(-1, 0)_ (0,-1)| (-1,-1)\, (-1,1)/
func _lol(arr :Array, shortArr :Array) -> Array:
var bedingung
var vektoren = [Vector2i(-1,0),Vector2i(0,-1), Vector2i(-1,-1), Vector2i(-1,1)]
var newArr = []
for e in vektoren:
if arr.count(e) >= 2:
bedingung = e
for i in range(1,arr.size()+1,1):
if (shortArr[i-1] - shortArr[i]) == e:
newArr.append(shortArr[i-1])
newArr.append(shortArr[i])
return newArr
#Generiert die Zufallszahl von 1-6
func _roll_dice() -> int:
schnickLost = false
@ -141,7 +181,7 @@ func _roll_dice() -> int:
await get_tree().create_timer(0.25).timeout
_update_dice_sprite(zahl)
print(zahl) #Debug ausgabe, später löschen
if zahl == 1:
switch_to_schnick()
@ -172,8 +212,6 @@ func _on_dice_button_pressed():
move_allowed = true
_roll_dice()
#Sucht sich für die entsprechende Augenzahl
#die X und Y-Koordinaten in der Tilemap
func _update_dice_sprite(result :int):
@ -208,12 +246,10 @@ func _get_dice_pos_y(result: int) -> int:
#Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert
func _five_wins() -> void:
print("5 Gewinnt aktiv") #Debug
sequence_needed = 5
#Nach dem Glücksradereignis tauschen die Spieler die Symbole
func _change_symbols():
print("tausch") #debug
current_player = 1 - current_player
nextPlayer.region_rect.position.x = current_player * 300
var tempX = player1Sprite.region_rect.position.x
@ -226,7 +262,6 @@ func _change_symbols():
#Nach dem Glücksradereignis gewinnt der Spieler sofort
func _instant_win():
won = player_states[current_player]
print("Winner: ", won)
wonPlayer.region_rect.position.x = player_states.find(won) * 300
wonPlayer.show()
nextPlayer.hide()
@ -235,7 +270,6 @@ func _instant_win():
func _instant_loose():
current_player = 1 - current_player
won = player_states[current_player]
print("Winner: ", won)
wonPlayer.region_rect.position.x = player_states.find(won) * 300
wonPlayer.show()
nextPlayer.hide()
@ -243,8 +277,7 @@ func _instant_loose():
#Zum Testen der Events
func _on_test_pressed():
var rand = randi() % 6 + 1
_dead_zone(rand)
_spin_the_wheel(14)
func _spin_the_wheel(result: int) -> void: