Преглед на файлове

Use array to store players

DricomDragon преди 5 години
родител
ревизия
ce3f60bfc2
променени са 1 файла, в които са добавени 5 реда и са изтрити 5 реда
  1. 5 5
      Game.gd

+ 5 - 5
Game.gd

@@ -1,18 +1,18 @@
 extends Node2D
 
 onready var cam = $Grid/Camera1
-onready var p1 = $Grid/Player1
-onready var p2 = $Grid/Player2
+var player = []
 var dist_max = 900
 var zoom_rate = 0.001
 
 func _ready():
-	pass
+	player.append($Grid/Player1)
+	player.append($Grid/Player2)
 
 func _process(d):
-	cam.position = 0.5 * (p1.position + p2.position)
+	cam.position = 0.5 * (player[0].position + player[1].position)
 
-	var dist = (p1.position).distance_to(p2.position)
+	var dist = (player[0].position).distance_to(player[1].position)
 
 	if dist < dist_max:
 		cam.zoom = Vector2(1.0, 1.0)