Fix panning and spawning
This commit is contained in:
parent
feba305a23
commit
02edb73602
3 changed files with 26 additions and 2 deletions
|
@ -9,7 +9,7 @@ custom_features=""
|
|||
export_filter="all_resources"
|
||||
include_filter="*.txt"
|
||||
exclude_filter=""
|
||||
export_path="builds/window-creatures.exe"
|
||||
export_path="builds/Window-Creatures-WIN/window-creatures.exe"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
extends Node2D
|
||||
|
||||
var mouse_in_window
|
||||
var following
|
||||
var diff = Vector2.ZERO
|
||||
var last_mouse = Vector2.ZERO
|
||||
|
||||
func _ready() -> void:
|
||||
Triggerer.listen("released", _on_released)
|
||||
|
@ -20,3 +23,24 @@ func _notification(blah):
|
|||
|
||||
if not Persister.get_value("grabbing"):
|
||||
get_window().grab_focus()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("right_click") and mouse_in_window:
|
||||
following = true
|
||||
|
||||
if Input.is_action_just_released("right_click"):
|
||||
following = false
|
||||
|
||||
var mouse = get_tree().root.get_mouse_position()
|
||||
if following:
|
||||
diff += (mouse - last_mouse) * 4
|
||||
|
||||
var x = floor(diff.x)
|
||||
var y = floor(diff.y)
|
||||
|
||||
get_parent().position += Vector2i(x, y)
|
||||
|
||||
diff -= Vector2(x, y)
|
||||
|
||||
last_mouse = mouse
|
||||
|
|
|
@ -53,7 +53,7 @@ func _generate_spawn_times():
|
|||
spawn_times = []
|
||||
|
||||
for i in range(0, Persister.get_value("creature_amount")):
|
||||
spawn_times.push_back(randi_range(10, 6 * 24 - 2 - 20))
|
||||
spawn_times.push_back(randi_range(10, 6 * 17))
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
|
|
Loading…
Reference in a new issue