Skip to content

Commit

Permalink
spin wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
Pham Minh Kha authored and Pham Minh Kha committed Jan 13, 2024
0 parents commit 1c10ce6
Show file tree
Hide file tree
Showing 22 changed files with 502 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Godot 4+ specific ignores
.godot/

# Godot-specific ignores
.import/
export.cfg
export_presets.cfg

# Imported translations (automatically generated from CSV files)
*.translation

# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json
Binary file added addons/assets_spin_wheel/spin_wheel_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_arrow.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cbu3r8pscyuvj"
path="res://.godot/imported/spin_wheel_arrow.png-ddbef59ed424d47ffba853f8f8d428bf.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_arrow.png"
dest_files=["res://.godot/imported/spin_wheel_arrow.png-ddbef59ed424d47ffba853f8f8d428bf.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_background.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://o5281jsg2i68"
path="res://.godot/imported/spin_wheel_background.png-07eae85734ed74a629b87de05c65a2a2.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_background.png"
dest_files=["res://.godot/imported/spin_wheel_background.png-07eae85734ed74a629b87de05c65a2a2.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 added addons/assets_spin_wheel/spin_wheel_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_button.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bsd6eravgnhy5"
path="res://.godot/imported/spin_wheel_button.png-c429b7fa8dfcfd185faa41a464d58847.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_button.png"
dest_files=["res://.godot/imported/spin_wheel_button.png-c429b7fa8dfcfd185faa41a464d58847.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_button_press.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://swfesmtw11ic"
path="res://.godot/imported/spin_wheel_button_press.png-58edecd87355a181084abf13e9267b16.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_button_press.png"
dest_files=["res://.godot/imported/spin_wheel_button_press.png-58edecd87355a181084abf13e9267b16.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_button_ring.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://defxo6urikxl6"
path="res://.godot/imported/spin_wheel_button_ring.png-0aae512ec6d002efff2c6845e4cae88c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_button_ring.png"
dest_files=["res://.godot/imported/spin_wheel_button_ring.png-0aae512ec6d002efff2c6845e4cae88c.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 added addons/assets_spin_wheel/spin_wheel_front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_front.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://6k8tvr1v60hy"
path="res://.godot/imported/spin_wheel_front.png-6c0924a6603c27b526bba4e5d5aa476d.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_front.png"
dest_files=["res://.godot/imported/spin_wheel_front.png-6c0924a6603c27b526bba4e5d5aa476d.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions addons/assets_spin_wheel/spin_wheel_front_empty.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ff556ic5603l"
path="res://.godot/imported/spin_wheel_front_empty.png-50be2c15b4a78700226a2ec15601bd65.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/assets_spin_wheel/spin_wheel_front_empty.png"
dest_files=["res://.godot/imported/spin_wheel_front_empty.png-50be2c15b4a78700226a2ec15601bd65.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
93 changes: 93 additions & 0 deletions addons/spin_wheel.gd
Original file line number Diff line number Diff line change
@@ -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
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 == false:
is_spin = 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) #random position from 0 to 360 degrees

for item in vat_pham:
if reward_position >= item.from - 22.5 and reward_position <= item.to - 22.5:
print(item.name)
#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




Loading

0 comments on commit 1c10ce6

Please sign in to comment.