Player Missile
This commit is contained in:
parent
b7b4d03fda
commit
853eb28d33
6 changed files with 80 additions and 9 deletions
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 146 B |
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/PlayerMissle.png-2c0430788415884763891e31b76bacad.stex"
|
path="res://.import/PlayerMissile.png-f8921134c7e116ae2eaef486ddb58b3b.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Assets/Player/PlayerMissle.png"
|
source_file="res://Assets/Player/PlayerMissile.png"
|
||||||
dest_files=[ "res://.import/PlayerMissle.png-2c0430788415884763891e31b76bacad.stex" ]
|
dest_files=[ "res://.import/PlayerMissile.png-f8921134c7e116ae2eaef486ddb58b3b.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
|
@ -3,6 +3,7 @@ extends KinematicBody2D
|
||||||
const DustEffect = preload("res://Scenes/Effects/DustEffect.tscn")
|
const DustEffect = preload("res://Scenes/Effects/DustEffect.tscn")
|
||||||
const WallDustEffect = preload("res://Scenes/Effects/WallDustEffect.tscn")
|
const WallDustEffect = preload("res://Scenes/Effects/WallDustEffect.tscn")
|
||||||
const PlayerBullet = preload("res://Scenes/Player/PlayerBullet.tscn")
|
const PlayerBullet = preload("res://Scenes/Player/PlayerBullet.tscn")
|
||||||
|
const PlayerMissile = preload("res://Scenes/Player/PlayerMissile.tscn")
|
||||||
const JumpEffect = preload("res://Scenes/Effects/JumpEffect.tscn")
|
const JumpEffect = preload("res://Scenes/Effects/JumpEffect.tscn")
|
||||||
|
|
||||||
var PlayerStats = ResourceLoader.PlayerStats
|
var PlayerStats = ResourceLoader.PlayerStats
|
||||||
|
@ -17,6 +18,7 @@ export (int) var wall_slide_speed = 42
|
||||||
export (int) var max_wall_slide_speed = 128
|
export (int) var max_wall_slide_speed = 128
|
||||||
export (int) var max_slope = 46
|
export (int) var max_slope = 46
|
||||||
export (int) var bullet_speed = 250
|
export (int) var bullet_speed = 250
|
||||||
|
export (int) var missile_speed = 250
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MOVE,
|
MOVE,
|
||||||
|
@ -79,6 +81,9 @@ func _physics_process(delta):
|
||||||
|
|
||||||
if Input.is_action_pressed("fire") and fireBulletTimer.time_left == 0:
|
if Input.is_action_pressed("fire") and fireBulletTimer.time_left == 0:
|
||||||
fire_bullet()
|
fire_bullet()
|
||||||
|
|
||||||
|
if Input.is_action_pressed("fire_missile") and fireBulletTimer.time_left == 0:
|
||||||
|
fire_missile()
|
||||||
|
|
||||||
func fire_bullet():
|
func fire_bullet():
|
||||||
var bullet = Utils.instance_scene_on_main(PlayerBullet, muzzle.global_position)
|
var bullet = Utils.instance_scene_on_main(PlayerBullet, muzzle.global_position)
|
||||||
|
@ -87,6 +92,14 @@ func fire_bullet():
|
||||||
bullet.rotation = bullet.velocity.angle()
|
bullet.rotation = bullet.velocity.angle()
|
||||||
fireBulletTimer.start()
|
fireBulletTimer.start()
|
||||||
|
|
||||||
|
func fire_missile():
|
||||||
|
var missile = Utils.instance_scene_on_main(PlayerMissile, muzzle.global_position)
|
||||||
|
missile.velocity = Vector2.RIGHT.rotated(playerGun.rotation) * missile_speed
|
||||||
|
missile.velocity.x *= sprite.scale.x # Flip left/right depending on players direction
|
||||||
|
motion -= missile.velocity * 0.25
|
||||||
|
missile.rotation = missile.velocity.angle()
|
||||||
|
fireBulletTimer.start()
|
||||||
|
|
||||||
func create_dust_effect():
|
func create_dust_effect():
|
||||||
var dust_position = global_position
|
var dust_position = global_position
|
||||||
dust_position.x += rand_range(-4, 4)
|
dust_position.x += rand_range(-4, 4)
|
||||||
|
@ -134,7 +147,9 @@ func apply_gravity(delta):
|
||||||
motion.y = min(motion.y, jump_force)
|
motion.y = min(motion.y, jump_force)
|
||||||
|
|
||||||
func update_animations(input_vector):
|
func update_animations(input_vector):
|
||||||
sprite.scale.x = sign(get_local_mouse_position().x)
|
var facing = sign(get_local_mouse_position().x)
|
||||||
|
if facing != 0:
|
||||||
|
sprite.scale.x = facing
|
||||||
animation.playback_speed = 1
|
animation.playback_speed = 1
|
||||||
|
|
||||||
if input_vector.x != 0:
|
if input_vector.x != 0:
|
||||||
|
|
|
@ -74,7 +74,7 @@ tracks/1/keys = {
|
||||||
} ]
|
} ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=5]
|
[sub_resource type="Animation" id=4]
|
||||||
resource_name = "WallSlide"
|
resource_name = "WallSlide"
|
||||||
length = 0.1
|
length = 0.1
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
|
@ -90,8 +90,7 @@ tracks/0/keys = {
|
||||||
"values": [ 10 ]
|
"values": [ 10 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=4]
|
[sub_resource type="Animation" id=5]
|
||||||
resource_name = "Blink"
|
|
||||||
length = 0.9
|
length = 0.9
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("Sprite:visible")
|
tracks/0/path = NodePath("Sprite:visible")
|
||||||
|
@ -145,10 +144,10 @@ shape = ExtResource( 6 )
|
||||||
anims/Idle = SubResource( 1 )
|
anims/Idle = SubResource( 1 )
|
||||||
anims/Jump = SubResource( 2 )
|
anims/Jump = SubResource( 2 )
|
||||||
anims/Run = SubResource( 3 )
|
anims/Run = SubResource( 3 )
|
||||||
anims/WallSlide = SubResource( 5 )
|
anims/WallSlide = SubResource( 4 )
|
||||||
|
|
||||||
[node name="BlinkAnimator" type="AnimationPlayer" parent="."]
|
[node name="BlinkAnimator" type="AnimationPlayer" parent="."]
|
||||||
anims/Blink = SubResource( 4 )
|
anims/Blink = SubResource( 5 )
|
||||||
|
|
||||||
[node name="Debug" parent="." instance=ExtResource( 3 )]
|
[node name="Debug" parent="." instance=ExtResource( 3 )]
|
||||||
visible = false
|
visible = false
|
||||||
|
@ -174,6 +173,7 @@ position = Vector2( 0, -7 )
|
||||||
shape = ExtResource( 6 )
|
shape = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="InvincibleTimer" type="Timer" parent="."]
|
[node name="InvincibleTimer" type="Timer" parent="."]
|
||||||
|
|
||||||
[connection signal="hit" from="Hurtbox" to="." method="_on_Hurtbox_hit"]
|
[connection signal="hit" from="Hurtbox" to="." method="_on_Hurtbox_hit"]
|
||||||
|
|
||||||
[editable path="Hurtbox"]
|
[editable path="Hurtbox"]
|
||||||
|
|
51
metroidvania/Scenes/Player/PlayerMissile.tscn
Normal file
51
metroidvania/Scenes/Player/PlayerMissile.tscn
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Assets/Player/PlayerMissile.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Objects/Proyectile.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://Assets/Effects/Particle.png" type="Texture" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 7, 2 )
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id=2]
|
||||||
|
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id=3]
|
||||||
|
curve = SubResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=4]
|
||||||
|
emission_shape = 2
|
||||||
|
emission_box_extents = Vector3( 0, 2, 0 )
|
||||||
|
flag_disable_z = true
|
||||||
|
gravity = Vector3( 0, 10, 0 )
|
||||||
|
initial_velocity = 5.0
|
||||||
|
initial_velocity_random = 0.5
|
||||||
|
orbit_velocity = 0.0
|
||||||
|
orbit_velocity_random = 0.0
|
||||||
|
scale_curve = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="PlayerMissile" instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Sprite" parent="." index="0"]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="VisibilityNotifier2D" parent="." index="1"]
|
||||||
|
position = Vector2( -0.5, 0 )
|
||||||
|
scale = Vector2( 2.125, 1 )
|
||||||
|
|
||||||
|
[node name="Hitbox" parent="." index="3"]
|
||||||
|
collision_mask = 10
|
||||||
|
damage = 3
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hitbox" index="0"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Particles2D" type="Particles2D" parent="." index="4"]
|
||||||
|
position = Vector2( -8, 0 )
|
||||||
|
lifetime = 0.4
|
||||||
|
preprocess = 0.2
|
||||||
|
local_coords = false
|
||||||
|
process_material = SubResource( 4 )
|
||||||
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
|
[editable path="Hitbox"]
|
|
@ -110,6 +110,11 @@ pause={
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
fire_missile={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue