Skip to content

Commit

Permalink
drop shadow visibility, poly original position double handling removed
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZajicek committed Mar 13, 2023
1 parent 97b9f38 commit 22a5607
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/DropShadowPoly.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Sprite2D


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
texture = Globals.user_settings.block_texture


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
4 changes: 3 additions & 1 deletion src/DropShadowPoly.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://ddnf6fenyc0jk"]
[gd_scene load_steps=3 format=3 uid="uid://ddnf6fenyc0jk"]

[ext_resource type="Texture2D" uid="uid://d2a7o585g1irr" path="res://icon.svg" id="1_2xgwx"]
[ext_resource type="Script" path="res://DropShadowPoly.gd" id="2_yj0km"]

[node name="DropShadow" type="Sprite2D"]
z_index = -1
scale = Vector2(0.5, 0.5)
texture = ExtResource("1_2xgwx")
script = ExtResource("2_yj0km")
6 changes: 3 additions & 3 deletions src/InfiniteModeMain.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func _unhandled_input(event: InputEvent) -> void:
dragging.drop_shadow.global_position = drop_position
var legal := test_if_legal(dragging, drop_position - grid.position)
if not legal:
dragging.drop_shadow.modulate = Color(1.0, 0.0, 0.0, 0.6)
else:
dragging.drop_shadow.modulate = Globals.user_settings.drop_shadow_colour
else:
dragging.drop_shadow.modulate = Globals.user_settings.grid_tile_colour.inverted()


if event.is_action_pressed("restart"):
Expand Down Expand Up @@ -84,7 +84,7 @@ func _on_Polyomino_put_down_event(_polyomino: Polyomino, _position: Vector2, _or
if grid.bitmap.get_total_line_count():
grid.destroy_lines()
else:
_polyomino.position = _original_position
_polyomino.position = _polyomino.original_position
dragging = null
await get_tree().process_frame
if get_tree().get_nodes_in_group("polyominoes").size() > 0:
Expand Down
7 changes: 3 additions & 4 deletions src/Polyomino.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func _ready() -> void:
randomize()
generate_shape()
connect_with_poly_children()

original_position = global_position
scale = scaled_poly

func generate_shape() -> void:
Expand All @@ -40,7 +40,6 @@ func generate_shape() -> void:
var new_drop_shadow_poly = drop_shadow_poly.instantiate()
new_drop_shadow_poly.position = (vector * Globals.tile_size)
drop_shadow.add_child(new_drop_shadow_poly)
# new_poly.label.text = str(new_poly.global_position)
score += 1
for child in get_children():
if child is Poly:
Expand All @@ -61,7 +60,6 @@ func _on_ClickableChild_event(_viewport: Node, event: InputEvent, _shape_idx: in
if event is InputEventScreenTouch or event is InputEventMouseButton:
if event.is_pressed() and not dragging:
get_tree().get_root().set_input_as_handled()
original_position = position
offset = position - event.position
offset.y -= Globals.user_settings.pickup_offset
dragging = self
Expand All @@ -80,7 +78,8 @@ func _unhandled_input(event: InputEvent) -> void:
for child in overlap_areas:
if child.has_overlapping_areas():
position = original_position
emit_signal("put_down", self, position, original_position)
else:
emit_signal("put_down", self, position, original_position)

scale = scaled_poly
dragging.drop_shadow.visible = false
Expand Down

0 comments on commit 22a5607

Please sign in to comment.