Compare commits
2 Commits
f0fcf0dcb3
...
0af538ff3f
| Author | SHA1 | Date | |
|---|---|---|---|
| 0af538ff3f | |||
| c20985ac91 |
@@ -24,7 +24,7 @@ var isAlive: bool = true
|
||||
@onready var invulnerable_cooldown_timer: Timer = $InvulnerableCooldownTimer
|
||||
var hasiframes: bool = false # only used for iframe after collision for now
|
||||
var target = Vector2.ZERO # either vector2 or Node2D
|
||||
var updating_target: bool = false
|
||||
var updating_target: bool = false # TODO: overhaul; make own node/script and actually expand logic properly
|
||||
|
||||
func _ready() -> void:
|
||||
var screen_size = get_viewport_rect().size
|
||||
@@ -38,9 +38,6 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _input(event):
|
||||
# TODO: only does clicks/taps; accept mouse drags
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
target = get_global_mouse_position()
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
# start tracking
|
||||
@@ -50,9 +47,6 @@ func _input(event):
|
||||
# stop tracking
|
||||
updating_target = false
|
||||
|
||||
if updating_target and event is InputEventMouseMotion:
|
||||
target = get_global_mouse_position()
|
||||
|
||||
func _physics_process(delta):
|
||||
var pos
|
||||
if typeof(target) == TYPE_VECTOR2:
|
||||
@@ -78,6 +72,9 @@ func _process(delta):
|
||||
if self.rotation != self.desired_rotation:
|
||||
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
|
||||
|
||||
if typeof(target) == TYPE_VECTOR2 and updating_target:
|
||||
target = get_global_mouse_position()
|
||||
|
||||
|
||||
func try_attack() -> void:
|
||||
if not can_attack:
|
||||
|
||||
@@ -92,7 +92,7 @@ tile_set = SubResource("TileSet_ojt85")
|
||||
position = Vector2(112, 64)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="player" unique_id=1614218911]
|
||||
zoom = Vector2(5, 5)
|
||||
zoom = Vector2(3, 3)
|
||||
limit_enabled = false
|
||||
limit_left = 0
|
||||
limit_top = 0
|
||||
|
||||
@@ -69,9 +69,3 @@ func _on_sight_body_entered(body: Node2D) -> void:
|
||||
|
||||
func _on_attack_cooldown_timer_timeout() -> void:
|
||||
can_attack = true
|
||||
|
||||
|
||||
func _on_collision_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
if player:
|
||||
player.target = self.collision
|
||||
|
||||
@@ -42,9 +42,3 @@ func become_injured() -> void:
|
||||
func _on_sight_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("predator") or (health < maxHealth and body.is_in_group("player")):
|
||||
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": body})
|
||||
|
||||
|
||||
func _on_collision_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
if player:
|
||||
player.target = self.collision
|
||||
|
||||
@@ -37,3 +37,8 @@ func play_sprite(anim: String) -> void:
|
||||
self.sprite.play(anim)
|
||||
if "wrapper" in self:
|
||||
self.wrapper.play_sprite(anim)
|
||||
|
||||
func _on_collision_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
|
||||
if player:
|
||||
if player.updating_target and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
player.target = self.collision
|
||||
|
||||
Reference in New Issue
Block a user