Poprawka obrazen
This commit is contained in:
parent
3a5f46998a
commit
be5de281c0
13
scenes/game/damage_popup.tscn
Normal file
13
scenes/game/damage_popup.tscn
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[gd_scene load_steps=2 format=3]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/game/damage_popup.gd" id="1_script"]
|
||||||
|
|
||||||
|
[node name="DamagePopup" type="Label"]
|
||||||
|
offset_left = -48.0
|
||||||
|
offset_top = -18.0
|
||||||
|
offset_right = 48.0
|
||||||
|
offset_bottom = 18.0
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
mouse_filter = 2
|
||||||
|
script = ExtResource("1_script")
|
||||||
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=11 format=3]
|
[gd_scene load_steps=12 format=3]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/game/game.gd" id="1_game"]
|
[ext_resource type="Script" path="res://scripts/game/game.gd" id="1_game"]
|
||||||
[ext_resource type="Script" path="res://scripts/game/space_level_background.gd" id="2_background"]
|
[ext_resource type="Script" path="res://scripts/game/space_level_background.gd" id="2_background"]
|
||||||
@ -6,6 +6,7 @@
|
|||||||
[ext_resource type="Script" path="res://scripts/game/flight_hud.gd" id="4_hud"]
|
[ext_resource type="Script" path="res://scripts/game/flight_hud.gd" id="4_hud"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/ui/ship_equipment_panel.tscn" id="5_equipment"]
|
[ext_resource type="PackedScene" path="res://scenes/ui/ship_equipment_panel.tscn" id="5_equipment"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/ui/ship_inventory_panel.tscn" id="6_inventory"]
|
[ext_resource type="PackedScene" path="res://scenes/ui/ship_inventory_panel.tscn" id="6_inventory"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/game/weapon_test_target.tscn" id="7_target"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="TopWall"]
|
[sub_resource type="RectangleShape2D" id="TopWall"]
|
||||||
size = Vector2(5200, 40)
|
size = Vector2(5200, 40)
|
||||||
@ -48,6 +49,9 @@ shape = SubResource("RightWall")
|
|||||||
|
|
||||||
[node name="PlayerShip" parent="." instance=ExtResource("3_player")]
|
[node name="PlayerShip" parent="." instance=ExtResource("3_player")]
|
||||||
|
|
||||||
|
[node name="WeaponTestTarget" parent="." instance=ExtResource("7_target")]
|
||||||
|
position = Vector2(240, 0)
|
||||||
|
|
||||||
[node name="HUD" type="CanvasLayer" parent="."]
|
[node name="HUD" type="CanvasLayer" parent="."]
|
||||||
script = ExtResource("4_hud")
|
script = ExtResource("4_hud")
|
||||||
|
|
||||||
|
|||||||
31
scenes/game/weapon_test_target.tscn
Normal file
31
scenes/game/weapon_test_target.tscn
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[gd_scene load_steps=4 format=3]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/game/weapon_test_target.gd" id="1_script"]
|
||||||
|
[ext_resource type="Texture2D" path="res://assets/Ships/Spaceship_0.png" id="2_texture"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="TargetCollision"]
|
||||||
|
radius = 34.0
|
||||||
|
|
||||||
|
[node name="WeaponTestTarget" type="StaticBody2D"]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 0
|
||||||
|
script = ExtResource("1_script")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_texture")
|
||||||
|
scale = Vector2(0.25, 0.25)
|
||||||
|
texture_filter = 1
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("TargetCollision")
|
||||||
|
|
||||||
|
[node name="NameLabel" type="Label" parent="."]
|
||||||
|
offset_left = -90.0
|
||||||
|
offset_top = 42.0
|
||||||
|
offset_right = 90.0
|
||||||
|
offset_bottom = 66.0
|
||||||
|
theme_override_colors/font_color = Color(0.65, 0.9, 1, 1)
|
||||||
|
theme_override_font_sizes/font_size = 16
|
||||||
|
text = "CEL TESTOWY"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
mouse_filter = 2
|
||||||
15
scripts/game/damage_popup.gd
Normal file
15
scripts/game/damage_popup.gd
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
extends Label
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
z_index = 30
|
||||||
|
add_theme_color_override("font_color", Color(1.0, 0.78, 0.28, 1.0))
|
||||||
|
add_theme_color_override("font_shadow_color", Color(0.05, 0.08, 0.12, 0.95))
|
||||||
|
add_theme_constant_override("shadow_offset_x", 2)
|
||||||
|
add_theme_constant_override("shadow_offset_y", 2)
|
||||||
|
add_theme_font_size_override("font_size", 22)
|
||||||
|
var tween := create_tween()
|
||||||
|
tween.set_parallel(true)
|
||||||
|
tween.tween_property(self, "position:y", position.y - 48.0, 0.8).set_ease(Tween.EASE_OUT)
|
||||||
|
tween.tween_property(self, "modulate:a", 0.0, 0.8).set_ease(Tween.EASE_IN)
|
||||||
|
tween.set_parallel(false)
|
||||||
|
tween.tween_callback(queue_free)
|
||||||
1
scripts/game/damage_popup.gd.uid
Normal file
1
scripts/game/damage_popup.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://d2jviog5nrx6l
|
||||||
@ -30,7 +30,20 @@ func configure(
|
|||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var step := projectile_speed * delta
|
var step := projectile_speed * delta
|
||||||
global_position += direction * step
|
var previous_position := global_position
|
||||||
|
var next_position := previous_position + direction * step
|
||||||
|
var query := PhysicsRayQueryParameters2D.create(
|
||||||
|
previous_position,
|
||||||
|
next_position,
|
||||||
|
collision_mask,
|
||||||
|
[get_rid()]
|
||||||
|
)
|
||||||
|
var result := get_world_2d().direct_space_state.intersect_ray(query)
|
||||||
|
if not result.is_empty():
|
||||||
|
global_position = result["position"]
|
||||||
|
_hit_target(result.get("collider"))
|
||||||
|
return
|
||||||
|
global_position = next_position
|
||||||
_distance_travelled += step
|
_distance_travelled += step
|
||||||
if _distance_travelled >= max_range:
|
if _distance_travelled >= max_range:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|||||||
17
scripts/game/weapon_test_target.gd
Normal file
17
scripts/game/weapon_test_target.gd
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
extends StaticBody2D
|
||||||
|
|
||||||
|
const DAMAGE_POPUP_SCENE := preload("res://scenes/game/damage_popup.tscn")
|
||||||
|
|
||||||
|
var total_damage_received := 0.0
|
||||||
|
|
||||||
|
func take_damage(amount: float) -> void:
|
||||||
|
total_damage_received += amount
|
||||||
|
var popup := DAMAGE_POPUP_SCENE.instantiate() as Label
|
||||||
|
popup.text = "-%s DMG" % _format_damage(amount)
|
||||||
|
popup.global_position = global_position + Vector2(randf_range(-18.0, 18.0), -34.0)
|
||||||
|
get_parent().add_child(popup)
|
||||||
|
|
||||||
|
func _format_damage(amount: float) -> String:
|
||||||
|
if is_equal_approx(amount, roundf(amount)):
|
||||||
|
return str(int(roundf(amount)))
|
||||||
|
return "%.1f" % amount
|
||||||
1
scripts/game/weapon_test_target.gd.uid
Normal file
1
scripts/game/weapon_test_target.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://bdgposd5781st
|
||||||
Loading…
x
Reference in New Issue
Block a user