Skip to content

Commit 128ef00

Browse files
authored
Merge pull request #13 from endlessm/push-vqmnmrqnzslz
Improve multiplayer controls & documentation
2 parents a1d098c + 10d57ff commit 128ef00

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

doc/MODS.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,14 @@ functionality.
140140
Click on the `Player` node. In the inspector, try changing the Player
141141
dropdown to "Two" or "Both".
142142

143-
Duplicate the `Player` node. Move it next to the existing player. Then
144-
change the Player to "Two" in the duplicated one. Now the game is
145-
multiplayer.
146-
147-
You will notice that the camera is following one of the player characters. So
148-
try disabling the `Camera2D` node that's a child of the `Player` node. And then
149-
enable the `MultiplayerCamera` node that's at the bottom of the Scene Dock.
143+
Duplicate the `Player` node. In the scene, move the second node so that it
144+
doesn't overlap with the first player. Then, in the inspector, change the Player
145+
property on the second Player node to "Two". Now the game is multiplayer.
146+
147+
You will notice that the camera is following one of the player characters. So,
148+
in the inspector, try disabling the `Camera2D` node that is a child of each
149+
`Player` node, then enable the `MultiplayerCamera` node that's at the bottom of
150+
the Scene Dock.
150151

151152
### Player and flag appearance
152153

project.godot

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,35 @@ players=""
3434

3535
[input]
3636

37-
player_2_up={
37+
player_2_jump={
3838
"deadzone": 0.5,
3939
"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":87,"physical_keycode":0,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
40+
, 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":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
4041
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
41-
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":1,"axis_value":-1.0,"script":null)
42-
]
43-
}
44-
player_2_down={
45-
"deadzone": 0.5,
46-
"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":83,"physical_keycode":0,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
47-
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
48-
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":1,"axis_value":1.0,"script":null)
42+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
4943
]
5044
}
5145
player_2_left={
5246
"deadzone": 0.5,
5347
"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":65,"physical_keycode":0,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
48+
, 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":65,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
5449
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
5550
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":0,"axis_value":-1.0,"script":null)
5651
]
5752
}
5853
player_2_right={
5954
"deadzone": 0.5,
6055
"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":68,"physical_keycode":0,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
56+
, 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":68,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
6157
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
6258
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":2,"axis_value":1.0,"script":null)
6359
]
6460
}
65-
player_1_up={
61+
player_1_jump={
6662
"deadzone": 0.5,
6763
"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":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
6864
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
69-
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
70-
]
71-
}
72-
player_1_down={
73-
"deadzone": 0.5,
74-
"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":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
75-
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
76-
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
65+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
7766
]
7867
}
7968
player_1_left={

scripts/hud.gd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ func _ready():
2626

2727

2828
func _unhandled_input(event):
29-
if event is InputEventKey and %Start.is_visible_in_tree():
29+
if (
30+
(
31+
event is InputEventKey
32+
or event is InputEventJoypadButton
33+
or event is InputEventJoypadMotion
34+
)
35+
and %Start.is_visible_in_tree()
36+
):
3037
%Start.hide()
3138

3239

scripts/player.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extends CharacterBody2D
66
const _PLAYER_ACTIONS = {
77
Global.Player.ONE:
88
{
9-
"jump": "player_1_up",
9+
"jump": "player_1_jump",
1010
"left": "player_1_left",
1111
"right": "player_1_right",
1212
},
1313
Global.Player.TWO:
1414
{
15-
"jump": "player_2_up",
15+
"jump": "player_2_jump",
1616
"left": "player_2_left",
1717
"right": "player_2_right",
1818
},

0 commit comments

Comments
 (0)