- GUI geupdated
- Lucky Wheel ist jetzt eine eigene Szene
main
Ileyan Al Jaaf 2024-04-01 01:17:11 +02:00
parent 42a002e5d2
commit 0e80adbcc0
20 changed files with 476 additions and 11 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
assets/.DS_Store vendored

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cbu3r8pscyuvj"
path="res://.godot/imported/spin_wheel_arrow.png-936961a2b5ae07daab7a1acbf375f82e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_arrow.png"
dest_files=["res://.godot/imported/spin_wheel_arrow.png-936961a2b5ae07daab7a1acbf375f82e.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://o5281jsg2i68"
path="res://.godot/imported/spin_wheel_background.png-cf8d76f7b909fbde31955774038edc1d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_background.png"
dest_files=["res://.godot/imported/spin_wheel_background.png-cf8d76f7b909fbde31955774038edc1d.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bsd6eravgnhy5"
path="res://.godot/imported/spin_wheel_button.png-dee136e3eebc4599ee2b30663358e34a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_button.png"
dest_files=["res://.godot/imported/spin_wheel_button.png-dee136e3eebc4599ee2b30663358e34a.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://swfesmtw11ic"
path="res://.godot/imported/spin_wheel_button_press.png-e59da88496c4ba380c99670f341f6e7a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_button_press.png"
dest_files=["res://.godot/imported/spin_wheel_button_press.png-e59da88496c4ba380c99670f341f6e7a.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://defxo6urikxl6"
path="res://.godot/imported/spin_wheel_button_ring.png-55abc01c9348197f0f4c43397e2ff726.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_button_ring.png"
dest_files=["res://.godot/imported/spin_wheel_button_ring.png-55abc01c9348197f0f4c43397e2ff726.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6k8tvr1v60hy"
path="res://.godot/imported/spin_wheel_front.png-92a12caba9820bbca65214965a17654c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_front.png"
dest_files=["res://.godot/imported/spin_wheel_front.png-92a12caba9820bbca65214965a17654c.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ff556ic5603l"
path="res://.godot/imported/spin_wheel_front_empty.png-452bc4c7033a15e9cd5ff01583413204.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lucky_wheel/spin_wheel_front_empty.png"
dest_files=["res://.godot/imported/spin_wheel_front_empty.png-452bc4c7033a15e9cd5ff01583413204.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

23
game.gd
View File

@ -26,6 +26,7 @@ var active = Theme.new()
@onready var schnick = $Schnick
@onready var numbers = $Numbers as TileMap
@onready var spinButton = $GUI/WheelSpin as Button
@onready var luckyWheel = $LuckyWheel as Control
# Called when the node enters the scene tree for the first time.
func _ready():
@ -131,8 +132,17 @@ func _roll_dice() -> int:
if zahl == 1:
switch_to_schnick()
if zahl == 6:
move_allowed = false
wheel_spin_allowed = true
luckyWheel.is_spin = true
switch_to_wheel()
var number = randi() % 100 + 1
_spin_the_wheel(number)
while luckyWheel.spun == false: #damit erst nach dem drehen 3s gewartet wird
await get_tree().create_timer(1).timeout
await get_tree().create_timer(3.2).timeout
luckyWheel.spun = false
luckyWheel.hide()
switch_to_game()
return zahl
@ -215,7 +225,7 @@ func _instant_loose():
#Zum Testen der Events
func _on_test_pressed():
switch_to_schnick()
get_tree().change_scene_to_file("res://lucky_wheel.tscn")
func _spin_the_wheel(result: int) -> void:
@ -272,6 +282,13 @@ func switch_to_schnick():
gui.hide()
schnick.show()
func switch_to_wheel():
move_allowed = false
gui.hide()
numbers.hide()
board.hide()
luckyWheel.show()
func switch_to_game():
move_allowed = true
gui.show()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://dmahmxghpm47w"]
[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"]
@ -6,6 +6,7 @@
[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")
@ -64,26 +65,26 @@ theme_override_font_sizes/font_size = 45
text = "Winner:"
[node name="DiceSprite" type="Sprite2D" parent="GUI"]
position = Vector2(1694, 488)
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 = 1351.0
offset_top = 752.0
offset_right = 1581.0
offset_bottom = 872.0
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 = 432.0
offset_top = 466.0
offset_right = 1582.0
offset_bottom = 552.0
offset_bottom = 586.0
theme_override_font_sizes/font_size = 30
text = "Würfeln"
@ -97,6 +98,7 @@ 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
@ -201,6 +203,24 @@ 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"]

93
lucky_wheel.gd 100644
View File

@ -0,0 +1,93 @@
extends Control
@export var is_spin: bool = false
@export var speed: int = 10
@export var power: int = 2
@export var reward_position = 0
@export var spun = false
signal sig_reward
var vat_pham = [
{
"name": "Dark blue",
"from": 0,
"to": 45,
"ma_vat_pham": 200,
"ten_vat_pham": "Thanh Long"
},
{
"name": "Dark green",
"from": 45,
"to": 90,
"ma_vat_pham": 0,
"ten_vat_pham": "Gạch"
},
{
"name": "Blue",
"from": 90,
"to": 135,
"ma_vat_pham": 204,
"ten_vat_pham": "Chanh"
},
{
"name": "Yellow",
"from": 135,
"to": 180,
"ma_vat_pham": 203,
"ten_vat_pham": "Dưa Hấu"
},
{
"name": "Purple",
"from": 180,
"to": 225,
"ma_vat_pham": 201,
"ten_vat_pham": "Sầu Riêng"
},
{
"name": "Green",
"from": 225,
"to": 270,
"ma_vat_pham": 0,
"ten_vat_pham": "Gạch"
},
{
"name": "Orange",
"from": 270,
"to": 315,
"ma_vat_pham": 202,
"ten_vat_pham": "Vãi"
},
{
"name": "Pink",
"from": 315,
"to": 360,
"ma_vat_pham": 0,
"ten_vat_pham": "Gạch"
}
]
func _on_btn_spin_pressed():
if is_spin == true:
spun = true
var tween = get_tree().create_tween().set_parallel(true)
tween.connect("finished", func():
#after tween finish animation, this function is call
var old_rotation_degrees = %front.rotation_degrees
#set is_spin = false to tell for user can press again
is_spin = false
if old_rotation_degrees > 360:
#This part is to fix the error that when rotating the steamer once, it will not rotate counterclockwise
var rad_ = fmod(old_rotation_degrees, 360)
%front.rotation_degrees = rad_
)
reward_position = randi_range(0, 360)
for item in vat_pham:
if reward_position >= item.from - 22.5 and reward_position <= item.to - 22.5:
#signal for another scene
sig_reward.emit(item.ma_vat_pham)
tween.tween_property(%front, "rotation_degrees", reward_position + 360 * speed * power , 3).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_CIRC)
tween.finished

97
lucky_wheel.tscn 100644
View File

@ -0,0 +1,97 @@
[gd_scene load_steps=8 format=3 uid="uid://c6p3euhbip0w1"]
[ext_resource type="Texture2D" uid="uid://o5281jsg2i68" path="res://assets/lucky_wheel/spin_wheel_background.png" id="1_ud5de"]
[ext_resource type="Script" path="res://lucky_wheel.gd" id="1_yqnp6"]
[ext_resource type="Texture2D" uid="uid://ff556ic5603l" path="res://assets/lucky_wheel/spin_wheel_front_empty.png" id="2_ro8ek"]
[ext_resource type="Texture2D" uid="uid://defxo6urikxl6" path="res://assets/lucky_wheel/spin_wheel_button_ring.png" id="3_nq070"]
[ext_resource type="Texture2D" uid="uid://bsd6eravgnhy5" path="res://assets/lucky_wheel/spin_wheel_button.png" id="3_sur1o"]
[ext_resource type="Texture2D" uid="uid://swfesmtw11ic" path="res://assets/lucky_wheel/spin_wheel_button_press.png" id="4_idmp7"]
[ext_resource type="Texture2D" uid="uid://cbu3r8pscyuvj" path="res://assets/lucky_wheel/spin_wheel_arrow.png" id="6_0lqqd"]
[node name="LuckyWheel" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 272.0
offset_top = 40.0
offset_right = 272.0
offset_bottom = 40.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.75, 0.75)
pivot_offset = Vector2(-211, 365)
script = ExtResource("1_yqnp6")
[node name="background" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -420.333
offset_top = -427.0
offset_right = 479.667
offset_bottom = 473.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_ud5de")
[node name="front" type="TextureRect" parent="background"]
unique_name_in_owner = true
layout_mode = 0
offset_right = 900.0
offset_bottom = 900.0
scale = Vector2(0.91999, 0.919998)
pivot_offset = Vector2(450, 450)
texture = ExtResource("2_ro8ek")
[node name="background_button" type="TextureRect" parent="background"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("3_nq070")
[node name="btn_spin" type="TextureButton" parent="background"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -100.0
offset_right = 100.0
offset_bottom = 100.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.812949, 0.807073)
pivot_offset = Vector2(100, 100)
texture_normal = ExtResource("3_sur1o")
texture_pressed = ExtResource("4_idmp7")
stretch_mode = 3
[node name="arrow" type="TextureRect" parent="background"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -100.0
offset_right = 100.0
offset_bottom = 181.0
grow_horizontal = 2
scale = Vector2(0.442426, 0.443682)
pivot_offset = Vector2(100, 6)
texture = ExtResource("6_0lqqd")
[connection signal="pressed" from="background/btn_spin" to="." method="_on_btn_spin_pressed"]