Skip to content

Commit 004dec2

Browse files
feat: handled sliders with border instead of tint
1 parent d901c99 commit 004dec2

File tree

6 files changed

+85
-45
lines changed

6 files changed

+85
-45
lines changed

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# Sum Zero
22

3-
[x] Build Android;
4-
[x] Gestire provenienza slider su tile (led ai 4 lati);
5-
[ ] Gestire sovrapposizione sliders usando contorno invece della tinta;
6-
[ ] Rimuovere highlight in hover (su mobile non ha senso);
7-
[ ] Gli slider devono essere sovrapposti rispettando un ordine in modo da mantenerlo quando vengono afferrati;
8-
[ ] Gli slider devono essere afferrabili solo dall'estremità finale;
9-
[ ] Rimuovere timer e how-to-play dal livello;
10-
[ ] Aggiungere numero di mosse rimanenti (numero massimo per ottenere una stella);
11-
[ ] Aggiungere menu selezione livello e how-to-play;
12-
[ ] Implementare nuove meccaniche:
13-
a. Somma 1 (+);
14-
b. Sottrae 1 (-);
15-
c. Somma 2 (++);
16-
d. Sottrae 2 (--);
17-
e. Inverte il segno (/);
18-
f. Ostacoli: celle che non permettono agli slider di passare;
19-
g. Slider tutto o niente: possono essere scalati solo su tutta la linea;
20-
h. Slider che azzerano le celle ma lasciano un ostacolo;
21-
i. Slider che si muove come un cavallo;
22-
[ ] Possibilità di skip del livello;
23-
[ ] Modalità sandbox con condivisione puzzle;
24-
[ ] Aggiungere SFX;
25-
[ ] Migliorare effetti grafici;
3+
## Roadmap
4+
5+
- [x] Android Build;
6+
- [x] Gestire provenienza slider su tile (led ai 4 lati);
7+
- [x] Gestire sovrapposizione sliders usando contorno invece della tinta;
8+
- [x] Rimuovere highlight in hover (su mobile non ha senso);
9+
- [-] Gli slider devono essere sovrapposti rispettando un ordine in modo da mantenerlo quando vengono afferrati;
10+
- [ ] Gli slider devono essere afferrabili solo dall'estremità finale;
11+
- [ ] Rimuovere timer e how-to-play dal livello;
12+
- [ ] Aggiungere numero di mosse rimanenti (numero massimo per ottenere una stella);
13+
- [ ] Aggiungere menu selezione livello e how-to-play;
14+
- [ ] Implementare nuove meccaniche:
15+
- Somma 1 (+);
16+
- Sottrae 1 (-);
17+
- Somma 2 (++);
18+
- Sottrae 2 (--);
19+
- Inverte il segno (/);
20+
- Ostacoli: celle che non permettono agli slider di passare;
21+
- Slider tutto o niente: possono essere scalati solo su tutta la linea;
22+
- Slider che azzerano le celle ma lasciano un ostacolo;
23+
- Slider che si muove come un cavallo;
24+
- [ ] Possibilità di skip del livello;
25+
- [ ] Aggiungere SFX;
26+
- [ ] Migliorare effetti grafici;
27+
- [ ] Modalità sandbox con condivisione puzzle;

assets/slider.png

1.45 KB
Loading

assets/slider.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://drxiqhjweubuq"
6+
path="res://.godot/imported/slider.png-0ae9312726c482ea6b8c8410fbfc83ab.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://assets/slider.png"
14+
dest_files=["res://.godot/imported/slider.png-0ae9312726c482ea6b8c8410fbfc83ab.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

scenes/ScalableArea.tscn

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
[gd_scene load_steps=7 format=3 uid="uid://ce6hhyfbr036r"]
22

33
[ext_resource type="Shader" path="res://shaders/ScalableArea.gdshader" id="1_cfxa8"]
4+
[ext_resource type="Texture2D" uid="uid://drxiqhjweubuq" path="res://assets/slider.png" id="2_bpwpr"]
45
[ext_resource type="Script" path="res://scripts/scalable_area.gd" id="2_f08w0"]
5-
[ext_resource type="Texture2D" uid="uid://bb6hgd3i624hv" path="res://assets/square.png" id="3_wrmo2"]
66
[ext_resource type="Texture2D" uid="uid://7bec7q7w10gl" path="res://assets/ui/minus.png" id="4_gjuxb"]
77

8-
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gx784"]
9-
resource_local_to_scene = true
8+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4iu34"]
109
shader = ExtResource("1_cfxa8")
11-
shader_parameter/base_color = Vector4(0, 0.2, 0, 0.2)
12-
shader_parameter/is_hovered = false
10+
shader_parameter/base_color = Color(0, 0, 0, 1)
1311
shader_parameter/glow_intensity = 1.0
14-
shader_parameter/hover_glow_multiplier = 2.0
1512

1613
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bx6b5"]
17-
size = Vector2(127, 128)
14+
size = Vector2(128, 128)
1815

1916
[node name="ScalableArea" type="Node2D"]
2017
script = ExtResource("2_f08w0")
2118

22-
[node name="Area" type="Sprite2D" parent="."]
23-
material = SubResource("ShaderMaterial_gx784")
24-
texture = ExtResource("3_wrmo2")
19+
[node name="Area" type="NinePatchRect" parent="."]
20+
unique_name_in_owner = true
21+
material = SubResource("ShaderMaterial_4iu34")
22+
offset_left = -64.0
23+
offset_top = -64.0
24+
offset_right = 64.0
25+
offset_bottom = 64.0
26+
texture = ExtResource("2_bpwpr")
27+
patch_margin_left = 24
28+
patch_margin_top = 24
29+
patch_margin_right = 24
30+
patch_margin_bottom = 24
2531

2632
[node name="Handle" type="Area2D" parent="."]
2733

2834
[node name="CollisionShape2D" type="CollisionShape2D" parent="Handle"]
29-
position = Vector2(0.5, 0)
3035
shape = SubResource("RectangleShape2D_bx6b5")
3136

3237
[node name="Icon" type="Sprite2D" parent="."]

scripts/scalable_area.gd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var _current_scale: int
2020
var _reachable_tiles: Array[Tile]
2121
var _area_increment: bool
2222

23-
@onready var area = $Area
23+
@onready var area: NinePatchRect = $Area
2424
@onready var handle = $Handle
2525
@onready var icon = $Icon
2626

@@ -50,8 +50,8 @@ func init(
5050

5151
handle.scale = Vector2(min_scale, 1)
5252
handle.position.x = -GlobalConst.HANDLE_SIZE / 2
53-
area.scale = Vector2(min_scale, 1)
54-
area.position.x = -GlobalConst.HANDLE_SIZE / 2
53+
area.size = Vector2(min_scale * 128, 128)
54+
area.position.x = -GlobalConst.HANDLE_SIZE
5555
icon.position.x = -GlobalConst.HANDLE_SIZE / 2
5656
icon.rotation_degrees = 90
5757
icon.texture = PLUS if area_increment else MINUS
@@ -100,12 +100,13 @@ func _update_changed_tiles() -> void:
100100

101101

102102
func _apply_scaling(_new_scale: float) -> void:
103-
area.scale.x = min_scale + _new_scale
104-
area.position.x = -GlobalConst.HANDLE_SIZE / 2 + _new_scale / 2 * GlobalConst.CELL_SIZE
103+
area.size.x = min_scale * 128 + _new_scale * 128
104+
# area.position.x = -GlobalConst.HANDLE_SIZE / 2 + _new_scale / 2 * GlobalConst.CELL_SIZE
105105

106106

107107
func toggle_highlight(is_on: bool) -> void:
108-
area.material.set_shader_parameter("is_hovered", is_on)
108+
print("FIX ME")
109+
# area.material.set_shader_parameter("is_hovered", is_on)
109110

110111

111112
func _on_handle_mouse_exited():

shaders/ScalableArea.gdshader

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
shader_type canvas_item;
22

3-
uniform vec4 base_color = vec4(1.0);
4-
uniform bool is_hovered = false;
5-
uniform float glow_intensity = 1.0;
6-
uniform float hover_glow_multiplier = 2.0;
3+
uniform vec4 base_color: source_color = vec4(1.0);
4+
uniform float glow_intensity: hint_range(0.0, 1.0, 0.1) = 1.0;
75

86
void fragment() {
97
vec4 color = texture(TEXTURE, UV);
108

119
// Adjust the glow intensity based on whether the sprite is hovered
12-
float final_glow_intensity = is_hovered ? glow_intensity * hover_glow_multiplier : glow_intensity;
10+
float final_glow_intensity = glow_intensity;
1311

1412
// Apply the glow effect
1513
vec4 glow_color = color * final_glow_intensity;

0 commit comments

Comments
 (0)