MP sync working, redoing all menus now
This commit is contained in:
@@ -9,6 +9,7 @@ extends CharacterBody2D
|
|||||||
@export var attack_speed := 2000
|
@export var attack_speed := 2000
|
||||||
@export var throwback_strength := 2
|
@export var throwback_strength := 2
|
||||||
@onready var player_sprite = $Sprite2D
|
@onready var player_sprite = $Sprite2D
|
||||||
|
@onready var player_cam = $player_cam
|
||||||
@onready var player := get_node(".")
|
@onready var player := get_node(".")
|
||||||
#Animation
|
#Animation
|
||||||
@onready var anim_tree = $AnimationTree
|
@onready var anim_tree = $AnimationTree
|
||||||
@@ -44,9 +45,19 @@ signal value_changed
|
|||||||
signal health_changed
|
signal health_changed
|
||||||
signal player_killed
|
signal player_killed
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
set_multiplayer_authority(str(name).to_int())
|
||||||
|
|
||||||
|
@rpc("any_peer")
|
||||||
|
func set_spawn_location(spawn_position: Vector2):
|
||||||
|
print("RPC position update! from PEER ID: ", player.name, spawn_position)
|
||||||
|
set_position(spawn_position)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if not is_multiplayer_authority(): return
|
if not is_multiplayer_authority(): return
|
||||||
print("Setting IDLE")
|
print("Setting IDLE: ", get_position())
|
||||||
|
player_cam.make_current()
|
||||||
|
#player_cam.current = true # for mp to set the camera
|
||||||
#anim_mode.travel("idle")
|
#anim_mode.travel("idle")
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +118,9 @@ func attack_finished():
|
|||||||
is_attacking = false
|
is_attacking = false
|
||||||
|
|
||||||
func get_input():
|
func get_input():
|
||||||
|
if Input.is_action_just_pressed("reset_pos"):
|
||||||
|
print("REsetting player POS: ")
|
||||||
|
set_position(Vector2(-110, 561))
|
||||||
if Input.is_action_just_pressed("print_pos"):
|
if Input.is_action_just_pressed("print_pos"):
|
||||||
print("PLAYER POSITION!: ", player.get_position())
|
print("PLAYER POSITION!: ", player.get_position())
|
||||||
if Input.is_action_just_pressed("show_inventory"):
|
if Input.is_action_just_pressed("show_inventory"):
|
||||||
@@ -171,7 +185,9 @@ func get_input():
|
|||||||
else:
|
else:
|
||||||
anim_tree.set("parameters/walkIdleBlend/blend_amount", 0)
|
anim_tree.set("parameters/walkIdleBlend/blend_amount", 0)
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
if not is_multiplayer_authority(): return
|
||||||
# if not is_multiplayer_authority():
|
# if not is_multiplayer_authority():
|
||||||
# get_input()
|
# get_input()
|
||||||
# move_and_slide()
|
# move_and_slide()
|
||||||
@@ -185,7 +201,11 @@ func _physics_process(delta):
|
|||||||
var collider = collision.get_collider()
|
var collider = collision.get_collider()
|
||||||
if collider.is_in_group("moveable"):
|
if collider.is_in_group("moveable"):
|
||||||
var normal = collision.get_normal()
|
var normal = collision.get_normal()
|
||||||
collider.apply_central_impulse(-collision.get_normal() * push_power)
|
collider.apply_central_force(-collision.get_normal() * push_power)
|
||||||
|
#collider.applied_force = -collision.get_normal() * push_power
|
||||||
|
#collider.move_object.rpc()
|
||||||
|
|
||||||
|
#collider.apply_central_impulse()
|
||||||
# push back the player when player pushed
|
# push back the player when player pushed
|
||||||
#player_hit.is_player_hit = true
|
#player_hit.is_player_hit = true
|
||||||
#player_hit.hit_velocity = push_power * .1
|
#player_hit.hit_velocity = push_power * .1
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
[gd_scene load_steps=20 format=3 uid="uid://c1gncjamuavvs"]
|
[gd_scene load_steps=22 format=3 uid="uid://c1gncjamuavvs"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Characters/test_player/test_player.gd" id="1_6aci1"]
|
[ext_resource type="Script" path="res://Characters/test_player/test_player.gd" id="1_6aci1"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cs5o8bykug82q" path="res://Characters/test_player/WARRIOR SKELETON SS 2.png" id="1_8pmbp"]
|
[ext_resource type="Texture2D" uid="uid://cs5o8bykug82q" path="res://Characters/test_player/WARRIOR SKELETON SS 2.png" id="1_8pmbp"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://0ou4asf4vsc1" path="res://UI/Inventory/Inventory.tscn" id="3_fol83"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a08cb"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3qub5"]
|
||||||
size = Vector2(22, 20)
|
size = Vector2(22, 20)
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_1103t"]
|
[sub_resource type="Animation" id="Animation_v17mb"]
|
||||||
resource_name = "attack"
|
resource_name = "attack"
|
||||||
length = 0.65
|
length = 0.65
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
@@ -22,7 +23,7 @@ tracks/0/keys = {
|
|||||||
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
|
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_vnyb5"]
|
[sub_resource type="Animation" id="Animation_dhyjd"]
|
||||||
resource_name = "damage"
|
resource_name = "damage"
|
||||||
step = 0.01
|
step = 0.01
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
@@ -38,7 +39,7 @@ tracks/0/keys = {
|
|||||||
"values": [Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1)]
|
"values": [Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_gq32v"]
|
[sub_resource type="Animation" id="Animation_jals6"]
|
||||||
resource_name = "die"
|
resource_name = "die"
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
@@ -53,7 +54,7 @@ tracks/0/keys = {
|
|||||||
"values": [Vector2i(0, 4), Vector2i(1, 4), Vector2i(2, 4), Vector2i(3, 4), Vector2i(4, 4)]
|
"values": [Vector2i(0, 4), Vector2i(1, 4), Vector2i(2, 4), Vector2i(3, 4), Vector2i(4, 4)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_r2lqp"]
|
[sub_resource type="Animation" id="Animation_mhxr4"]
|
||||||
resource_name = "idle"
|
resource_name = "idle"
|
||||||
length = 2.0
|
length = 2.0
|
||||||
loop_mode = 1
|
loop_mode = 1
|
||||||
@@ -70,7 +71,7 @@ tracks/0/keys = {
|
|||||||
"values": [Vector2i(0, 0), Vector2i(1, 0), Vector2i(2, 0), Vector2i(3, 0), Vector2i(4, 0)]
|
"values": [Vector2i(0, 0), Vector2i(1, 0), Vector2i(2, 0), Vector2i(3, 0), Vector2i(4, 0)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_psmw8"]
|
[sub_resource type="Animation" id="Animation_5kwsw"]
|
||||||
resource_name = "walk"
|
resource_name = "walk"
|
||||||
loop_mode = 1
|
loop_mode = 1
|
||||||
step = 0.01
|
step = 0.01
|
||||||
@@ -87,81 +88,97 @@ tracks/0/keys = {
|
|||||||
"values": [Vector2i(0, 1), Vector2i(1, 1), Vector2i(2, 1), Vector2i(3, 1), Vector2i(4, 1), Vector2i(5, 1)]
|
"values": [Vector2i(0, 1), Vector2i(1, 1), Vector2i(2, 1), Vector2i(3, 1), Vector2i(4, 1), Vector2i(5, 1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rx5pu"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_mfcw3"]
|
||||||
_data = {
|
_data = {
|
||||||
"attack": SubResource("Animation_1103t"),
|
"attack": SubResource("Animation_v17mb"),
|
||||||
"damage": SubResource("Animation_vnyb5"),
|
"damage": SubResource("Animation_dhyjd"),
|
||||||
"die": SubResource("Animation_gq32v"),
|
"die": SubResource("Animation_jals6"),
|
||||||
"idle": SubResource("Animation_r2lqp"),
|
"idle": SubResource("Animation_mhxr4"),
|
||||||
"walk": SubResource("Animation_psmw8")
|
"walk": SubResource("Animation_5kwsw")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_7kx25"]
|
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_lqar1"]
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_gm2dr"]
|
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_vr7py"]
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_cl8pn"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_d7310"]
|
||||||
animation = &"attack"
|
animation = &"attack"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_tyu0k"]
|
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_83svy"]
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f5cnp"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ixc0x"]
|
||||||
animation = &"damage"
|
animation = &"damage"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4qn65"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_wmn47"]
|
||||||
animation = &"die"
|
animation = &"die"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_kqkvd"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_poall"]
|
||||||
animation = &"idle"
|
animation = &"idle"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_66hu3"]
|
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_cxexk"]
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jxg51"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6a4lj"]
|
||||||
animation = &"walk"
|
animation = &"walk"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_6ake6"]
|
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_4pmjh"]
|
||||||
graph_offset = Vector2(-1059.2, -82.3198)
|
graph_offset = Vector2(-769.911, -161.25)
|
||||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_7kx25")
|
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_lqar1")
|
||||||
nodes/AttackOneShot/position = Vector2(-320, 60)
|
nodes/AttackOneShot/position = Vector2(-320, 60)
|
||||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_gm2dr")
|
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_vr7py")
|
||||||
nodes/DieOneShot/position = Vector2(-120, 180)
|
nodes/DieOneShot/position = Vector2(-120, 180)
|
||||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_cl8pn")
|
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_d7310")
|
||||||
nodes/attack_anim/position = Vector2(-560, 200)
|
nodes/attack_anim/position = Vector2(-560, 200)
|
||||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_tyu0k")
|
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_83svy")
|
||||||
nodes/damageOneShot/position = Vector2(100, 320)
|
nodes/damageOneShot/position = Vector2(100, 320)
|
||||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_f5cnp")
|
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_ixc0x")
|
||||||
nodes/damage_anim/position = Vector2(-200, 460)
|
nodes/damage_anim/position = Vector2(-200, 460)
|
||||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_4qn65")
|
nodes/die_anim/node = SubResource("AnimationNodeAnimation_wmn47")
|
||||||
nodes/die_anim/position = Vector2(-440, 340)
|
nodes/die_anim/position = Vector2(-440, 340)
|
||||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_kqkvd")
|
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_poall")
|
||||||
nodes/idle_anim/position = Vector2(-940, 60)
|
nodes/idle_anim/position = Vector2(-940, 60)
|
||||||
nodes/output/position = Vector2(400, 340)
|
nodes/output/position = Vector2(400, 340)
|
||||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_66hu3")
|
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_cxexk")
|
||||||
nodes/walkIdleBlend/position = Vector2(-660, -40)
|
nodes/walkIdleBlend/position = Vector2(-660, -40)
|
||||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_jxg51")
|
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_6a4lj")
|
||||||
nodes/walk_anim/position = Vector2(-920, -80)
|
nodes/walk_anim/position = Vector2(-920, -80)
|
||||||
node_connections = [&"output", 0, &"damageOneShot", &"AttackOneShot", 0, &"walkIdleBlend", &"AttackOneShot", 1, &"attack_anim", &"DieOneShot", 0, &"AttackOneShot", &"DieOneShot", 1, &"die_anim", &"damageOneShot", 0, &"DieOneShot", &"damageOneShot", 1, &"damage_anim", &"walkIdleBlend", 0, &"walk_anim", &"walkIdleBlend", 1, &"idle_anim"]
|
node_connections = [&"output", 0, &"damageOneShot", &"AttackOneShot", 0, &"walkIdleBlend", &"AttackOneShot", 1, &"attack_anim", &"DieOneShot", 0, &"AttackOneShot", &"DieOneShot", 1, &"die_anim", &"damageOneShot", 0, &"DieOneShot", &"damageOneShot", 1, &"damage_anim", &"walkIdleBlend", 0, &"walk_anim", &"walkIdleBlend", 1, &"idle_anim"]
|
||||||
|
|
||||||
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_n4dy6"]
|
||||||
|
properties/0/path = NodePath(".:position")
|
||||||
|
properties/0/spawn = true
|
||||||
|
properties/0/sync = true
|
||||||
|
properties/1/path = NodePath(".:rotation")
|
||||||
|
properties/1/spawn = true
|
||||||
|
properties/1/sync = true
|
||||||
|
properties/2/path = NodePath("Sprite2D:frame")
|
||||||
|
properties/2/spawn = true
|
||||||
|
properties/2/sync = true
|
||||||
|
properties/3/path = NodePath("Sprite2D:flip_h")
|
||||||
|
properties/3/spawn = true
|
||||||
|
properties/3/sync = true
|
||||||
|
|
||||||
[node name="test_player" type="CharacterBody2D" groups=["player"]]
|
[node name="test_player" type="CharacterBody2D" groups=["player"]]
|
||||||
|
motion_mode = 1
|
||||||
script = ExtResource("1_6aci1")
|
script = ExtResource("1_6aci1")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(1, 2)
|
position = Vector2(1, 2)
|
||||||
shape = SubResource("RectangleShape2D_a08cb")
|
shape = SubResource("RectangleShape2D_3qub5")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
texture = ExtResource("1_8pmbp")
|
texture = ExtResource("1_8pmbp")
|
||||||
hframes = 6
|
hframes = 6
|
||||||
vframes = 6
|
vframes = 6
|
||||||
|
frame = 4
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
libraries = {
|
libraries = {
|
||||||
"": SubResource("AnimationLibrary_rx5pu")
|
"": SubResource("AnimationLibrary_mfcw3")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="AnimationTree" type="AnimationTree" parent="."]
|
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||||
tree_root = SubResource("AnimationNodeBlendTree_6ake6")
|
tree_root = SubResource("AnimationNodeBlendTree_4pmjh")
|
||||||
anim_player = NodePath("../AnimationPlayer")
|
anim_player = NodePath("../AnimationPlayer")
|
||||||
active = true
|
active = true
|
||||||
parameters/AttackOneShot/active = false
|
parameters/AttackOneShot/active = false
|
||||||
@@ -174,6 +191,13 @@ parameters/walkIdleBlend/blend_amount = 1.0
|
|||||||
|
|
||||||
[node name="player_cam" type="Camera2D" parent="."]
|
[node name="player_cam" type="Camera2D" parent="."]
|
||||||
modulate = Color(0, 0, 0, 1)
|
modulate = Color(0, 0, 0, 1)
|
||||||
current = true
|
|
||||||
|
|
||||||
[node name="InvulnerableTimer" type="Timer" parent="."]
|
[node name="InvulnerableTimer" type="Timer" parent="."]
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="Inventory" parent="CanvasLayer" instance=ExtResource("3_fol83")]
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
|
replication_config = SubResource("SceneReplicationConfig_n4dy6")
|
||||||
|
@@ -1,22 +1,81 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@onready var manager = get_node(".")
|
@onready var manager = get_node(".")
|
||||||
|
@onready var main_menu = $CanvasLayer/MainMenu
|
||||||
|
@onready var start_game_menu = $CanvasLayer/StartGameMenu
|
||||||
|
@onready var address_entry = $CanvasLayer/MainMenu/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/AddressEntry
|
||||||
|
@onready var notifications = $CanvasLayer/notifications
|
||||||
|
@onready var spawner = $MultiplayerSpawner
|
||||||
|
|
||||||
|
|
||||||
|
var PORT = 9999
|
||||||
|
var enet_peer = ENetMultiplayerPeer.new()
|
||||||
|
|
||||||
const Level1 = preload("res://Levels/Level1/Level1.tscn")
|
const Level1 = preload("res://Levels/Level1/Level1.tscn")
|
||||||
const Player = preload("res://Characters/test_player/test_player.tscn")
|
const Player = preload("res://Characters/test_player/test_player.tscn")
|
||||||
|
var spawn_location: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
#get_tree().paused = true
|
||||||
var level_1 = Level1.instantiate()
|
var level_1 = Level1.instantiate()
|
||||||
var spawn_location = level_1.get_node("PlayerSpawnLocation")
|
var spawn_location_in_level = level_1.get_node("PlayerSpawnLocation")
|
||||||
spawn_location.set_visible(false)
|
spawn_location = spawn_location_in_level.get_position()
|
||||||
manager.add_child(level_1)
|
spawn_location_in_level.set_visible(false)
|
||||||
var new_player = Player.instantiate()
|
add_child(level_1)
|
||||||
manager.add_child(new_player)
|
|
||||||
new_player.set_position(spawn_location.get_position())
|
|
||||||
|
|
||||||
|
|
||||||
|
func add_player(peer_id):
|
||||||
|
var player = Player.instantiate()
|
||||||
|
player.name = str(peer_id)
|
||||||
|
add_child(player) # Adds to current scene under root node
|
||||||
|
if peer_id == 1:
|
||||||
|
player.set_position(spawn_location)
|
||||||
|
else:
|
||||||
|
spawn_location = spawn_location + Vector2(50, 0)
|
||||||
|
player.set_spawn_location.rpc(spawn_location)
|
||||||
|
print("SPAWN LOCATION: ", spawn_location, " PEER ID: ", player.name)
|
||||||
|
# show_notification.rpc("Test Message")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("call_local")
|
||||||
|
func show_notification(my_message: String):
|
||||||
|
notifications.show_new_notification(my_message)
|
||||||
|
|
||||||
|
func _on_host_button_pressed(): # When hosting a new game
|
||||||
|
main_menu.hide()
|
||||||
|
start_game_menu.show()
|
||||||
|
enet_peer.create_server(PORT)
|
||||||
|
multiplayer.multiplayer_peer = enet_peer
|
||||||
|
multiplayer.peer_connected.connect(add_player)
|
||||||
|
|
||||||
|
add_player(multiplayer.get_unique_id())
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_join_button_pressed():
|
||||||
|
main_menu.hide()
|
||||||
|
enet_peer.create_client("localhost", PORT)
|
||||||
|
multiplayer.multiplayer_peer = enet_peer
|
||||||
|
|
||||||
|
|
||||||
|
func _on_start_game_button_pressed():
|
||||||
|
start_game_menu.hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_play_single_player_button_pressed():
|
||||||
|
var player = Player.instantiate()
|
||||||
|
player.name = str(1)
|
||||||
|
add_child(player)
|
||||||
|
player.set_position(spawn_location)
|
||||||
|
main_menu.hide()
|
||||||
|
notifications.hide()
|
||||||
|
@@ -2,5 +2,38 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" path="res://Game Manager/game_manager.gd" id="1_bkvdw"]
|
[ext_resource type="Script" path="res://Game Manager/game_manager.gd" id="1_bkvdw"]
|
||||||
|
|
||||||
[node name="game_manager" type="Node2D"]
|
[node name="game_manager" type="Node"]
|
||||||
script = ExtResource("1_bkvdw")
|
script = ExtResource("1_bkvdw")
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="StartGameMenu" type="Control" parent="CanvasLayer"]
|
||||||
|
process_mode = 3
|
||||||
|
visible = false
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/StartGameMenu"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/StartGameMenu/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="StartGameButton" type="Button" parent="CanvasLayer/StartGameMenu/PanelContainer/MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Start Game"
|
||||||
|
|
||||||
|
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||||
|
_spawnable_scenes = PackedStringArray("res://Characters/test_player/test_player.tscn", "res://PhysicsObjects/HandStatue/HandStatue.tscn")
|
||||||
|
spawn_path = NodePath("..")
|
||||||
|
|
||||||
|
[connection signal="pressed" from="CanvasLayer/StartGameMenu/PanelContainer/MarginContainer/StartGameButton" to="." method="_on_start_game_button_pressed"]
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,27 +1,34 @@
|
|||||||
extends RigidBody2D
|
extends RigidBody2D
|
||||||
|
|
||||||
@onready var rigid_body = get_node(".")
|
@export var initial_impulse:Vector2 = Vector2(0,0)
|
||||||
|
@export var damage_speed:int = 50
|
||||||
|
@export var max_speed:int = 150
|
||||||
|
@export var push_strength:int = 20
|
||||||
|
|
||||||
@onready var last_velocity:Vector2 = Vector2(0,0)
|
@onready var last_velocity:Vector2 = Vector2(0,0)
|
||||||
@onready var current_player:CharacterBody2D = null
|
@onready var current_player:CharacterBody2D = null
|
||||||
|
|
||||||
@export var initial_impulse:Vector2 = Vector2(0,0)
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
print("Statue Ready!")
|
|
||||||
if initial_impulse != Vector2.ZERO:
|
|
||||||
rigid_body.apply_central_impulse(initial_impulse)
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
last_velocity = get_linear_velocity()
|
||||||
|
if last_velocity.length() > damage_speed:
|
||||||
|
set_modulate(Color("8e2325"))
|
||||||
|
else:
|
||||||
|
set_modulate(Color("ffffff"))
|
||||||
|
if last_velocity.length() > max_speed:
|
||||||
|
set_linear_velocity(get_linear_velocity().normalized() * max_speed)
|
||||||
|
last_velocity.length()
|
||||||
|
|
||||||
|
|
||||||
func _on_body_entered(body):
|
func _on_body_entered(body):
|
||||||
print("body entered! ")
|
|
||||||
if body.is_in_group("player"):
|
if body.is_in_group("player"):
|
||||||
print("Player collided!")
|
if last_velocity.length() > damage_speed:
|
||||||
current_player = body
|
current_player = body
|
||||||
current_player.player_hit.is_player_hit = true
|
current_player.player_hit.is_player_hit = true
|
||||||
current_player.player_hit.hit_velocity = last_velocity
|
current_player.player_hit.hit_velocity = last_velocity.normalized() * push_strength
|
||||||
|
|
||||||
if last_velocity.x > 50 or last_velocity.y < -50 or last_velocity.x < -50 or last_velocity.y > 50:
|
|
||||||
current_player.health_changed_func(-1)
|
current_player.health_changed_func(-1)
|
||||||
rigid_body.set_sleeping(true)
|
# set_freeze_enabled(true)
|
||||||
|
# await get_tree().create_timer(0.5).timeout
|
||||||
|
set_sleeping(true)
|
||||||
|
# set_freeze_enabled(false)
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://ca4ghctk5gllj"]
|
[gd_scene load_steps=6 format=3 uid="uid://ca4ghctk5gllj"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="1_462gd"]
|
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="1_462gd"]
|
||||||
[ext_resource type="Script" path="res://PhysicsObjects/HandStatue/HandStatue.gd" id="1_ap0lt"]
|
[ext_resource type="Script" path="res://PhysicsObjects/HandStatue/HandStatue.gd" id="1_ap0lt"]
|
||||||
@@ -12,12 +12,21 @@ bounce = 0.76
|
|||||||
radius = 9.0
|
radius = 9.0
|
||||||
height = 34.0
|
height = 34.0
|
||||||
|
|
||||||
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_14ixl"]
|
||||||
|
properties/0/path = NodePath(".:position")
|
||||||
|
properties/0/spawn = false
|
||||||
|
properties/0/sync = false
|
||||||
|
properties/1/path = NodePath(".:linear_velocity")
|
||||||
|
properties/1/spawn = false
|
||||||
|
properties/1/sync = true
|
||||||
|
|
||||||
[node name="HandStatue" type="RigidBody2D" groups=["moveable"]]
|
[node name="HandStatue" type="RigidBody2D" groups=["moveable"]]
|
||||||
physics_material_override = SubResource("PhysicsMaterial_ho34d")
|
physics_material_override = SubResource("PhysicsMaterial_ho34d")
|
||||||
|
max_contacts_reported = 3
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
|
can_sleep = false
|
||||||
lock_rotation = true
|
lock_rotation = true
|
||||||
script = ExtResource("1_ap0lt")
|
script = ExtResource("1_ap0lt")
|
||||||
initial_impulse = Vector2(200, 0)
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(0, -4)
|
position = Vector2(0, -4)
|
||||||
@@ -29,4 +38,7 @@ texture = ExtResource("1_462gd")
|
|||||||
region_enabled = true
|
region_enabled = true
|
||||||
region_rect = Rect2(48, 36, 16, 28)
|
region_rect = Rect2(48, 36, 16, 28)
|
||||||
|
|
||||||
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
|
replication_config = SubResource("SceneReplicationConfig_14ixl")
|
||||||
|
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
18
PhysicsObjects/HandStatue/MultiplayerSynchronizer.gd
Normal file
18
PhysicsObjects/HandStatue/MultiplayerSynchronizer.gd
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
extends MultiplayerSynchronizer
|
||||||
|
|
||||||
|
|
||||||
|
#func _enter_tree():
|
||||||
|
# set_multiplayer_authority(1)
|
||||||
|
#
|
||||||
|
## Called when the node enters the scene tree for the first time.
|
||||||
|
#func _ready():
|
||||||
|
# if not is_multiplayer_authority(): return
|
||||||
|
#
|
||||||
|
#
|
||||||
|
## Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# if not is_multiplayer_authority(): return
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#func _physics_process(delta):
|
||||||
|
# if not is_multiplayer_authority(): return
|
BIN
PickupableObjects/Bomb/bomb_anim.png
Normal file
BIN
PickupableObjects/Bomb/bomb_anim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 841 B |
34
PickupableObjects/Bomb/bomb_anim.png.import
Normal file
34
PickupableObjects/Bomb/bomb_anim.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dwqq3s0su5myy"
|
||||||
|
path="res://.godot/imported/bomb_anim.png-1c92dadf237f59ac8452a68f910adeb7.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://PickupableObjects/Bomb/bomb_anim.png"
|
||||||
|
dest_files=["res://.godot/imported/bomb_anim.png-1c92dadf237f59ac8452a68f910adeb7.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
|
BIN
PickupableObjects/Bomb/bomb_icon.png
Normal file
BIN
PickupableObjects/Bomb/bomb_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 221 B |
34
PickupableObjects/Bomb/bomb_icon.png.import
Normal file
34
PickupableObjects/Bomb/bomb_icon.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dmqfqmr16bdqk"
|
||||||
|
path="res://.godot/imported/bomb_icon.png-7e2eda12156138a4003e63cacc06b10a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://PickupableObjects/Bomb/bomb_icon.png"
|
||||||
|
dest_files=["res://.godot/imported/bomb_icon.png-7e2eda12156138a4003e63cacc06b10a.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
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.6 KiB |
@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/Stuff.png-96e376a9d98d7c764e870eeeeddfebc9.ct
|
|||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
mipmaps/generate=false
|
mipmaps/generate=false
|
||||||
|
9
UI/MainMenu/MainMenu.tscn
Normal file
9
UI/MainMenu/MainMenu.tscn
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bk6yvc16x1n2k"]
|
||||||
|
|
||||||
|
[node name="MainMenu" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
@@ -17,10 +17,16 @@ config/icon="res://icon.svg"
|
|||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
window/stretch/mode="viewport"
|
||||||
window/stretch/scale=2.0
|
window/stretch/scale=2.0
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
reset_pos={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [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":4194439,"key_label":0,"unicode":49,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
print_pos={
|
print_pos={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
@@ -61,6 +67,11 @@ show_inventory={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
test_force={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [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":4194441,"key_label":0,"unicode":51,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
@@ -68,5 +79,4 @@ show_inventory={
|
|||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
renderer/rendering_method="gl_compatibility"
|
|
||||||
textures/canvas_textures/default_texture_filter=0
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
Reference in New Issue
Block a user