v.0.6.3 coole animationen

beim löschen
fehler mein setzten wärend des glücksrad drehen muss behoben werden
main
Daniel Lehmann 2024-04-01 17:05:54 +02:00
parent 0e80adbcc0
commit 331e63f7e3
4 changed files with 268 additions and 7 deletions

View File

@ -80,6 +80,11 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2:
#Löscht eine Zeile nach dem Glücksrad ereignis #Löscht eine Zeile nach dem Glücksrad ereignis
func delete_column(column: int) -> void: 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)
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))
for j in range((column - 2), -1, -1): for j in range((column - 2), -1, -1):
for i in range(-2, 4, 1): for i in range(-2, 4, 1):
var tile_map_cell_position = Vector2i(i,j) var tile_map_cell_position = Vector2i(i,j)
@ -101,24 +106,33 @@ func delete_column(column: int) -> void:
func delete_row(row: int) -> void: func delete_row(row: int) -> void:
for i in range(6): for i in range(6):
self.set_cell(tile_map_layer, Vector2i(row - 3, i), 1, Vector2i(1, 2), 0)
await get_tree().create_timer(0.25).timeout
#Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert) #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, Vector2i(row - 3, i)) self.set_cell(tile_map_layer, Vector2i(row - 3, i))
func _clear_enemy_tile(grid_pos: Vector2) -> void: func _clear_enemy_tile(grid_pos: Vector2) -> void:
var true_position = grid_pos self.set_cell(tile_map_layer, grid_pos)
self.set_cell(tile_map_layer, true_position) self.set_cell(tile_map_layer, grid_pos, 1, Vector2i(1, 2), 0)
for i in range(true_position.y - 1, -1, -1 ): await get_tree().create_timer(0.25).timeout
var tile_map_cell_position = Vector2i(true_position.x, i) #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, grid_pos)
for i in range(grid_pos.y - 1, -1, -1 ):
@warning_ignore("narrowing_conversion")
var tile_map_cell_position = Vector2i(grid_pos.x, i)
var tile_data = self.get_cell_tile_data(tile_map_layer, tile_map_cell_position) var tile_data = self.get_cell_tile_data(tile_map_layer, tile_map_cell_position)
if tile_data: 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_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_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 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) @warning_ignore("narrowing_conversion")
var new_tile_map_cell_position = Vector2i(grid_pos.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) 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 i == 0: if i == 0:
self.set_cell(tile_map_layer, Vector2i(true_position.x, 0)) @warning_ignore("narrowing_conversion")
self.set_cell(tile_map_layer, Vector2i(grid_pos.x, 0))
else: else:
#Falls kein Inhalt, leer setzten #Falls kein Inhalt, leer setzten
self.set_cell(tile_map_layer, Vector2i(true_position.x, i + 1)) @warning_ignore("narrowing_conversion")
self.set_cell(tile_map_layer, Vector2i(grid_pos.x, i + 1))

233
gamD0B3.tmp 100644
View File

@ -0,0 +1,233 @@
[gd_scene load_steps=8 format=3 uid="uid://dmahmxghpm47w"]
[ext_resource type="Script" path="res://game.gd" id="1_g1ie7"]
[ext_resource type="PackedScene" uid="uid://dvlk7imglgpms" path="res://board/board.tscn" id="1_ym80r"]
[ext_resource type="Texture2D" uid="uid://do2vfb2cj7fk" path="res://assets/sprites.png" id="3_0333r"]
[ext_resource type="Texture2D" uid="uid://61xrksg1k2ek" path="res://assets/stein.png" id="4_evbl8"]
[ext_resource type="Texture2D" uid="uid://cr37od6sevrmd" path="res://assets/scissors.png" id="5_clubr"]
[ext_resource type="Texture2D" uid="uid://b1vi81hwhys1p" path="res://assets/paper.png" id="6_g740b"]
[ext_resource type="PackedScene" uid="uid://c6p3euhbip0w1" path="res://lucky_wheel.tscn" id="7_d5gkw"]
[node name="Game" type="Node2D"]
script = ExtResource("1_g1ie7")
[node name="Numbers" parent="." instance=ExtResource("1_ym80r")]
position = Vector2(878, 280)
layer_0/tile_data = PackedInt32Array(65533, 1, 3, 131069, 65537, 3, 196605, 131073, 3, 262141, 196609, 3, 327677, 65537, 4, 393213, 131073, 4, -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(879, 280)
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="BlindBoard" parent="." instance=ExtResource("1_ym80r")]
position = Vector2(879, 280)
layer_0/tile_data = PackedInt32Array(65537, 196609, 0, 131073, 196609, 0, 131074, 196609, 0, 0, 196609, 0, 65536, 196609, 0, 131072, 196609, 0, 1, 196609, 0, 2, 196609, 0, 65538, 196609, 0, 65534, 196609, 0, 131070, 196609, 0, 131071, 196609, 0, 196607, 196609, 0, 65535, 196609, 0, 196606, 196609, 0, 262142, 196609, 0, 327678, 196609, 0, 393214, 196609, 0, 393215, 196609, 0, 327680, 196609, 0, 327681, 196609, 0, 327682, 196609, 0, 327683, 196609, 0, 262147, 196609, 0, 196611, 196609, 0, 131075, 196609, 0, 65539, 196609, 0, 3, 196609, 0, 196610, 196609, 0, 262146, 196609, 0, 262145, 196609, 0, 196609, 196609, 0, 262144, 196609, 0, 196608, 196609, 0, 327679, 196609, 0, 262143, 196609, 0)
[node name="GUI" type="Node2D" parent="."]
[node name="Title" type="Label" parent="GUI"]
offset_left = 715.0
offset_top = 70.0
offset_right = 1195.0
offset_bottom = 142.0
size_flags_horizontal = 4
theme_override_colors/font_shadow_color = Color(0.278431, 0.537255, 0.870588, 1)
theme_override_font_sizes/font_size = 50
text = "Tic Tac Toe Extreme"
horizontal_alignment = 1
[node name="NextPlayer" type="Sprite2D" parent="GUI"]
position = Vector2(1528, 343.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 = 1351.0
offset_top = 312.0
offset_right = 1481.0
offset_bottom = 381.0
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 45
text = "Next:"
[node name="WonPlayer" type="Sprite2D" parent="GUI"]
position = Vector2(1840, 343.75)
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 = 1605.0
offset_top = 311.75
offset_right = 1776.0
offset_bottom = 380.75
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 45
text = "Winner:"
[node name="DiceSprite" type="Sprite2D" parent="GUI"]
position = Vector2(1696, 519)
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 = 1353.0
offset_top = 638.0
offset_right = 1583.0
offset_bottom = 758.0
theme_override_colors/font_color = Color(1, 0, 0, 1)
theme_override_font_sizes/font_size = 30
text = "Restart"
[node name="DiceButton" type="Button" parent="GUI"]
offset_left = 1351.0
offset_top = 466.0
offset_right = 1582.0
offset_bottom = 586.0
theme_override_font_sizes/font_size = 30
text = "Würfeln"
[node name="Test" type="Button" parent="GUI"]
offset_left = 1640.0
offset_top = 765.0
offset_right = 1872.0
offset_bottom = 861.0
rotation = 0.000312189
theme_override_font_sizes/font_size = 35
text = "Test"
[node name="WheelSpin" type="Button" parent="GUI"]
visible = false
offset_left = 1351.0
offset_top = 592.0
offset_right = 1581.0
offset_bottom = 712.0
theme_override_font_sizes/font_size = 25
text = "Spin the Wheel"
[node name="Player1Label" type="Label" parent="GUI"]
offset_left = 82.0
offset_top = 473.15
offset_right = 331.0
offset_bottom = 556.15
theme_override_font_sizes/font_size = 60
text = "Player 1:"
[node name="Player1Sprite" type="Sprite2D" parent="GUI"]
texture_filter = 1
position = Vector2(412, 518.15)
scale = Vector2(1.137, 1.05)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(8, 108, 85, 86)
[node name="Player2Label" type="Label" parent="GUI"]
offset_left = 82.0
offset_top = 629.3
offset_right = 331.0
offset_bottom = 712.3
theme_override_font_sizes/font_size = 60
text = "Player 2:"
[node name="Player2Sprite" type="Sprite2D" parent="GUI"]
texture_filter = 1
position = Vector2(412, 662.3)
scale = Vector2(1.04, 1.05)
texture = ExtResource("3_0333r")
region_enabled = true
region_rect = Rect2(307, 108, 86, 86)
[node name="Event" type="Label" parent="GUI"]
offset_left = 573.0
offset_top = 909.0
offset_right = 778.0
offset_bottom = 978.0
theme_override_font_sizes/font_size = 50
text = "Ereignis:"
[node name="Sequenz" type="Label" parent="GUI"]
offset_left = 20.0
offset_top = 199.0
offset_right = 814.0
offset_bottom = 268.0
theme_override_font_sizes/font_size = 50
text = "Steine zum gewinnen: "
[node name="Schnick" type="Node2D" parent="."]
visible = false
[node name="Label" type="Label" parent="Schnick"]
offset_left = 364.5
offset_top = 49.0
offset_right = 1592.5
offset_bottom = 218.0
size_flags_horizontal = 2
theme_override_font_sizes/font_size = 60
text = "Reallife Schere, Stein, Papier Minigame:
Hast du dir deinen nächsten Zug verdient?"
horizontal_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="Stein" type="Sprite2D" parent="Schnick"]
position = Vector2(953.5, 538)
scale = Vector2(0.2, 0.2)
texture = ExtResource("4_evbl8")
[node name="Scissors" type="Sprite2D" parent="Schnick"]
position = Vector2(486.5, 524)
scale = Vector2(0.25, 0.25)
texture = ExtResource("5_clubr")
[node name="Paper" type="Sprite2D" parent="Schnick"]
position = Vector2(1417.5, 538)
scale = Vector2(0.7, 0.7)
texture = ExtResource("6_g740b")
[node name="Gewonnen" type="Button" parent="Schnick"]
offset_left = 609.5
offset_top = 765.0
offset_right = 921.5
offset_bottom = 909.0
size_flags_horizontal = 2
theme_override_font_sizes/font_size = 60
text = "Ja"
metadata/_edit_use_anchors_ = true
[node name="Verloren" type="Button" parent="Schnick"]
offset_left = 1049.5
offset_top = 765.0
offset_right = 1361.5
offset_bottom = 909.0
size_flags_horizontal = 2
theme_override_font_sizes/font_size = 60
text = "Nein"
[node name="LuckyWheel" parent="." instance=ExtResource("7_d5gkw")]
visible = false
offset_left = 1024.0
offset_top = 455.0
offset_right = 1024.0
offset_bottom = 455.0
[node name="Titel" type="Label" parent="LuckyWheel"]
layout_mode = 0
offset_left = -401.667
offset_top = -679.0
offset_right = 438.333
offset_bottom = -484.0
theme_override_font_sizes/font_size = 70
text = "Du hast eine 6 gewürfelt!
Drehe nun am Rad:"
horizontal_alignment = 1
[connection signal="pressed" from="GUI/RestartButton" to="." method="_on_restart_button_pressed"]
[connection signal="pressed" from="GUI/DiceButton" to="." method="_on_dice_button_pressed"]
[connection signal="pressed" from="GUI/Test" to="." method="_on_test_pressed"]
[connection signal="pressed" from="GUI/WheelSpin" to="." method="_on_spin_the_wheel_pressed"]
[connection signal="pressed" from="Schnick/Gewonnen" to="." method="_on_gewonnen_pressed"]
[connection signal="pressed" from="Schnick/Verloren" to="." method="_on_verloren_pressed"]

10
game.gd
View File

@ -25,6 +25,7 @@ var active = Theme.new()
@onready var sequenz = $GUI/Sequenz as Label @onready var sequenz = $GUI/Sequenz as Label
@onready var schnick = $Schnick @onready var schnick = $Schnick
@onready var numbers = $Numbers as TileMap @onready var numbers = $Numbers as TileMap
@onready var blindBoard = $BlindBoard as TileMap
@onready var spinButton = $GUI/WheelSpin as Button @onready var spinButton = $GUI/WheelSpin as Button
@onready var luckyWheel = $LuckyWheel as Control @onready var luckyWheel = $LuckyWheel as Control
@ -35,6 +36,7 @@ func _ready():
wuerfeln_erlaubt = false wuerfeln_erlaubt = false
move_allowed = true move_allowed = true
wheel_spin_allowed = false wheel_spin_allowed = false
blindBoard.visible = false
sequence_needed = 4 sequence_needed = 4
board.reset() board.reset()
won = "" won = ""
@ -63,6 +65,7 @@ func _process(_delta):
move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2) move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2)
wuerfeln_erlaubt = true wuerfeln_erlaubt = true
zuege += 1 zuege += 1
blindBoard.visible = false
won = _check_win() won = _check_win()
if won=="": if won=="":
switch_player() switch_player()
@ -131,7 +134,10 @@ func _roll_dice() -> int:
if zahl == 1: if zahl == 1:
switch_to_schnick() switch_to_schnick()
if zahl == 3:
blindBoard.visible = true
if zahl == 6: if zahl == 6:
board.active = false
luckyWheel.is_spin = true luckyWheel.is_spin = true
switch_to_wheel() switch_to_wheel()
var number = randi() % 100 + 1 var number = randi() % 100 + 1
@ -142,6 +148,7 @@ func _roll_dice() -> int:
luckyWheel.spun = false luckyWheel.spun = false
luckyWheel.hide() luckyWheel.hide()
switch_to_game() switch_to_game()
board.active = true
return zahl return zahl
@ -239,6 +246,7 @@ func _spin_the_wheel(result: int) -> void:
ereignis.text += "Instant loose!" ereignis.text += "Instant loose!"
_instant_loose() _instant_loose()
elif result <= 15: elif result <= 15:
await get_tree().create_timer(6).timeout
enable_remove = true enable_remove = true
ereignis.text += "Du darfst einen Stein entfernen!" ereignis.text += "Du darfst einen Stein entfernen!"
elif result <= 30: elif result <= 30:
@ -255,10 +263,12 @@ func _spin_the_wheel(result: int) -> void:
elif result <= 65: elif result <= 65:
var zeile_zum_loeschen = randi() % 6 + 1 var zeile_zum_loeschen = randi() % 6 + 1
ereignis.text += "Zeile " + str(zeile_zum_loeschen) + " wird entfernt!" ereignis.text += "Zeile " + str(zeile_zum_loeschen) + " wird entfernt!"
await get_tree().create_timer(6).timeout
board.delete_column(zeile_zum_loeschen) board.delete_column(zeile_zum_loeschen)
elif result <= 85: elif result <= 85:
var spalte_zum_loeschen = randi() % 6 + 1 var spalte_zum_loeschen = randi() % 6 + 1
ereignis.text += "Spalte " + str(spalte_zum_loeschen) + " wird entfernt!" ereignis.text += "Spalte " + str(spalte_zum_loeschen) + " wird entfernt!"
await get_tree().create_timer(6).timeout
board.delete_row(spalte_zum_loeschen) board.delete_row(spalte_zum_loeschen)
elif result <= 100: elif result <= 100:
ereignis.text += str(result) ereignis.text += str(result)

View File

@ -19,6 +19,10 @@ layer_0/tile_data = PackedInt32Array(65533, 1, 3, 131069, 65537, 3, 196605, 1310
position = Vector2(879, 280) position = Vector2(879, 280)
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) 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="BlindBoard" parent="." instance=ExtResource("1_ym80r")]
position = Vector2(879, 280)
layer_0/tile_data = PackedInt32Array(65537, 196609, 0, 131073, 196609, 0, 131074, 196609, 0, 0, 196609, 0, 65536, 196609, 0, 131072, 196609, 0, 1, 196609, 0, 2, 196609, 0, 65538, 196609, 0, 65534, 196609, 0, 131070, 196609, 0, 131071, 196609, 0, 196607, 196609, 0, 65535, 196609, 0, 196606, 196609, 0, 262142, 196609, 0, 327678, 196609, 0, 393214, 196609, 0, 393215, 196609, 0, 327680, 196609, 0, 327681, 196609, 0, 327682, 196609, 0, 327683, 196609, 0, 262147, 196609, 0, 196611, 196609, 0, 131075, 196609, 0, 65539, 196609, 0, 3, 196609, 0, 196610, 196609, 0, 262146, 196609, 0, 262145, 196609, 0, 196609, 196609, 0, 262144, 196609, 0, 196608, 196609, 0, 327679, 196609, 0, 262143, 196609, 0)
[node name="GUI" type="Node2D" parent="."] [node name="GUI" type="Node2D" parent="."]
[node name="Title" type="Label" parent="GUI"] [node name="Title" type="Label" parent="GUI"]