IN PROCESS Shoot
parent
0a15ff1634
commit
52602364f3
|
@ -75,6 +75,12 @@ 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":0,"physical_scancode":16777234,"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":0,"physical_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)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var speed = 128
|
||||
var velocity = Vector2.ZERO
|
||||
|
||||
func _physics_process(_delta):
|
||||
velocity.x = speed
|
||||
move_and_slide(velocity)
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/models/bullet/bullet.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/models/bullet/Bullet.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 3.5, 3.5 )
|
||||
|
||||
[node name="Bullet" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/bullet.png-7146bc96edc61364c883e6ea6db4f1ea.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/models/bullet/bullet.png"
|
||||
dest_files=[ "res://.import/bullet.png-7146bc96edc61364c883e6ea6db4f1ea.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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
|
@ -9,7 +9,7 @@ func _ready():
|
|||
hp = 15
|
||||
|
||||
func _physics_process(_delta):
|
||||
var player_position = player.global_position + Vector2(8, 8)
|
||||
var player_position = player.global_position + Vector2(12, 12)
|
||||
var angle = get_angle_to(player_position)
|
||||
if position.distance_to(player_position) > 64:
|
||||
velocity.x = cos(angle)
|
||||
|
|
|
@ -5,6 +5,14 @@ var speed_multiplier: float = 1.0
|
|||
var slowed = false
|
||||
var target
|
||||
var speed = 100
|
||||
|
||||
onready var bullet = preload("res://src/models/bullet/Bullet.tscn")
|
||||
var bullet_instance
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("shoot"):
|
||||
_shoot()
|
||||
|
||||
func get_input():
|
||||
var input_direction = Input.get_vector("left", "right", "up", "down")
|
||||
velocity = input_direction * speed
|
||||
|
@ -29,7 +37,6 @@ func _physics_process(_delta):
|
|||
|
||||
const SHADER = preload("res://res/shaders/outline.tres")
|
||||
|
||||
|
||||
func choose_target():
|
||||
var least_dist = 4000
|
||||
var enemy_dist
|
||||
|
@ -40,3 +47,9 @@ func choose_target():
|
|||
least_dist = enemy_dist
|
||||
target = enemy
|
||||
#enemy.set_shader_param("width", 0)
|
||||
|
||||
func _shoot():
|
||||
bullet_instance = bullet.instance()
|
||||
get_parent().add_child(bullet_instance)
|
||||
bullet_instance.global_position.x = get_node("../Player").global_position.x + 12
|
||||
bullet_instance.global_position.y = get_node("../Player").global_position.y - 4
|
||||
|
|
Loading…
Reference in New Issue