parent
8d5714c215
commit
ffba3fce8c
@ -0,0 +1,13 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed = 300.0
|
||||
|
||||
func _physics_process(delta):
|
||||
var collision = move_and_collide(velocity * delta)
|
||||
if collision:
|
||||
if collision.get_position().x > position.x:
|
||||
velocity.x = -velocity.x
|
||||
else:
|
||||
velocity.y = -velocity.y
|
||||
collision_mask = 0
|
||||
$Trail.shrinking = true
|
@ -0,0 +1,49 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://bxyl3aa8j8qc5"]
|
||||
|
||||
[ext_resource type="Script" path="res://bullet.gd" id="1_eeg3n"]
|
||||
[ext_resource type="Script" path="res://trail.gd" id="2_uq0x2"]
|
||||
[ext_resource type="Texture2D" uid="uid://dbjqbgu6ru4m1" path="res://white.png" id="3_35obe"]
|
||||
[ext_resource type="Texture2D" uid="uid://bda38sojncx5q" path="res://light.png" id="4_jdr6g"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_1y8mw"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_qw0p6"]
|
||||
_data = [Vector2(0, 1), 0.0, -1.0, 0, 1, Vector2(1, 0), -1.0, 0.0, 1, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_s173t"]
|
||||
colors = PackedColorArray(0.967279, 0.105729, 0.103599, 1, 0.980392, 0.541176, 0.160784, 1)
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_uqkxw"]
|
||||
properties/0/path = NodePath("../..:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/sync = true
|
||||
properties/0/watch = false
|
||||
|
||||
[node name="Bullet" type="CharacterBody2D"]
|
||||
collision_layer = 4
|
||||
script = ExtResource("1_eeg3n")
|
||||
speed = 2000.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_1y8mw")
|
||||
|
||||
[node name="Trail" type="Line2D" parent="."]
|
||||
width_curve = SubResource("Curve_qw0p6")
|
||||
gradient = SubResource("Gradient_s173t")
|
||||
script = ExtResource("2_uq0x2")
|
||||
MAX_LENGTH = 3
|
||||
|
||||
[node name="PointLight2D" type="PointLight2D" parent="Trail"]
|
||||
scale = Vector2(0.1, 0.1)
|
||||
color = Color(0.996078, 0.807843, 0.682353, 1)
|
||||
energy = 2.5
|
||||
texture = ExtResource("4_jdr6g")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
texture = ExtResource("3_35obe")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
root_path = NodePath("../Trail/PointLight2D")
|
||||
replication_config = SubResource("SceneReplicationConfig_uqkxw")
|
@ -0,0 +1,20 @@
|
||||
extends Node2D
|
||||
|
||||
@export var bullet: PackedScene
|
||||
@export var spread = 10.0
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("fire"):
|
||||
fire.rpc()
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func fire():
|
||||
var authority = get_parent().get_node("MultiplayerSynchronizer").get_multiplayer_authority()
|
||||
if authority != get_multiplayer_authority():
|
||||
return;
|
||||
var new_bullet = bullet.instantiate()
|
||||
new_bullet.position = global_position
|
||||
new_bullet.velocity = Vector2.from_angle(rotation + deg_to_rad(randf_range(-spread / 2, spread / 2))) * new_bullet.speed;
|
||||
get_tree().root.add_child(new_bullet)
|
||||
get_parent().x_velocity_offset = -600 * cos(rotation)
|
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bda38sojncx5q"
|
||||
path="res://.godot/imported/light.png-06e94102f0cce323cff7daad56cf3030.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://light.png"
|
||||
dest_files=["res://.godot/imported/light.png-06e94102f0cce323cff7daad56cf3030.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
@ -0,0 +1,20 @@
|
||||
extends Line2D
|
||||
|
||||
var queue: Array
|
||||
@export var MAX_LENGTH: int
|
||||
var shrinking = false
|
||||
@export var OPACITY_SHRINK_RATE = 5
|
||||
@export var SIZE_SHRINK_RATE = 5
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
queue.push_front(global_position)
|
||||
if queue.size() > MAX_LENGTH:
|
||||
queue.pop_back()
|
||||
clear_points()
|
||||
for point in queue:
|
||||
add_point(point - global_position)
|
||||
if shrinking:
|
||||
modulate.a = lerpf(modulate.a, 0, OPACITY_SHRINK_RATE * delta)
|
||||
width = lerpf(width, 0, SIZE_SHRINK_RATE * delta)
|
||||
$PointLight2D.energy = lerpf($PointLight2D.energy, 0, OPACITY_SHRINK_RATE * delta)
|
Loading…
Reference in new issue