Add first gun fire
The fire will be of a simple kind initially, but it could be swapped during the game for something different (power-ups?)master
parent
374fb2d613
commit
abe8d86124
Binary file not shown.
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/SimpleGunShot.png-9f4751826e09c42069e0e43d2842bcdb.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/misc/SimpleGunShot.png"
|
||||||
|
dest_files=[ "res://.import/SimpleGunShot.png-9f4751826e09c42069e0e43d2842bcdb.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,27 @@
|
||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/misc/SimpleGunShot.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://assets/misc/Hitbox.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://src/misc/SimpleGunShot.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://src/misc/SimpleGunShotHitbox.gd" type="Script" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 1.00781, 1.99957 )
|
||||||
|
|
||||||
|
[node name="SimpleGunShot" type="KinematicBody2D"]
|
||||||
|
visible = false
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 20
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="GunShotHitbox" parent="." instance=ExtResource( 2 )]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="GunShotHitbox" index="0"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
[connection signal="area_entered" from="GunShotHitbox" to="GunShotHitbox" method="_on_Hitbox_area_entered"]
|
||||||
|
|
||||||
|
[editable path="GunShotHitbox"]
|
|
@ -19,3 +19,6 @@ texture = ExtResource( 1 )
|
||||||
position = Vector2( 0, 3 )
|
position = Vector2( 0, 3 )
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="GunShot" type="Node2D" parent="."]
|
||||||
|
position = Vector2( 5, -20 )
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -57,9 +57,12 @@ ui_accept={
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"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":16777222,"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":16777222,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":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":32,"unicode":0,"echo":false,"script":null)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
ui_select={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
ui_left={
|
ui_left={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
|
||||||
|
@ -88,6 +91,12 @@ ui_down={
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"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":83,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
shoot={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
export var SPEED = 5
|
||||||
|
|
||||||
|
var _velocity = Vector2.ZERO
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
move_and_collide(Vector2(0, SPEED * -1))
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
func _on_Hitbox_area_entered(area):
|
||||||
|
queue_free()
|
|
@ -1,21 +1,34 @@
|
||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
const SimpleGunShot = preload("res://assets/misc/SimpleGunShot.tscn")
|
||||||
|
|
||||||
export var ACCELERATION: int = 700
|
export var ACCELERATION: int = 700
|
||||||
export var MAX_SPEED: int = 150
|
export var MAX_SPEED: int = 150
|
||||||
export var ROLL_SPEED: int = 120
|
export var ROLL_SPEED: int = 120
|
||||||
export var FRICTION: int = 550
|
export var FRICTION: int = 550
|
||||||
|
|
||||||
var velocity: Vector2 = Vector2.ZERO
|
var _velocity: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("shoot"):
|
||||||
|
shoot()
|
||||||
|
move(delta)
|
||||||
|
|
||||||
|
func shoot() -> void:
|
||||||
|
var simpleGunShot := SimpleGunShot.instance()
|
||||||
|
var gunShot := get_node("GunShot")
|
||||||
|
simpleGunShot.position = gunShot.get_global_position()
|
||||||
|
get_tree().current_scene.add_child(simpleGunShot)
|
||||||
|
|
||||||
|
func move(delta: float) -> void:
|
||||||
var input_vector := Vector2.ZERO
|
var input_vector := Vector2.ZERO
|
||||||
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
|
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
|
||||||
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
|
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
|
||||||
input_vector = input_vector.normalized()
|
input_vector = input_vector.normalized()
|
||||||
|
|
||||||
if input_vector != Vector2.ZERO:
|
if input_vector != Vector2.ZERO:
|
||||||
input_vector = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
input_vector = _velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||||
else:
|
else:
|
||||||
input_vector = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
input_vector = _velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||||
|
|
||||||
velocity = move_and_slide(input_vector)
|
_velocity = move_and_slide(input_vector)
|
||||||
|
|
Loading…
Reference in New Issue