feat: player health wip
This commit is contained in:
parent
da46fd1db7
commit
8f4f47d67d
@ -1,15 +1,25 @@
|
|||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
@onready var global = $"/root/Player"
|
@onready var global = $"/root/Player"
|
||||||
|
var playerHealth = 100.0
|
||||||
|
var dead = false
|
||||||
const SPEED = 350.0
|
const SPEED = 350.0
|
||||||
var charAngle = 0.0
|
var charAngle = 0.0
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
global.emit_signal("playerPosition",self.global_position)
|
global.emit_signal("playerPosition",self.global_position)
|
||||||
movement()
|
if dead != true:
|
||||||
|
movement()
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if dead != false:
|
||||||
|
setAnimation("Death")
|
||||||
|
if Input.is_action_just_pressed("test"):
|
||||||
|
playerDamage(100)
|
||||||
|
|
||||||
|
func setAnimation(anim):
|
||||||
|
if $"Birb".animation != anim:
|
||||||
|
$Birb.animation = anim
|
||||||
|
$"Birb".play()
|
||||||
|
|
||||||
func animation():
|
|
||||||
pass
|
|
||||||
|
|
||||||
func movement():
|
func movement():
|
||||||
var vertical = Input.get_axis("up","down")
|
var vertical = Input.get_axis("up","down")
|
||||||
var horizontal = Input.get_axis("left","right")
|
var horizontal = Input.get_axis("left","right")
|
||||||
@ -24,4 +34,10 @@ func movement():
|
|||||||
velocity.y = SPEED * vertical
|
velocity.y = SPEED * vertical
|
||||||
velocity.x = SPEED * horizontal
|
velocity.x = SPEED * horizontal
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
$"../Camera2D/Label".text = (str(charAngle*180/PI))
|
#$"../UI/Label".text = (str(charAngle*180/PI))
|
||||||
|
|
||||||
|
func playerDamage(amount):
|
||||||
|
if dead == false:
|
||||||
|
playerHealth -= amount
|
||||||
|
if playerHealth <= 0 and dead == false:
|
||||||
|
dead = true
|
||||||
|
@ -59,6 +59,11 @@ right={
|
|||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
test={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":84,"key_label":0,"unicode":116,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user