Boost & health bars, enemy AI improvements, LimboConsole commands
This commit is contained in:
parent
45c79db18c
commit
14d397ab60
5 changed files with 229 additions and 11 deletions
160
scenes/game.tscn
160
scenes/game.tscn
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=21 format=4 uid="uid://bauklhpieuivd"]
|
[gd_scene load_steps=28 format=4 uid="uid://bauklhpieuivd"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d0qswyhwbhdua" path="res://scripts/game.gd" id="1_u5sy4"]
|
[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"]
|
[ext_resource type="Texture2D" uid="uid://dtwo7g0ipc4k" path="res://textures/ship_1.png" id="1_uwrxv"]
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
[ext_resource type="Shader" uid="uid://bk7q00br1ms30" path="res://scripts/retro.gdshader" id="12_kvuet"]
|
[ext_resource type="Shader" uid="uid://bk7q00br1ms30" path="res://scripts/retro.gdshader" id="12_kvuet"]
|
||||||
[ext_resource type="Texture2D" uid="uid://hgfmjw6gbdnn" path="res://textures/blank.png" id="12_trtic"]
|
[ext_resource type="Texture2D" uid="uid://hgfmjw6gbdnn" path="res://textures/blank.png" id="12_trtic"]
|
||||||
[ext_resource type="Script" uid="uid://d0txwo63hlrsy" path="res://scripts/enterable.gd" id="13_trtic"]
|
[ext_resource type="Script" uid="uid://d0txwo63hlrsy" path="res://scripts/enterable.gd" id="13_trtic"]
|
||||||
|
[ext_resource type="Theme" uid="uid://dtc7h6gpwpend" path="res://scenes/ui.tres" id="15_ir15t"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ir15t"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ir15t"]
|
||||||
texture = ExtResource("12_trtic")
|
texture = ExtResource("12_trtic")
|
||||||
|
|
@ -35,6 +36,29 @@ points = PackedVector2Array(-16, 16, 16, 16, 0, -16)
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_lnu2h"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_lnu2h"]
|
||||||
radius = 20.0
|
radius = 20.0
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ca42v"]
|
||||||
|
bg_color = Color(0, 0, 1, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_rysoc"]
|
||||||
|
outline_size = 2
|
||||||
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ssvqc"]
|
||||||
|
bg_color = Color(1, 0, 0, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ir15t"]
|
||||||
|
bg_color = Color(0.5421658, 0.0015220869, 0.72708863, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_ca42v"]
|
||||||
|
outline_size = 2
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rysoc"]
|
||||||
|
bg_color = Color(1, 0, 0, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_trtic"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_trtic"]
|
||||||
shader = ExtResource("12_kvuet")
|
shader = ExtResource("12_kvuet")
|
||||||
shader_parameter/shake = 0.002000000095
|
shader_parameter/shake = 0.002000000095
|
||||||
|
|
@ -85,6 +109,8 @@ shape = SubResource("RectangleShape2D_kvuet")
|
||||||
position = Vector2(0, 245.5)
|
position = Vector2(0, 245.5)
|
||||||
rotation = 3.1415927
|
rotation = 3.1415927
|
||||||
|
|
||||||
|
[node name="Unloadables" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Player" type="RigidBody2D" parent="."]
|
[node name="Player" type="RigidBody2D" parent="."]
|
||||||
position = Vector2(-78, 957)
|
position = Vector2(-78, 957)
|
||||||
linear_damp = 6.247
|
linear_damp = 6.247
|
||||||
|
|
@ -105,6 +131,7 @@ bus = &"Sound Effects"
|
||||||
|
|
||||||
[node name="Fire" type="AudioStreamPlayer" parent="Player"]
|
[node name="Fire" type="AudioStreamPlayer" parent="Player"]
|
||||||
stream = ExtResource("8_vtaks")
|
stream = ExtResource("8_vtaks")
|
||||||
|
max_polyphony = 4
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="Player"]
|
[node name="Sprite" type="Sprite2D" parent="Player"]
|
||||||
texture = ExtResource("1_uwrxv")
|
texture = ExtResource("1_uwrxv")
|
||||||
|
|
@ -125,7 +152,83 @@ rotation_smoothing_speed = 15.0
|
||||||
shape = SubResource("CircleShape2D_lnu2h")
|
shape = SubResource("CircleShape2D_lnu2h")
|
||||||
debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
||||||
|
|
||||||
[node name="Unloadables" type="Node2D" parent="."]
|
[node name="BoostMeter" type="ProgressBar" parent="Player"]
|
||||||
|
custom_minimum_size = Vector2(12, 0)
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -54.0
|
||||||
|
offset_top = -24.0
|
||||||
|
offset_right = -42.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_ca42v")
|
||||||
|
value = 100.0
|
||||||
|
fill_mode = 2
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Player/BoostMeter"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -23.0
|
||||||
|
offset_top = -12.0
|
||||||
|
offset_right = 23.0
|
||||||
|
offset_bottom = 12.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
pivot_offset = Vector2(23, 12)
|
||||||
|
text = "100"
|
||||||
|
label_settings = SubResource("LabelSettings_rysoc")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="HealthMeter" type="ProgressBar" parent="Player"]
|
||||||
|
custom_minimum_size = Vector2(12, 0)
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = 42.0
|
||||||
|
offset_top = -24.0
|
||||||
|
offset_right = 54.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_ssvqc")
|
||||||
|
value = 100.0
|
||||||
|
fill_mode = 2
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Player/HealthMeter"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -23.0
|
||||||
|
offset_top = -12.0
|
||||||
|
offset_right = 23.0
|
||||||
|
offset_bottom = 12.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
pivot_offset = Vector2(23, 12)
|
||||||
|
text = "100"
|
||||||
|
label_settings = SubResource("LabelSettings_rysoc")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="UI" type="CanvasLayer" parent="."]
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
|
@ -154,6 +257,59 @@ offset_bottom = 12.0
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
text = "DIST: 2048"
|
text = "DIST: 2048"
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="UI/Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -52.0
|
||||||
|
offset_right = 260.0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme = ExtResource("15_ir15t")
|
||||||
|
|
||||||
|
[node name="HFlowContainer" type="HFlowContainer" parent="UI/Control/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/v_separation = 0
|
||||||
|
|
||||||
|
[node name="Fuel" type="ProgressBar" parent="UI/Control/PanelContainer/HFlowContainer"]
|
||||||
|
custom_minimum_size = Vector2(256, 24)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_ir15t")
|
||||||
|
value = 100.0
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="UI/Control/PanelContainer/HFlowContainer/Fuel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
text = "100% FUEL"
|
||||||
|
label_settings = SubResource("LabelSettings_ca42v")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Health" type="ProgressBar" parent="UI/Control/PanelContainer/HFlowContainer"]
|
||||||
|
custom_minimum_size = Vector2(256, 24)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_rysoc")
|
||||||
|
value = 50.0
|
||||||
|
fill_mode = 1
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="UI/Control/PanelContainer/HFlowContainer/Health"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
text = "+1000 HEALTH"
|
||||||
|
label_settings = SubResource("LabelSettings_ca42v")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="FadeToBlack" type="ColorRect" parent="UI"]
|
[node name="FadeToBlack" type="ColorRect" parent="UI"]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dtc7h6gpwpend"]
|
[gd_resource type="Theme" load_steps=7 format=3 uid="uid://dtc7h6gpwpend"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mq06m"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mq06m"]
|
||||||
bg_color = Color(0, 0, 0, 1)
|
bg_color = Color(0, 0, 0, 1)
|
||||||
|
|
@ -29,6 +29,23 @@ expand_margin_top = 2.0
|
||||||
expand_margin_right = 2.0
|
expand_margin_right = 2.0
|
||||||
expand_margin_bottom = 2.0
|
expand_margin_bottom = 2.0
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s6eqm"]
|
||||||
|
bg_color = Color(0, 0, 0, 1)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(0.53333336, 0.53333336, 0.53333336, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cv53u"]
|
||||||
|
bg_color = Color(0, 0, 0, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_twtfq"]
|
||||||
|
bg_color = Color(1, 1, 1, 1)
|
||||||
|
corner_detail = 1
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
Button/colors/font_color = Color(0, 0, 0, 1)
|
Button/colors/font_color = Color(0, 0, 0, 1)
|
||||||
Button/colors/font_focus_color = Color(1, 1, 1, 1)
|
Button/colors/font_focus_color = Color(1, 1, 1, 1)
|
||||||
|
|
@ -41,3 +58,9 @@ Button/styles/hover = SubResource("StyleBoxFlat_mq06m")
|
||||||
Button/styles/hover_pressed = SubResource("StyleBoxFlat_ue5e3")
|
Button/styles/hover_pressed = SubResource("StyleBoxFlat_ue5e3")
|
||||||
Button/styles/normal = SubResource("StyleBoxFlat_oei2i")
|
Button/styles/normal = SubResource("StyleBoxFlat_oei2i")
|
||||||
Button/styles/pressed = SubResource("StyleBoxFlat_ue5e3")
|
Button/styles/pressed = SubResource("StyleBoxFlat_ue5e3")
|
||||||
|
Panel/styles/panel = SubResource("StyleBoxFlat_s6eqm")
|
||||||
|
PanelContainer/styles/panel = SubResource("StyleBoxFlat_s6eqm")
|
||||||
|
ProgressBar/colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
ProgressBar/constants/outline_size = 2
|
||||||
|
ProgressBar/styles/background = SubResource("StyleBoxFlat_cv53u")
|
||||||
|
ProgressBar/styles/fill = SubResource("StyleBoxFlat_twtfq")
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ var firing = true
|
||||||
|
|
||||||
var axis = 0
|
var axis = 0
|
||||||
var movement_axis = -1
|
var movement_axis = -1
|
||||||
|
var evade_direction = 1
|
||||||
|
|
||||||
|
var stress = 0
|
||||||
|
|
||||||
var AI_MODE_ATTACK = 1
|
var AI_MODE_ATTACK = 1
|
||||||
|
|
||||||
|
|
@ -135,12 +138,8 @@ func _process(delta: float) -> void:
|
||||||
if ai_mode == AI_MODE_ATTACK:
|
if ai_mode == AI_MODE_ATTACK:
|
||||||
firing = false
|
firing = false
|
||||||
|
|
||||||
if !front_cast and (player_distance > 480):
|
if !front_cast and (player_distance > 720):
|
||||||
boost_pressed = true
|
boost_pressed = true
|
||||||
elif $FireCast.get_collider() == player:
|
|
||||||
if player_distance > 480: boost_pressed = true
|
|
||||||
|
|
||||||
firing = true
|
|
||||||
else:
|
else:
|
||||||
boost_pressed = false
|
boost_pressed = false
|
||||||
|
|
||||||
|
|
@ -160,6 +159,17 @@ func _process(delta: float) -> void:
|
||||||
if (player.linear_velocity.length() > 256) or (player_distance > 320):
|
if (player.linear_velocity.length() > 256) or (player_distance > 320):
|
||||||
ai_state = AI_STATE_TRACK_ENEMY
|
ai_state = AI_STATE_TRACK_ENEMY
|
||||||
|
|
||||||
|
var direction = (player.position - position).normalized()
|
||||||
|
|
||||||
|
# Optionally, you can get the angle if needed
|
||||||
|
var angle = direction.angle() + deg_to_rad(90)
|
||||||
|
|
||||||
|
var angular_target = wrapf(angle - rotation, -PI, PI)
|
||||||
|
|
||||||
|
if abs(rad_to_deg(rotation - angular_target)) < 15:
|
||||||
|
if player_distance > 480: boost_pressed = true
|
||||||
|
|
||||||
|
firing = true
|
||||||
if front_cast:
|
if front_cast:
|
||||||
var front_cast_distance = ($SightCast.get_collision_point() - position).length()
|
var front_cast_distance = ($SightCast.get_collision_point() - position).length()
|
||||||
|
|
||||||
|
|
@ -211,6 +221,8 @@ 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:
|
func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||||
|
if not "linear_velocity" in body: return
|
||||||
|
|
||||||
if body.linear_velocity.length() + linear_velocity.length() > 256:
|
if body.linear_velocity.length() + linear_velocity.length() > 256:
|
||||||
$Collision.play()
|
$Collision.play()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,19 @@ var time_since_last_atmospheric_track = 999
|
||||||
var current_atmospheric_track = null
|
var current_atmospheric_track = null
|
||||||
|
|
||||||
var asteroid_scene = preload("res://scenes/asteroid.tscn")
|
var asteroid_scene = preload("res://scenes/asteroid.tscn")
|
||||||
|
var enemy_scene = preload("res://scenes/enemy.tscn")
|
||||||
|
|
||||||
func ship_heal(health: float = 1000) -> void:
|
func ship_health(health: float = 1000) -> void:
|
||||||
$Player.health = health
|
$Player.health = health
|
||||||
|
|
||||||
|
func summon_enemy() -> void:
|
||||||
|
var spawn_position = $Player.position + ($Player.transform.y * 1024)
|
||||||
|
|
||||||
|
var enemy = enemy_scene.instantiate()
|
||||||
|
enemy.position = spawn_position
|
||||||
|
|
||||||
|
add_child(enemy)
|
||||||
|
|
||||||
## Takes a world coordinate and converts it to a chunk coordinate.
|
## Takes a world coordinate and converts it to a chunk coordinate.
|
||||||
func world_to_chunk(position: Vector2) -> Vector2:
|
func world_to_chunk(position: Vector2) -> Vector2:
|
||||||
return Vector2(floori(position.x / 1024), floori(position.y / 1024))
|
return Vector2(floori(position.x / 1024), floori(position.y / 1024))
|
||||||
|
|
@ -42,7 +51,9 @@ func enter_physical(map):
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
LimboConsole
|
LimboConsole.register_command(ship_health, "ship_health", "Sets the ship's health.")
|
||||||
|
LimboConsole.register_command(summon_enemy, "summon_enemy", "Summons an enemy.")
|
||||||
|
|
||||||
if global.ground_location:
|
if global.ground_location:
|
||||||
$Player.global_position = get_node(global.ground_location + "/ExitPoint").global_position
|
$Player.global_position = get_node(global.ground_location + "/ExitPoint").global_position
|
||||||
$Player.rotation = get_node(global.ground_location + "/ExitPoint").rotation
|
$Player.rotation = get_node(global.ground_location + "/ExitPoint").rotation
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ func _process(delta: float) -> void:
|
||||||
if (time_since_last_fire <= 0) and Input.is_action_pressed("fire"):
|
if (time_since_last_fire <= 0) and Input.is_action_pressed("fire"):
|
||||||
time_since_last_fire = 0.25
|
time_since_last_fire = 0.25
|
||||||
|
|
||||||
|
$Fire.play()
|
||||||
|
|
||||||
var laser = laser_scene.instantiate()
|
var laser = laser_scene.instantiate()
|
||||||
|
|
||||||
laser.creator = self
|
laser.creator = self
|
||||||
|
|
@ -52,6 +54,20 @@ func _process(delta: float) -> void:
|
||||||
boosting = true
|
boosting = true
|
||||||
$Boost.play()
|
$Boost.play()
|
||||||
|
|
||||||
|
if boost < 100:
|
||||||
|
$BoostMeter.modulate = Color(1, 1, 1, 1)
|
||||||
|
else:
|
||||||
|
$BoostMeter.modulate.a -= delta * 2
|
||||||
|
$BoostMeter.value = boost
|
||||||
|
$BoostMeter/Label.text = str(floori(boost))
|
||||||
|
|
||||||
|
if health < 100:
|
||||||
|
$HealthMeter.modulate = Color(1, 1, 1, 1)
|
||||||
|
else:
|
||||||
|
$HealthMeter.modulate.a -= delta * 2
|
||||||
|
$HealthMeter.value = health / 10
|
||||||
|
$HealthMeter/Label.text = str(floori(health / 10))
|
||||||
|
|
||||||
if camera_shake_power > 0:
|
if camera_shake_power > 0:
|
||||||
camera_shake_power -= delta * 20
|
camera_shake_power -= delta * 20
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue