Lessons: Player health, damage, stats, resources
This commit is contained in:
parent
147199a012
commit
7842e15c6c
13 changed files with 153 additions and 18 deletions
|
@ -4,6 +4,8 @@ const DustEffect = preload("res://Scenes/Effects/DustEffect.tscn")
|
|||
const PlayerBullet = preload("res://Scenes/Player/PlayerBullet.tscn")
|
||||
const JumpEffect = preload("res://Scenes/Effects/JumpEffect.tscn")
|
||||
|
||||
var PlayerStats = ResourceLoader.PlayerStats
|
||||
|
||||
export (int) var acceleration = 512
|
||||
export (int) var max_speed = 64
|
||||
export (float) var friction = 0.25
|
||||
|
@ -12,6 +14,7 @@ export (int) var jump_force = 128
|
|||
export (int) var max_slope = 46
|
||||
export (int) var bullet_speed = 250
|
||||
|
||||
var invincible = false setget set_invincible
|
||||
var motion = Vector2.ZERO
|
||||
var snap_vector = Vector2.ZERO
|
||||
var just_jumped= false
|
||||
|
@ -22,8 +25,15 @@ onready var coyoteJumpTimer = $CoyoteJumpTimer
|
|||
onready var playerGun = $Sprite/PlayerGun
|
||||
onready var muzzle = $Sprite/PlayerGun/Sprite/Muzzle
|
||||
onready var fireBulletTimer = $FireBulletTimer
|
||||
onready var blinkAnimator = $BlinkAnimator
|
||||
|
||||
|
||||
func set_invincible(value):
|
||||
invincible = value
|
||||
|
||||
func _ready():
|
||||
PlayerStats.connect("player_died", self, "_on_died")
|
||||
|
||||
func _physics_process(delta):
|
||||
just_jumped = false
|
||||
var input_vector = get_input_vector()
|
||||
|
@ -125,3 +135,11 @@ func move():
|
|||
if is_on_floor() and get_floor_velocity().length() == 0 and abs(motion.x) < 1:
|
||||
position.x = last_position.x
|
||||
|
||||
func _on_Hurtbox_hit(damage):
|
||||
if not invincible:
|
||||
PlayerStats.health -= damage
|
||||
blinkAnimator.play("Blink")
|
||||
|
||||
|
||||
func _on_died():
|
||||
queue_free()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue