main
Elnu 7 months ago
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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@ -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

@ -1,8 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://r5n0cnh707fi"]
[gd_scene load_steps=7 format=3 uid="uid://r5n0cnh707fi"]
[ext_resource type="Script" path="res://scene_manager.gd" id="1_ywv22"]
[ext_resource type="PackedScene" uid="uid://b6olswaoek0bw" path="res://player.tscn" id="2_b15um"]
[ext_resource type="PackedScene" uid="uid://dmbiy6vupfawk" path="res://platform.tscn" id="3_njyoi"]
[ext_resource type="Texture2D" uid="uid://dbjqbgu6ru4m1" path="res://white.png" id="4_4433x"]
[sub_resource type="Environment" id="Environment_2bsl2"]
background_mode = 3
glow_enabled = true
glow_intensity = 0.7
glow_bloom = 1.0
[sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_loqya"]
[node name="Main" type="Node2D"]
script = ExtResource("1_ywv22")
@ -51,3 +60,14 @@ scale = Vector2(26.2654, 622.781)
[node name="CollisionShape2D9" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(1499, 155)
scale = Vector2(26.2654, 622.781)
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_2bsl2")
camera_attributes = SubResource("CameraAttributesPhysical_loqya")
[node name="White" type="Sprite2D" parent="."]
modulate = Color(0.0352941, 0.0352941, 0.0352941, 1)
z_index = -7
position = Vector2(508, 275.5)
scale = Vector2(38.125, 24.2812)
texture = ExtResource("4_4433x")

@ -72,7 +72,6 @@ func _on_host_pressed():
})
func _on_join_pressed():
peer = ENetMultiplayerPeer.new()
peer.create_client($LineEditIP.text if $LineEditIP.text else "127.0.0.1", port)

@ -1,10 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://dmbiy6vupfawk"]
[gd_scene load_steps=4 format=3 uid="uid://dmbiy6vupfawk"]
[ext_resource type="Texture2D" uid="uid://dbjqbgu6ru4m1" path="res://white.png" id="1_eu1eh"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6fi6a"]
size = Vector2(32, 32)
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_kdxkp"]
polygon = PackedVector2Array(16, 16, -16, 16, -16, -16, 16, -16)
[node name="CollisionShape2D" type="StaticBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -13,3 +16,6 @@ shape = SubResource("RectangleShape2D_6fi6a")
[node name="Sprite2D" type="Sprite2D" parent="."]
modulate = Color(0.105882, 0.105882, 0.105882, 1)
texture = ExtResource("1_eu1eh")
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
occluder = SubResource("OccluderPolygon2D_kdxkp")

@ -17,6 +17,8 @@ var last_grounded = 0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var gun: Node2D
func _ready():
$MultiplayerSynchronizer.set_multiplayer_authority(name.to_int())
var username = GameManager.players[name.to_int()].name
@ -25,6 +27,7 @@ func _ready():
for i in username.length():
username_hash += username.unicode_at(i)
$Sprite2D.modulate = Color.from_hsv((username_hash % 255) / 255.0, 0.5, 0.8)
gun = $Gun
func _physics_process(delta):
if $MultiplayerSynchronizer.get_multiplayer_authority() != multiplayer.get_unique_id():
@ -34,7 +37,9 @@ func _physics_process(delta):
if is_on_floor():
last_grounded = Time.get_ticks_msec()
else:
velocity.y += gravity * delta * (limp_gravity_modifier if Input.is_action_pressed("limp") else 1)
velocity.y += gravity * delta * (limp_gravity_modifier if Input.is_action_pressed("limp") else 1.0)
gun.look_at(get_global_mouse_position())
var grounded = Time.get_ticks_msec() - last_grounded < fox_time

@ -1,6 +1,9 @@
[gd_scene load_steps=6 format=3 uid="uid://b6olswaoek0bw"]
[gd_scene load_steps=9 format=3 uid="uid://b6olswaoek0bw"]
[ext_resource type="Script" path="res://player.gd" id="1_0p8o6"]
[ext_resource type="Script" path="res://gun.gd" id="2_847gu"]
[ext_resource type="PackedScene" uid="uid://bxyl3aa8j8qc5" path="res://bullet.tscn" id="3_ckwue"]
[ext_resource type="Texture2D" uid="uid://bda38sojncx5q" path="res://light.png" id="4_q0kom"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_2xv6m"]
load_path = "res://.godot/imported/white.png-d8533361663a5f8fe5200e5b5262a62d.ctex"
@ -16,6 +19,10 @@ properties/0/path = NodePath(".:position")
properties/0/spawn = true
properties/0/sync = true
properties/0/watch = false
properties/1/path = NodePath("Gun:rotation")
properties/1/spawn = true
properties/1/sync = true
properties/1/watch = false
[node name="Player" type="CharacterBody2D"]
collision_layer = 2
@ -26,9 +33,23 @@ fox_time = 100
limp_gravity_modifier = 3.0
[node name="Sprite2D" type="Sprite2D" parent="."]
light_mask = 0
scale = Vector2(1, 1.5)
texture = SubResource("CompressedTexture2D_2xv6m")
[node name="Gun" type="Node2D" parent="."]
z_index = 1
script = ExtResource("2_847gu")
bullet = ExtResource("3_ckwue")
[node name="Sprite2D" type="Sprite2D" parent="Gun"]
position = Vector2(19, 0)
scale = Vector2(0.78125, 0.17375)
texture = SubResource("CompressedTexture2D_2xv6m")
[node name="BulletSpawn" type="Node2D" parent="Gun"]
position = Vector2(31, 0)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_8wbiu")
@ -55,3 +76,7 @@ grow_vertical = 2
size_flags_horizontal = 4
text = "Player"
horizontal_alignment = 1
[node name="PointLight2D" type="PointLight2D" parent="."]
shadow_enabled = true
texture = ExtResource("4_q0kom")

@ -52,6 +52,11 @@ limp={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"echo":false,"script":null)
]
}
fire={
"deadzone": 0.5,
"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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
[physics]
@ -60,3 +65,4 @@ limp={
[rendering]
renderer/rendering_method.mobile="gl_compatibility"
environment/defaults/default_clear_color=Color(0, 0, 0, 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…
Cancel
Save