Kaynağa Gözat

Add action keys for 8 players

DricomDragon 4 yıl önce
ebeveyn
işleme
f0a265ef31
2 değiştirilmiş dosya ile 68 ekleme ve 2 silme
  1. 16 2
      Hub.gd
  2. 52 0
      project.godot

+ 16 - 2
Hub.gd

@@ -4,6 +4,11 @@ extends Node2D
 
 signal hub_finished
 
+const ACTION_PLAYER_PREFIX = "p"
+const ACTION_LEFT_SUFFIX = "_left"
+const ACTION_RIGHT_SUFFIX = "_right"
+const MAX_PLAYERS = 8
+
 export (Array, Color) var playerColors = [
 	Color.red,
 	Color.blue,
@@ -16,11 +21,13 @@ export (Array, Color) var playerColors = [
 ]
 
 var _playerScene = preload("res://Player.tscn")
-var _playerActionsLeft = ["p1_left", "p2_left", "p3_left"]
-var _playerActionsRight = ["p1_right", "p2_right", "p3_right"]
+var _playerActionsLeft
+var _playerActionsRight
 
 var _hub_enabled = true
 
+func _ready():
+	_fill_action_arrays()
 
 func _unhandled_input(event):
 	if event.is_pressed() and _hub_enabled:
@@ -46,3 +53,10 @@ func _unhandled_input(event):
 					add_child(player)
 
 					get_tree().set_input_as_handled()
+
+func _fill_action_arrays():
+	_playerActionsLeft = []
+	_playerActionsRight = []
+	for k in MAX_PLAYERS:
+		_playerActionsLeft.append(ACTION_PLAYER_PREFIX + str(k) + ACTION_LEFT_SUFFIX)
+		_playerActionsRight.append(ACTION_PLAYER_PREFIX + str(k) + ACTION_RIGHT_SUFFIX)

+ 52 - 0
project.godot

@@ -64,6 +64,58 @@ p3_right={
 "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":16777233,"unicode":0,"echo":false,"script":null)
  ]
 }
+p0_left={
+"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)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p0_right={
+"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)
+ ]
+}
+p4_left={
+"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":16777354,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p4_right={
+"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":16777356,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p5_left={
+"deadzone": 0.5,
+"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
+ ]
+}
+p5_right={
+"deadzone": 0.5,
+"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
+ ]
+}
+p6_left={
+"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":75,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p6_right={
+"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":59,"unicode":0,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":77,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p7_left={
+"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":86,"unicode":0,"echo":false,"script":null)
+ ]
+}
+p7_right={
+"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":78,"unicode":0,"echo":false,"script":null)
+ ]
+}
 
 [rendering]