player.tscn: scholar of the first bullet casings
This commit is contained in:
parent
79cbd62a69
commit
bc57ba4171
45 changed files with 1429 additions and 113 deletions
|
@ -25,6 +25,7 @@ var turns = 0
|
|||
|
||||
const BoneParticle = preload("res://objects/enemy/bone_particle.tscn")
|
||||
const EasyBullet = preload("res://objects/enemy/roboturret_proj.tscn")
|
||||
const BulletCasing = preload("res://objects/enemy/bullet_casing.tscn")
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
|
@ -44,7 +45,7 @@ func _physics_process(delta):
|
|||
if !shooting:
|
||||
# check for player in raycast
|
||||
var collider = shoot_cast.get_collider()
|
||||
if collider != null && (collider.is_in_group("player") or collider.is_in_group("msx")):
|
||||
if collider != null && (collider.is_in_group("player_hitbox") or collider.is_in_group("msx")):
|
||||
if Game.get_sector(global_position) == Game.get_sector(collider.global_position):
|
||||
if Game.is_easy_mode:
|
||||
var easy_bullet = EasyBullet.instance()
|
||||
|
@ -56,13 +57,16 @@ func _physics_process(delta):
|
|||
else:
|
||||
# kill player and enter shooting state temporarily
|
||||
collider.get_parent().die()
|
||||
|
||||
# play sound
|
||||
Audio.play_sound(Audio.a_die_robot, Audio.ac_boss)
|
||||
|
||||
# muzzle flash
|
||||
muzzle_flash.emitting = true
|
||||
shooting = true
|
||||
get_tree().create_timer(0.5, false).connect("timeout", self, "_stop_shoot")
|
||||
sprite.play("shoot")
|
||||
|
||||
# check other raycast to find collision passing through player
|
||||
graphics_cast.force_raycast_update()
|
||||
var hit_position = graphics_cast.to_global(Vector2(256.0, 0.0))
|
||||
|
@ -76,6 +80,16 @@ func _physics_process(delta):
|
|||
# move and play sparks
|
||||
sparks.global_position = hit_position
|
||||
sparks.emitting = true
|
||||
|
||||
# spawn a bullet casing
|
||||
var casing = BulletCasing.instance()
|
||||
casing.rotation = rand_range(0.0, 2.0*PI) # random rotation
|
||||
casing.global_position = shoot_position.global_position
|
||||
casing.linear_velocity = Vector2(45.0 * rand_range(0.5, 1.5), 0.0).rotated(rand_range(-PI, 0.0))
|
||||
casing.angular_velocity = rand_range(-PI*2.0, PI*2.0)
|
||||
var timer = get_tree().create_timer(3.0 + rand_range(0.0, 1.0), false)
|
||||
timer.connect("timeout", casing, "queue_free")
|
||||
get_parent().call_deferred("add_child", casing)
|
||||
return
|
||||
|
||||
# if there aren't turns, walk around
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue