First Prototype
This commit is contained in:
parent
c321b70bb0
commit
eb11047456
35 changed files with 779 additions and 4 deletions
47
scenes/game/entities/entity.gd
Normal file
47
scenes/game/entities/entity.gd
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
## Signal for when the entity dies
|
||||
signal death
|
||||
## Signal for when the entity gets damaged
|
||||
signal damaged
|
||||
## Signal for when the entity gets healed
|
||||
signal healed
|
||||
|
||||
## The maximal possible amount of Health for the Entity
|
||||
@export_range(1,100) var maxHealth = 10
|
||||
|
||||
## The maximal possible Speed of the Entity
|
||||
@export_range(100,500) var maxSpeed = 200
|
||||
## The normal Speed between Min and Max
|
||||
@export_range(100,500) var normalSpeed = 100
|
||||
## The lowest possible Speed of the Entity
|
||||
@export_range(100,500) var minSpeed = 50
|
||||
|
||||
## Acceleration of the Entity
|
||||
@export_range(100,500) var acceleration = 10
|
||||
|
||||
@onready var health = maxHealth
|
||||
@onready var speed = normalSpeed
|
||||
var invincible = false
|
||||
|
||||
func hit(damage : int) -> void:
|
||||
health -= damage
|
||||
damaged.emit()
|
||||
if health <= 0:
|
||||
health = 0
|
||||
death.emit()
|
||||
|
||||
func heal(heal : int) -> void:
|
||||
health += heal
|
||||
healed.emit()
|
||||
if health >= maxHealth:
|
||||
health = maxHealth
|
||||
|
||||
func resetSpeed():
|
||||
speed = normalSpeed
|
||||
|
||||
func resetHealth():
|
||||
health = health
|
||||
|
||||
func setSpeed(n):
|
||||
speed = n
|
||||
Loading…
Add table
Add a link
Reference in a new issue