-
Notifications
You must be signed in to change notification settings - Fork 0
/
Approved.gd
45 lines (36 loc) · 1.19 KB
/
Approved.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
extends Node2D
signal mouse_released
var picked_up: bool = false
var stamp = preload("res://stampg.tscn")
var start_spot
func _ready():
start_spot = global_position
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if picked_up:
global_position = get_global_mouse_position()
if Input.is_action_just_pressed("RMB") and !picked_up:
mouse_released.emit()
#picked_up = false
if Input.is_action_just_pressed("LMB") and picked_up:
var highest = null
var height_index = 99999999
for i in $Area2D.get_overlapping_areas():
if i.get_parent().get_index() < height_index and i.get_parent().is_in_group("paper"):
height_index = i.get_parent().get_index()
highest = i.get_parent()
if highest != null:
var temp = stamp.instantiate()
highest.add_child(temp)
temp.global_transform.origin = global_transform.origin
$"/root/Singleton".play_sound("stamp use")
if highest.get("approved")!=null:
highest.approved = 1
func _on_button_pressed():
picked_up = !picked_up
if picked_up:
$"/root/Singleton".play_sound("stamp up")
else:
global_position = start_spot
$"/root/Singleton".play_sound("stamp down")
await mouse_released