added attacks
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
extends CharacterBody2D
|
||||
extends Entity
|
||||
class_name Player
|
||||
|
||||
signal color_changed(color: Color)
|
||||
signal lives_changed(lives: int)
|
||||
|
||||
@onready var sprite_2d: Sprite2D = $Sprite2D
|
||||
const ATTACK := preload("res://scene/attack.tscn")
|
||||
|
||||
var color := Color.WHITE
|
||||
@export var speed = 100
|
||||
var lives: int = 1
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var input_direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
@@ -33,3 +31,8 @@ func _physics_process(delta: float) -> void:
|
||||
color.b -= 0.25
|
||||
sprite_2d.modulate = color
|
||||
color_changed.emit(color)
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
var attack: Attack = ATTACK.instantiate()
|
||||
attack.set_initiator(self)
|
||||
get_parent().add_sibling(attack)
|
||||
|
||||
Reference in New Issue
Block a user