Made ship more responsive, refactored responsibility for hit/death into the thing that got hit/died
This commit is contained in:
parent
cae134a054
commit
baa57c4d33
3 changed files with 52 additions and 28 deletions
|
|
@ -2,8 +2,9 @@ extends Area2D
|
|||
|
||||
var velocity = Vector2(0, 0)
|
||||
var rot_velocity = 0
|
||||
|
||||
var explosion = preload('res://Scenes/explosion.tscn')
|
||||
var pop = preload("res://Sounds/Explosion5.wav")
|
||||
var pop = preload("res://Sounds/Explosion.wav")
|
||||
|
||||
func _ready() -> void:
|
||||
connect("body_entered", _on_body_entered)
|
||||
|
|
@ -15,14 +16,16 @@ func _physics_process(delta):
|
|||
Utils.wrap_position(self)
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.name == "Ship":
|
||||
Game.set_lives(Game.lives - 1)
|
||||
|
||||
Utils.play_sound(pop, get_parent())
|
||||
|
||||
var boom = explosion.instantiate()
|
||||
boom.position = body.global_position
|
||||
boom.scale = Vector2(6, 6)
|
||||
get_parent().add_child(boom)
|
||||
body.reset()
|
||||
if body.name == "Ship" and body.hit():
|
||||
queue_free()
|
||||
|
||||
func hit():
|
||||
Utils.play_sound(pop, get_parent())
|
||||
|
||||
var boom = explosion.instantiate()
|
||||
boom.position = global_position
|
||||
boom.scale = scale
|
||||
get_parent().add_child(boom)
|
||||
|
||||
Game.set_score(Game.score + 100)
|
||||
queue_free()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue