Prechádzať zdrojové kódy

updated to godot 3.4.4

galo 1 rok pred
rodič
commit
167367d467
5 zmenil súbory, kde vykonal 21 pridanie a 32 odobranie
  1. 1 0
      .import/.gdignore
  2. 6 6
      Server.gd
  3. 6 8
      main.tscn
  4. 5 6
      project.godot
  5. 3 12
      spawner.gd

+ 1 - 0
.import/.gdignore

@@ -0,0 +1 @@
+

+ 6 - 6
Server.gd

@@ -23,13 +23,13 @@ func _process(_delta):
 
 var playerphsyics = preload('res://playerphysics.tscn')
 
-func conn(arg):
-	print('client connected, id: ' + str(arg))
+func conn(id):
+	print('client connected, id: ' + str(id))
 	yield(get_tree(),"physics_frame")
 	rpc_id(0,'ping')
 	print('clients connected: ' + str(custom_multiplayer.get_network_connected_peers().size()))
 	var instance = playerphsyics.instance()
-	instance.name = str(arg)
+	instance.name = str(id)
 	$players.add_child(instance)
 
 func makedummmy():
@@ -58,12 +58,12 @@ func _physics_process(delta):
 	var position_datachunk = {}
 	for i in $players.get_children():
 		position_datachunk[i.name] = i.global_position
-	rpc_id(0, 'player_position', position_datachunk)
+	rpc_unreliable_id(0, 'player_position', position_datachunk)
 	
 	var animation_datachunk = {}
 	for i in $players.get_children():
 		animation_datachunk[i.name] = i.animation
-	rpc_id(0, 'player_animation', animation_datachunk)
+	rpc_unreliable_id(0, 'player_animation', animation_datachunk)
 	
 	tick += 1
 	if fmod(tick,tickrate) == 0:
@@ -102,7 +102,7 @@ func level_up(lv, maxhp, gain, dmgup, id):
 	$players.get_node(str(id)).dmg += dmgup
 	rpc_id( 0,'atr_update', {id:{'maxhp':maxhp}})
 	
-	gen_power_queue(str(id))
+#	gen_power_queue(str(id))
 
 #powerup code
 

+ 6 - 8
main.tscn

@@ -71,6 +71,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin1"]
 modulate = Color( 0, 0.811765, 1, 1 )
 frames = SubResource( 5 )
+frame = 3
 playing = true
 offset = Vector2( 32, 32 )
 
@@ -82,6 +83,7 @@ render_target_v_flip = true
 
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin2"]
 frames = SubResource( 5 )
+frame = 1
 speed_scale = 0.8
 playing = true
 offset = Vector2( 32, 32 )
@@ -109,7 +111,6 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin4"]
 modulate = Color( 1, 0, 0.984314, 1 )
 frames = SubResource( 5 )
-frame = 3
 speed_scale = 0.9
 playing = true
 offset = Vector2( 32, 32 )
@@ -123,7 +124,8 @@ tickrate = 4
 
 [node name="enemies" type="Node" parent="Server"]
 script = ExtResource( 6 )
-limit = 10
+spawn_speed = 5
+limit = 128
 mod = 1.2
 hpgain = 1
 dmggain = 3
@@ -131,9 +133,7 @@ enemydmg = 1
 
 [node name="dmgbox" type="Node" parent="Server"]
 
-[node name="Client" type="Node" parent="." groups=[
-"client",
-]]
+[node name="Client" type="Node" parent="." groups=["client"]]
 script = ExtResource( 1 )
 
 [node name="ping" type="Label" parent="Client"]
@@ -170,9 +170,7 @@ __meta__ = {
 
 [node name="PowerMenu" parent="Client" instance=ExtResource( 12 )]
 
-[node name="Client2" type="Node" parent="." groups=[
-"client",
-]]
+[node name="Client2" type="Node" parent="." groups=["client"]]
 script = ExtResource( 1 )
 
 [node name="Input" type="Node" parent="Client2"]

+ 5 - 6
project.godot

@@ -10,7 +10,6 @@ config_version=4
 
 _global_script_classes=[  ]
 _global_script_class_icons={
-
 }
 
 [application]
@@ -33,27 +32,27 @@ window/stretch/aspect="keep"
 
 w={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 a={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 s={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 d={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 f3={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777246,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777246,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 

+ 3 - 12
spawner.gd

@@ -26,14 +26,7 @@ var areas = preload('res://Enemy2.tscn')
 func _ready():
 	
 	yield(get_tree().create_timer(1.0),"timeout")
-#	while true:
-#
-##		wave_num *= mod
-##		limit *= mod2
-##		wave_num = (wave_num)
-##		limit = (clamp(limit,0,maxlimit))
-#
-#		if dict.arraypos.size() < limit:
+	
 	for x in maxlimit:
 		var rot = rand_range(-PI,PI)
 		var pos = (Vector2(sin(rot), cos(rot)) * 400) + Vector2(320,180)
@@ -51,9 +44,6 @@ func _ready():
 		dict.arraydirtime.append(int(rand_range(60,120)))
 		dict.enabled.append(false)
 		dict.type.append(randi()%4)
-#
-#		print('there is a total of: ' + str(dict.arraypos.size()) +' enemmies')
-#		yield(get_tree().create_timer(spawn_speed),"timeout")
 	
 	var timer = Timer.new()
 	timer.wait_time = spawn_speed
@@ -106,7 +96,8 @@ func _physics_process(delta):
 
 #exclusive movmenet code
 				if fmod(tick, dict.arraydirtime[i]) == 0:
-					dict.arraymotion[i] = (dict.arraytarget[i].global_position - dict.arraypos[i]).normalized() * speed
+					if is_instance_valid(dict.arraytarget[i]):
+						dict.arraymotion[i] = (dict.arraytarget[i].global_position - dict.arraypos[i]).normalized() * speed
 				dict.arraypos[i] += dict.arraymotion[i]
 
 # enemy attak on players