Finish Sonic Waves (XD)

main
Luna Brovchuk 2023-10-01 22:21:49 +02:00
parent f314860b17
commit dc3af8c23a
4 changed files with 32 additions and 19 deletions

View File

@ -19,7 +19,6 @@ script = ExtResource( 2 )
use_parent_material = true
frames = ExtResource( 1 )
animation = "idle"
frame = 2
playing = true
centered = false
@ -32,8 +31,3 @@ shape = SubResource( 1 )
[node name="SameSpeciesCollider" type="CollisionShape2D" parent="."]
position = Vector2( 8.5, 10 )
shape = SubResource( 2 )
[node name="Timer" type="Timer" parent="."]
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@ -4,12 +4,31 @@ var velocity = Vector2.ZERO
var speed = 64
onready var sonic_wave_preload = preload("res://src/models/sonic_wave/Sonic_Wave.tscn")
var shooting_timer = .0
var attack_timer = .0
var shooting = false
var shot = false
var sonic_wave
func _ready():
hp = 15
func _physics_process(_delta):
func _physics_process(delta):
if not shooting:
shooting_timer += delta
if shooting_timer >= 2.0:
shooting = true
shooting_timer = .0
if shooting:
attack_timer += delta
if attack_timer >= .5 and not shot:
_shoot()
shot = true
if attack_timer >= 1.0:
attack_timer = 0
shooting = false
shot = false
var player_position = player.global_position + Vector2(12, 12)
var angle = get_angle_to(player_position)
if position.distance_to(player_position) > 64:
@ -29,15 +48,11 @@ func _physics_process(_delta):
self.global_position.y += sin(Time.get_ticks_msec() * 0.01) / 3
velocity *= speed * speed_multiplier
if not shooting:
velocity = move_and_slide(velocity)
func _shoot():
sonic_wave = sonic_wave_preload.instance()
get_parent().add_child(sonic_wave)
sonic_wave.global_position.x = self.global_position.x + 8
sonic_wave.global_position.y = self.global_position.y + 8
func _on_Timer_timeout():
_shoot()

View File

@ -5,10 +5,10 @@
[ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 3.5, 3.5 )
extents = Vector2( 4, 4 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 3.5, 9 )
extents = Vector2( 7, 11 )
[sub_resource type="Animation" id=4]
resource_name = "RESET"
@ -48,7 +48,7 @@ tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 2 ),
"times": PoolRealArray( 0, 0.9 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ true, false ]

View File

@ -3,7 +3,11 @@ extends KinematicBody2D
var velocity = Vector2.ZERO
var speed = 120
onready var player = $"../../Player"
var angle
func _ready():
angle = global_position.angle_to_point(player.global_position)
func _physics_process(delta):
self.global_position = self.global_position.move_toward(player.global_position, delta * speed)
$Sprite.look_at(player.global_position)
$Sprite.rotation_degrees = rad2deg(angle + PI)
move_and_slide(Vector2(speed, 0).rotated(angle + PI))