0 Commits
4 changed files with 17 additions and 36 deletions

No files matched your search

+14 -31
View File
@@ -17,12 +17,6 @@ var desired_rotation: float = 0
# Resources / money # Resources / money
var resources: int = 0 var resources: int = 0
# Health
var healthPoints: int = 100
var isAlive: bool = true
@onready var invulnerable_cooldown_timer: Timer = $InvulnerableCooldownTimer
var hasiframes: bool = false # only used for iframe after collision for now
func _ready() -> void: func _ready() -> void:
var screen_size = get_viewport_rect().size var screen_size = get_viewport_rect().size
GameManager.init_screen_size(screen_size.x, screen_size.y) GameManager.init_screen_size(screen_size.x, screen_size.y)
@@ -33,19 +27,17 @@ func _ready() -> void:
func _process(delta): func _process(delta):
# TODO: Connects this to some respawn screen velocity = Vector2.ZERO
if isAlive: if Input.is_action_pressed("move_right"):
velocity = Vector2.ZERO velocity.x += 1
if Input.is_action_pressed("move_right"): if Input.is_action_pressed("move_left"):
velocity.x += 1 velocity.x -= 1
if Input.is_action_pressed("move_left"): if Input.is_action_pressed("move_down"):
velocity.x -= 1 velocity.y += 1
if Input.is_action_pressed("move_down"): if Input.is_action_pressed("move_up"):
velocity.y += 1 velocity.y -= 1
if Input.is_action_pressed("move_up"): if Input.is_action_pressed("try_attack"):
velocity.y -= 1 try_attack()
if Input.is_action_pressed("try_attack"):
try_attack()
if not velocity.is_zero_approx(): if not velocity.is_zero_approx():
@@ -74,7 +66,7 @@ func _on_attack_timeout() -> void:
sprite.play("default") sprite.play("default")
attack_cooldown_timer.start() attack_cooldown_timer.start()
func _on_attack_cooldown_timeout() -> void: func _on_cooldown_timeout() -> void:
can_attack = true can_attack = true
func _on_attack_hit(body: Node2D) -> void: func _on_attack_hit(body: Node2D) -> void:
@@ -90,18 +82,9 @@ func _on_attack_hit(body: Node2D) -> void:
sprite.play("default") sprite.play("default")
# TODO: resource handling logic # TODO: resource handling logic
func _on_invulnerable_cooldown_timeout() -> void:
hasiframes = false
func handle_damage(dmg: int, src: Node) -> void: func handle_damage(dmg: int, src: Node) -> void:
# TODO: enhanced damage logic (src entity effects?) # TODO: damage logic
if not hasiframes: pass
print("Player took %d damage." % dmg)
healthPoints -= dmg
hasiframes = true
invulnerable_cooldown_timer.start()
if healthPoints <= 0:
isAlive = false
func collect_resource(damnt: int) -> void: func collect_resource(damnt: int) -> void:
resources += damnt resources += damnt
@@ -59,10 +59,6 @@ one_shot = true
[node name="AttackCooldownTimer" type="Timer" parent="." unique_id=1056439284] [node name="AttackCooldownTimer" type="Timer" parent="." unique_id=1056439284]
one_shot = true one_shot = true
[node name="InvulnerableCooldownTimer" type="Timer" parent="." unique_id=311411582]
one_shot = true
[connection signal="body_entered" from="AttackArea" to="." method="_on_attack_hit"] [connection signal="body_entered" from="AttackArea" to="." method="_on_attack_hit"]
[connection signal="timeout" from="AttackTimer" to="." method="_on_attack_timeout"] [connection signal="timeout" from="AttackTimer" to="." method="_on_attack_timeout"]
[connection signal="timeout" from="AttackCooldownTimer" to="." method="_on_attack_cooldown_timeout"] [connection signal="timeout" from="AttackCooldownTimer" to="." method="_on_cooldown_timeout"]
[connection signal="timeout" from="InvulnerableCooldownTimer" to="." method="_on_invulnerable_cooldown_timeout"]
+1
View File
@@ -1,3 +1,4 @@
@abstract
extends CharacterBody2D extends CharacterBody2D
class_name NPC2D class_name NPC2D
+1
View File
@@ -1,3 +1,4 @@
@abstract
extends NPC2D extends NPC2D
class_name AbstractPrey2D class_name AbstractPrey2D
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.