Lasers, AI adjustments
This commit is contained in:
parent
37bb98a436
commit
49fd5c0d65
6 changed files with 88 additions and 49 deletions
|
|
@ -67,6 +67,7 @@ backward={
|
|||
fire={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(588, 29),"global_position":Vector2(597, 77),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
secondary_fire={
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=19 format=3 uid="uid://bauklhpieuivd"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://bauklhpieuivd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0qswyhwbhdua" path="res://scripts/game.gd" id="1_u5sy4"]
|
||||
[ext_resource type="Texture2D" uid="uid://dtwo7g0ipc4k" path="res://textures/ship_1.png" id="1_uwrxv"]
|
||||
|
|
@ -9,9 +9,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://b6tyof2j3ytbv" path="res://sounds/concrete_halls.mp3" id="3_0tnpc"]
|
||||
[ext_resource type="AudioStream" uid="uid://b1ung55xg31l3" path="res://sounds/boost_finish.mp3" id="3_p57ef"]
|
||||
[ext_resource type="AudioStream" uid="uid://y7lhonymtk3t" path="res://sounds/fire.mp3" id="8_vtaks"]
|
||||
[ext_resource type="Script" uid="uid://b7te10evkqwhy" path="res://scripts/laser.gd" id="10_kvpfn"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy6dv2tio433m" path="res://scenes/enemy.tscn" id="11_dinhu"]
|
||||
[ext_resource type="Texture2D" uid="uid://bb0v0jtreyba3" path="res://textures/laser.png" id="11_kvuet"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
|
||||
radius = 16.0
|
||||
|
|
@ -19,20 +17,6 @@ radius = 16.0
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_lnu2h"]
|
||||
radius = 20.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_trtic"]
|
||||
radius = 12.0
|
||||
|
||||
[sub_resource type="Curve" id="Curve_ir15t"]
|
||||
_data = [Vector2(0, 0.5393259), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_ca42v"]
|
||||
curve = SubResource("Curve_ir15t")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_rysoc"]
|
||||
gravity = Vector3(0, 98, 0)
|
||||
alpha_curve = SubResource("CurveTexture_ca42v")
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource("1_u5sy4")
|
||||
|
||||
|
|
@ -85,26 +69,6 @@ rotation_smoothing_speed = 15.0
|
|||
shape = SubResource("CircleShape2D_lnu2h")
|
||||
debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
||||
|
||||
[node name="Laser" type="RigidBody2D" parent="."]
|
||||
position = Vector2(77, -428)
|
||||
linear_damp = 6.247
|
||||
script = ExtResource("10_kvpfn")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="Laser"]
|
||||
texture = ExtResource("11_kvuet")
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="Laser"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape2D" parent="Laser/Hitbox"]
|
||||
shape = SubResource("CircleShape2D_trtic")
|
||||
debug_color = Color(1, 0, 0, 0.41960785)
|
||||
|
||||
[node name="Trail" type="GPUParticles2D" parent="Laser"]
|
||||
amount = 24
|
||||
texture = ExtResource("11_kvuet")
|
||||
lifetime = 0.05
|
||||
process_material = SubResource("ParticleProcessMaterial_rysoc")
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource("11_dinhu")]
|
||||
position = Vector2(0, -418)
|
||||
|
||||
|
|
@ -138,4 +102,3 @@ grow_vertical = 2
|
|||
text = "DIST: 2048"
|
||||
|
||||
[connection signal="body_shape_entered" from="Player/Hitbox" to="Player" method="_on_hitbox_body_shape_entered"]
|
||||
[connection signal="body_shape_entered" from="Laser/Hitbox" to="Laser" method="_on_hitbox_body_shape_entered"]
|
||||
|
|
|
|||
39
scenes/laser.tscn
Normal file
39
scenes/laser.tscn
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://dgj3hd5wlaoc0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b7te10evkqwhy" path="res://scripts/laser.gd" id="1_a7dhc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bb0v0jtreyba3" path="res://textures/laser.png" id="2_jjj73"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_trtic"]
|
||||
radius = 12.0
|
||||
|
||||
[sub_resource type="Curve" id="Curve_ir15t"]
|
||||
_data = [Vector2(0, 0.5393259), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_ca42v"]
|
||||
curve = SubResource("Curve_ir15t")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_rysoc"]
|
||||
gravity = Vector3(0, 98, 0)
|
||||
alpha_curve = SubResource("CurveTexture_ca42v")
|
||||
|
||||
[node name="Laser" type="RigidBody2D"]
|
||||
linear_damp = 6.247
|
||||
script = ExtResource("1_a7dhc")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_jjj73")
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape2D" parent="Hitbox"]
|
||||
shape = SubResource("CircleShape2D_trtic")
|
||||
debug_color = Color(1, 0, 0, 0.41960785)
|
||||
|
||||
[node name="Trail" type="GPUParticles2D" parent="."]
|
||||
amount = 24
|
||||
texture = ExtResource("2_jjj73")
|
||||
lifetime = 0.05
|
||||
process_material = SubResource("ParticleProcessMaterial_rysoc")
|
||||
|
||||
[connection signal="body_shape_entered" from="Hitbox" to="." method="_on_hitbox_body_shape_entered"]
|
||||
|
|
@ -4,7 +4,9 @@ var health = 1000
|
|||
var boost = 100
|
||||
var speed = 480
|
||||
var time_since_last_collision = 1
|
||||
var time_since_last_fire = 0
|
||||
var boosting = false
|
||||
var firing = true
|
||||
|
||||
var axis = 0
|
||||
var movement_axis = -1
|
||||
|
|
@ -15,7 +17,8 @@ var ai_mode = AI_MODE_ATTACK
|
|||
|
||||
var AI_STATE_EVADE_OBJECT = 1
|
||||
var AI_STATE_TRACK_ENEMY = 2
|
||||
var AI_STATE_STATIONARY_ENEMY = 3
|
||||
var AI_STATE_EVADE_ENEMY_AIM = 3
|
||||
var AI_STATE_STATIONARY_ENEMY = 4
|
||||
|
||||
var object_to_evade = null
|
||||
var last_ai_state_before_evasion = AI_STATE_TRACK_ENEMY
|
||||
|
|
@ -29,6 +32,8 @@ var boost_pressed = false
|
|||
var ai_tick = 0.1
|
||||
@onready var player = get_parent().get_node("Player")
|
||||
|
||||
var laser_scene = preload("res://scenes/laser.tscn")
|
||||
|
||||
func cast(angle):
|
||||
$SightCast.rotation_degrees = angle
|
||||
$SightCast.force_raycast_update()
|
||||
|
|
@ -64,6 +69,9 @@ func check_front():
|
|||
return 1
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
modulate.g = health / 1000.0
|
||||
modulate.b = health / 1000.0
|
||||
|
||||
ai_tick -= delta
|
||||
|
||||
if boosting:
|
||||
|
|
@ -86,6 +94,20 @@ func _process(delta: float) -> void:
|
|||
boosting = true
|
||||
$Boost.play()
|
||||
|
||||
time_since_last_fire -= delta
|
||||
|
||||
if (time_since_last_fire <= 0) and firing:
|
||||
time_since_last_fire = 0.25
|
||||
|
||||
var laser = laser_scene.instantiate()
|
||||
|
||||
laser.creator = self
|
||||
|
||||
laser.position = position
|
||||
laser.rotation = rotation
|
||||
|
||||
get_parent().get_node("Unloadables").add_child(laser)
|
||||
|
||||
if time_since_last_collision <= 1:
|
||||
time_since_last_collision += delta
|
||||
|
||||
|
|
@ -115,11 +137,13 @@ func _process(delta: float) -> void:
|
|||
else:
|
||||
boost_pressed = false
|
||||
|
||||
var direction_to_player = global_position.direction_to(player.position).angle() + deg_to_rad(270)
|
||||
|
||||
if ai_state == AI_STATE_TRACK_ENEMY:
|
||||
target_rotation = global_position.direction_to(player.position).angle() + deg_to_rad(270)
|
||||
target_rotation = direction_to_player
|
||||
|
||||
if ai_state == AI_STATE_STATIONARY_ENEMY:
|
||||
target_rotation = global_position.direction_to(player.position).angle() + deg_to_rad(270)
|
||||
target_rotation = direction_to_player
|
||||
movement_axis = 0
|
||||
|
||||
if front_cast:
|
||||
|
|
@ -143,8 +167,6 @@ func _process(delta: float) -> void:
|
|||
if front_cast_distance > 160 * (speed / 300):
|
||||
ai_state = last_ai_state_before_evasion
|
||||
|
||||
print(ai_state)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
axis = 0
|
||||
|
||||
|
|
@ -176,8 +198,6 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if body.linear_velocity.length() + linear_velocity.length() > 256:
|
||||
health -= 100
|
||||
|
||||
$Collision.play()
|
||||
|
||||
time_since_last_collision = 0
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
extends RigidBody2D
|
||||
|
||||
var shooter = null
|
||||
var creator = null
|
||||
var lifetime = 0
|
||||
var has_collided = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if has_collided: return
|
||||
|
||||
linear_velocity = transform.y * -1 * 256
|
||||
linear_velocity = transform.y * -1 * 2048
|
||||
|
||||
|
||||
func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if body != shooter:
|
||||
if body != creator:
|
||||
has_collided = true
|
||||
|
||||
linear_velocity = Vector2()
|
||||
|
|
|
|||
|
|
@ -2,16 +2,33 @@ extends RigidBody2D
|
|||
|
||||
var health = 1000
|
||||
var boost = 100
|
||||
var time_since_last_fire = 0
|
||||
var time_since_last_collision = 1
|
||||
var camera_shake_power = 0
|
||||
var boosting = false
|
||||
|
||||
var laser_scene = preload("res://scenes/laser.tscn")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
modulate.g = health / 1000.0
|
||||
modulate.b = health / 1000.0
|
||||
$Camera.offset.x = randi_range(-camera_shake_power, camera_shake_power)
|
||||
$Camera.offset.y = randi_range(-camera_shake_power, camera_shake_power)
|
||||
|
||||
time_since_last_fire -= delta
|
||||
|
||||
if (time_since_last_fire <= 0) and Input.is_action_pressed("fire"):
|
||||
time_since_last_fire = 0.25
|
||||
|
||||
var laser = laser_scene.instantiate()
|
||||
|
||||
laser.creator = self
|
||||
|
||||
laser.position = position
|
||||
laser.rotation = rotation
|
||||
|
||||
get_parent().get_node("Unloadables").add_child(laser)
|
||||
|
||||
if boosting:
|
||||
if Input.is_action_pressed("boost"):
|
||||
boost -= delta * 40
|
||||
|
|
@ -67,7 +84,6 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if body.linear_velocity.length() + linear_velocity.length() > 256:
|
||||
health -= 100
|
||||
camera_shake_power = 4
|
||||
|
||||
$Collision.play()
|
||||
|
|
|
|||
Loading…
Reference in a new issue