FaC random placement
This commit is contained in:
parent
3232182a9f
commit
dbdb9a7bf2
10 changed files with 106 additions and 7 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 24 KiB |
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/home.png-2752292748af7c14e83f6ea9f10c841a.cte
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 30 KiB |
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/user.png-dc728d288b223856966bafd84c0b8c54.cte
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ config_version=5
|
||||||
|
|
||||||
config/name="DD"
|
config/name="DD"
|
||||||
run/main_scene="uid://bv4rxfc4hm6t7"
|
run/main_scene="uid://bv4rxfc4hm6t7"
|
||||||
config/features=PackedStringArray("4.4", "Mobile")
|
config/features=PackedStringArray("4.5", "Mobile")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,15 @@ vertical_alignment = 1
|
||||||
justification_flags = 162
|
justification_flags = 162
|
||||||
|
|
||||||
[node name="GridContainer" parent="ColorRect" instance=ExtResource("1_85msg")]
|
[node name="GridContainer" parent="ColorRect" instance=ExtResource("1_85msg")]
|
||||||
layout_mode = 0
|
layout_mode = 1
|
||||||
offset_left = 515.0
|
anchors_preset = 8
|
||||||
offset_top = 217.0
|
anchor_left = 0.5
|
||||||
offset_right = 765.0
|
anchor_top = 0.5
|
||||||
offset_bottom = 467.0
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -125.0
|
||||||
|
offset_top = -125.0
|
||||||
|
offset_right = 125.0
|
||||||
|
offset_bottom = 125.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
|
||||||
67
scenes/find_a_couple/tile_grid.gd
Normal file
67
scenes/find_a_couple/tile_grid.gd
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
extends GridContainer
|
||||||
|
|
||||||
|
@export var pair_count: int = 3 # Количество пар
|
||||||
|
@export var tile_textures: Array[Texture2D] # Массив изображений
|
||||||
|
@export var tile_size: Vector2 = Vector2(100, 100)
|
||||||
|
|
||||||
|
var tiles_array: Array = []
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
generate_tiles()
|
||||||
|
|
||||||
|
func generate_tiles():
|
||||||
|
# Очищаем предыдущие плитки
|
||||||
|
for child in get_children():
|
||||||
|
child.queue_free()
|
||||||
|
tiles_array.clear()
|
||||||
|
|
||||||
|
# Проверяем достаточно ли изображений
|
||||||
|
if tile_textures.size() < pair_count:
|
||||||
|
push_error("Not enough textures for pairs! Need: ", pair_count, ", Have: ", tile_textures.size())
|
||||||
|
return
|
||||||
|
|
||||||
|
# Создаем пары индексов
|
||||||
|
var pairs_indices = create_pairs_indices()
|
||||||
|
|
||||||
|
# Перемешиваем порядок
|
||||||
|
pairs_indices.shuffle()
|
||||||
|
|
||||||
|
# Настраиваем GridContainer
|
||||||
|
setup_grid_container(pairs_indices.size())
|
||||||
|
|
||||||
|
# Создаем плитки
|
||||||
|
for i in range(pairs_indices.size()):
|
||||||
|
var texture_index = pairs_indices[i]
|
||||||
|
var tile = preload("res://scenes/find_a_couple/tile_btn.tscn").instantiate()
|
||||||
|
|
||||||
|
# Передаем данные в плитку
|
||||||
|
tile.front_texture = tile_textures[texture_index]
|
||||||
|
tile.back_texture = preload("res://assets/find_a_couple/back.png") # Рубашка
|
||||||
|
tile.tile_id = texture_index # ID для сравнения пар
|
||||||
|
tile.custom_minimum_size = tile_size
|
||||||
|
|
||||||
|
#tile.tile_clicked.connect(_on_tile_clicked)
|
||||||
|
add_child(tile)
|
||||||
|
tiles_array.append(tile)
|
||||||
|
|
||||||
|
func create_pairs_indices() -> Array:
|
||||||
|
var indices = []
|
||||||
|
# Создаем пары (каждое изображение повторяется 2 раза)
|
||||||
|
for i in range(pair_count):
|
||||||
|
indices.append(i)
|
||||||
|
indices.append(i)
|
||||||
|
return indices
|
||||||
|
|
||||||
|
func setup_grid_container(total_tiles: int):
|
||||||
|
# Вычисляем оптимальное количество колонок
|
||||||
|
columns = ceil(sqrt(total_tiles))
|
||||||
|
|
||||||
|
# Вычисляем количество строк
|
||||||
|
var rows = ceil(float(total_tiles) / columns)
|
||||||
|
|
||||||
|
# Устанавливаем минимальный размер контейнера
|
||||||
|
custom_minimum_size = Vector2(columns * tile_size.x, rows * tile_size.y)
|
||||||
|
|
||||||
|
#func _on_tile_clicked(clicked_tile):
|
||||||
|
# Логика обработки клика на плитке
|
||||||
|
#process_tile_click(clicked_tile)
|
||||||
1
scenes/find_a_couple/tile_grid.gd.uid
Normal file
1
scenes/find_a_couple/tile_grid.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c2427cp8ana1g
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://exbrdfhk0bou"]
|
[gd_scene load_steps=6 format=3 uid="uid://exbrdfhk0bou"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c2427cp8ana1g" path="res://scenes/find_a_couple/tile_grid.gd" id="1_j4vmv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://lu353vx1qhnw" path="res://scenes/find_a_couple/tile_btn.tscn" id="1_l5jho"]
|
[ext_resource type="PackedScene" uid="uid://lu353vx1qhnw" path="res://scenes/find_a_couple/tile_btn.tscn" id="1_l5jho"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bsj2xqsrkncfw" path="res://assets/find_a_couple/envelope.png" id="2_ey8fv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dkhosb3l014nu" path="res://assets/find_a_couple/home.png" id="2_j4vmv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bakxisrbvoy3e" path="res://assets/find_a_couple/user.png" id="4_0oft7"]
|
||||||
|
|
||||||
[node name="GridContainer" type="GridContainer"]
|
[node name="GridContainer" type="GridContainer"]
|
||||||
theme_override_constants/h_separation = 50
|
theme_override_constants/h_separation = 50
|
||||||
theme_override_constants/v_separation = 50
|
theme_override_constants/v_separation = 50
|
||||||
columns = 2
|
columns = 2
|
||||||
|
script = ExtResource("1_j4vmv")
|
||||||
|
tile_textures = Array[Texture2D]([ExtResource("2_ey8fv"), ExtResource("2_j4vmv"), ExtResource("4_0oft7")])
|
||||||
|
|
||||||
[node name="TextureButton" parent="." instance=ExtResource("1_l5jho")]
|
[node name="TextureButton" parent="." instance=ExtResource("1_l5jho")]
|
||||||
custom_minimum_size = Vector2(100, 100)
|
custom_minimum_size = Vector2(100, 100)
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
extends TextureButton
|
extends TextureButton
|
||||||
|
|
||||||
|
signal tile_clicked(tile) # Сигнал для основной логики игры
|
||||||
|
|
||||||
@export var front_texture: Texture2D # Изображение на лицевой стороне
|
@export var front_texture: Texture2D # Изображение на лицевой стороне
|
||||||
@export var back_texture: Texture2D # Изображение на обратной стороне
|
@export var back_texture: Texture2D # Изображение на обратной стороне
|
||||||
@export var flip_duration: float = 0.3 # Длительность анимации переворота
|
@export var flip_duration: float = 0.3 # Длительность анимации переворота
|
||||||
|
|
||||||
@onready var timer = $Timer
|
@onready var timer = $Timer
|
||||||
|
|
||||||
|
var tile_id: int = -1
|
||||||
|
var tile_index: int = -1
|
||||||
var is_flipped: bool = false
|
var is_flipped: bool = false
|
||||||
|
var is_matched: bool = false
|
||||||
var can_click: bool = true
|
var can_click: bool = true
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
custom_minimum_size = Vector2(100, 100)
|
||||||
texture_normal = back_texture
|
texture_normal = back_texture
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue