godot-shooter / meteor / files / MeteorLarge.gd
Branch meteor · default branch · all branches
MeteorLarge.gd
0a6bdc27 2023-11-06 Pavel Safronov | 1 | extends KinematicBody2D |
| 2 | ||
| 3 | export var health = 5 | |
| 4 | export var max_health = 5 | |
| 5 | export var size = 1 | |
| 6 | export var velocity: Vector2 = Vector2(1,1).normalized() | |
| 7 | ||
| 8 | func _ready() -> void: | |
| 9 | scale = Vector2(size, size) | |
| 10 | ||
| 11 | func hurt(damage: int = 1) -> void: | |
| 12 | health -= 1 | |
| 13 | if health <= 0: | |
| 14 | kill() | |
| 15 | ||
| 16 | func kill() -> void: | |
| 17 | queue_free() | |
| 18 | ||
| 19 | func _physics_process(delta: float) -> void: | |
| 20 | velocity = move_and_slide(velocity) |