forked from team-sg/hero-mark-2
Marisa Rigate's Big Commit: Disaster Averted!
This commit is contained in:
parent
1215099f4d
commit
263d6219cc
19 changed files with 314 additions and 95 deletions
|
@ -3,25 +3,38 @@ extends KinematicBody2D
|
|||
var velocity = Vector2.ZERO
|
||||
var is_moving = false
|
||||
var is_holding_shard = true
|
||||
var has_respawned = false
|
||||
onready var death_particles = $DeathSplatter
|
||||
onready var sprite = $Sprite
|
||||
onready var anims = $AnimationPlayer
|
||||
onready var raycast = $RayCast2D
|
||||
onready var respawn_raycast = $RespawnRaycast
|
||||
onready var shard_position = $Position2D
|
||||
onready var start_position = position
|
||||
onready var blink_timer = $BlinkTimer
|
||||
const shard = preload("res://objects/collectibles/shard.tscn")
|
||||
const BloodSpray := preload("res://objects/environment/blood/blood_spray.tscn")
|
||||
|
||||
func _ready():
|
||||
raycast.add_exception($Hitbox)
|
||||
blink_timer.start(rand_range(5.0,7.0))
|
||||
|
||||
func _physics_process(delta):
|
||||
print(respawn_raycast.get_collider())
|
||||
if is_moving: velocity.x = -50
|
||||
#Stop when see something
|
||||
if raycast.is_colliding(): velocity.x = 0
|
||||
if raycast.is_colliding():
|
||||
#stop behind sg
|
||||
velocity.x = 0
|
||||
if respawn_raycast.is_colliding():
|
||||
#start moving again after respawning when seeing sg
|
||||
if raycast.get_collider() != null:
|
||||
if raycast.get_collider().is_in_group("player_hitbox"): is_moving = true
|
||||
velocity.y += 128 * delta
|
||||
velocity = move_and_slide_with_snap(velocity, Vector2.DOWN, Vector2.UP, true)
|
||||
#Anims
|
||||
if velocity.x == 0:
|
||||
if !anims.get_current_animation() == "give": anims.play("idle")
|
||||
if !anims.get_current_animation() == "give" && !anims.get_current_animation() == "respawn" && !anims.get_current_animation() == "blink": anims.play("idle")
|
||||
else:
|
||||
anims.play("walk")
|
||||
#Stop at the end of path and give shard
|
||||
|
@ -39,7 +52,18 @@ func spawn_shard():
|
|||
is_holding_shard = false
|
||||
|
||||
func switch_action():
|
||||
is_moving = true
|
||||
#is_moving = true
|
||||
pass
|
||||
|
||||
func spray_blood():
|
||||
for i in 16:
|
||||
var spray = BloodSpray.instance()
|
||||
spray.pause_mode = PAUSE_MODE_PROCESS
|
||||
Physics2DServer.set_active(true)
|
||||
spray.global_position = global_position
|
||||
spray.velocity = Vector2(randf() * 80.0, 0.0).rotated(randf() * TAU)
|
||||
spray.stains_player = false
|
||||
get_parent().add_child(spray)
|
||||
|
||||
func die():
|
||||
#Create particles
|
||||
|
@ -47,5 +71,15 @@ func die():
|
|||
get_parent().add_child(death_particles)
|
||||
death_particles.global_position = global_position
|
||||
death_particles.emitting = true
|
||||
spray_blood()
|
||||
Audio.play_sound(Audio.a_msx_die,Audio.ac_die)
|
||||
queue_free()
|
||||
is_moving = false
|
||||
velocity.x = 0
|
||||
position = start_position
|
||||
anims.play("respawn")
|
||||
has_respawned = true
|
||||
|
||||
|
||||
func _on_BlinkTimer_timeout():
|
||||
anims.play("blink")
|
||||
blink_timer.start(rand_range(5.0,7.0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue