Multiplayer screen is no longer mad uggo. Just regular uggo

This commit is contained in:
Sage Vaillancourt 2018-05-26 15:34:41 -04:00
parent 4887754f6b
commit 7a383e432c
12 changed files with 377 additions and 119 deletions

43
Main.gd
View File

@ -12,10 +12,6 @@ var rectangle_opacity = 1
const BADDIE_WAIT_TIME_DEFAULT = 5
remote func move_player(id, position):
prints("MAIN SAYS:", id, position)
pass
func _ready():
var mainmenu = preload("res://MainMenu.tscn").instance()
add_child(mainmenu)
@ -70,34 +66,47 @@ var sendblob = 1
var bad_health_multi = 1
func BaddieTimer():
if total_bads_spawned <= a_round_of_bads:
var bad
var bad_type
var badposition = Vector2()
if sendblob%20 == 0:
bad = LaserBad.instance()
bad_type = 2
sendblob += 1
elif sendblob%5 == 0:
bad = BlobBad.instance()
bad_type = 1
sendblob += 1
else:
bad = FirstBad.instance()
bad_type = 0
sendblob += 1
add_child(bad)
bad.connect("dead", self, "_on_bad_death")
bad.health_multi = bad_health_multi
total_bads_spawned += 1
if $BaddieTimer.wait_time > 0.5:
$BaddieTimer.wait_time = $BaddieTimer.wait_time * 0.99
if total_bads_spawned == a_round_of_bads:
bad_health_multi *= 1.5
updatePoints()
bad.position.x = 1200
bad.position.y = (randi()%410) + 50
badposition.x = 1200
badposition.y = (randi()%410) + 50
if get_tree().is_network_server():
rpc("spawnBad", bad_type, badposition)
else:
spawnBad(bad_type, badposition)
else:
total_bads_spawned = 0
sync func spawnBad(bad_type, position): ### sync func ?
var bad
if bad_type == 0:
bad = FirstBad.instance()
if bad_type == 1:
bad = BlobBad.instance()
if bad_type == 2:
bad = LaserBad.instance()
add_child(bad)
bad.connect("dead", self, "_on_bad_death")
bad.health_multi = bad_health_multi
bad.position = position
func _on_PauseButton_pressed():
$Player.upgradeMenu()
@ -142,8 +151,8 @@ func _input(event):
touchy_shooty = true
func _on_Player_multiplayer_movement(id, position, is_shooting):
prints("Multiplayer movement for", id, "to", position)
$OtherPlayer.visible = true
$OtherPlayer.username = str(id)
$OtherPlayer.position = position
if is_shooting:
$OtherPlayer.shoot()

View File

@ -176,10 +176,10 @@ _sections_unfolded = [ "Transform", "Visibility" ]
[connection signal="multiplayer_movement" from="Player" to="." method="_on_Player_multiplayer_movement"]
[connection signal="restart_game" from="Player" to="Mothership" method="_on_Player_restart_game"]
[connection signal="restart_game" from="Player" to="." method="_on_Player_restart_game"]
[connection signal="restart_game" from="Player" to="Mothership" method="_on_Player_restart_game"]
[connection signal="shooting_speed_upgrade" from="Player" to="." method="_on_Player_shooting_speed_upgrade"]
[connection signal="update_display" from="Player" to="." method="_on_Player_update_display"]

View File

@ -1,6 +1,9 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=7 format=2]
[sub_resource type="BitmapFont" id=1]
[ext_resource path="res://art/multiplayer_menu/start_server.png" type="Texture" id=1]
[ext_resource path="res://art/multiplayer_menu/enter_username.png" type="Texture" id=2]
[sub_resource type="BitmapFont" id=5]
textures = [ ]
chars = PoolIntArray( )
@ -9,7 +12,7 @@ height = 1.0
ascent = 0.0
distance_field = false
[sub_resource type="BitmapFont" id=2]
[sub_resource type="BitmapFont" id=6]
textures = [ ]
chars = PoolIntArray( )
@ -18,6 +21,24 @@ height = 1.0
ascent = 0.0
distance_field = false
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ ExtResource( 1 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[node name="Node" type="Node"]
[node name="ColorRect" type="ColorRect" parent="." index="0"]
@ -210,8 +231,8 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_fonts/mono_font = SubResource( 1 )
custom_fonts/italics_font = SubResource( 2 )
custom_fonts/mono_font = SubResource( 5 )
custom_fonts/italics_font = SubResource( 6 )
bbcode_enabled = false
bbcode_text = "Enter a username"
visible_characters = -1
@ -250,4 +271,40 @@ text = "Back to Main Menu"
flat = false
align = 1
[node name="ServerIcon" type="AnimatedSprite" parent="." index="9"]
position = Vector2( 261.643, 353.76 )
scale = Vector2( 0.203772, 0.203773 )
frames = SubResource( 3 )
animation = "default"
[node name="UsernameIcon" type="AnimatedSprite" parent="." index="10"]
position = Vector2( 506.573, 154.684 )
scale = Vector2( 0.268352, 0.268352 )
frames = SubResource( 4 )
animation = "default"
[node name="ServerIP" type="Label" parent="." index="11"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 764.0
margin_top = 14.0
margin_right = 1012.0
margin_bottom = 79.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "192.168.0.1"
align = 2
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

View File

@ -1,15 +1,16 @@
extends Node
signal player_info
var my_ip
var peer
var player_info = {}
var my_info = { name = "", color = Color8(255, 0, 255) }
var my_info = { name = "", color = Color8(255, 255, 255) }
var server_ip
func _ready():
my_ip = IP.get_local_addresses()[1]
prints(my_ip)
$YourIP.text = str("Your IP address:", my_ip)
get_tree().connect("network_peer_connected", self, "_player_connected")
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
get_tree().connect("connected_to_server", self, "_connected_ok")
@ -25,8 +26,14 @@ func _on_Server_pressed():
prints(get_tree().is_network_server())
prints(get_tree().has_network_peer())
prints(my_info)
$ServerIP.visible = true
$ServerIP.text = str(my_ip)
$EnterIP.visible = false
$ServerEntry.visible = false
$ServerAcceptIcon.visible = false
func _on_Client_pressed():
server_ip = $ServerEntry.text
peer = NetworkedMultiplayerENet.new()
peer.create_client(server_ip, 6969)
get_tree().set_network_peer(peer)
@ -50,11 +57,7 @@ func _server_disconnected():
func _connected_fail():
pass # Could not even connect to server, abort
remote func move_player(id, position):
prints("NETWORKING SAYS:", id, position)
pass
remote func register_player(id, info):
player_info[id] = info
if get_tree().is_network_server():
@ -64,6 +67,7 @@ remote func register_player(id, info):
for peer_id in player_info:
rpc_id(id, "register_player", peer_id, player_info[peer_id])
prints(player_info[id], id)
emit_signal("player_info", player_info)
# Call function to update lobby UI here
@ -71,11 +75,11 @@ func _on_Name_pressed():
my_info = { name = $LineEdit.text, color = Color8(18, 255, 18) }
func _on_LineEdit_text_entered(new_text):
my_info = {name = new_text, color = my_info.color}
$UsernameLabel.text = str("Your netname is \"", new_text, "\"")
usernameEntered()
func _on_Server_Entry_text_entered(new_text):
server_ip = new_text
#server_ip = new_text
_on_Client_pressed()
func _on_BackToMain_pressed():
$Server.visible = false
@ -83,7 +87,35 @@ func _on_BackToMain_pressed():
$Name.visible = false
$UsernameEntry.visible = false
$ServerEntry.visible = false
$YourIP.visible = false
$UsernameLabel.visible = false
$BackToMain.visible = false
$ColorRect.visible = false
$UsernameAccept.visible = false
$UsernameAcceptIcon.visible = false
$BackIcon.visible = false
$EnterUsername.visible = false
$StartServer.visible = false
$ServerAcceptIcon.visible = false
$EnterIP.visible = false
func _on_UsernameEntry_text_changed(new_text):
my_info = {name = new_text, color = my_info.color}
func _on_UsernameAccept_pressed():
usernameEntered()
func usernameEntered():
my_info = {name = $UsernameEntry.text, color = my_info.color}
$UsernameLabel.text = str("Your netname is \"", $UsernameEntry.text, "\"")
if $UsernameEntry.text > "":
$UsernameEntry.visible = false
$UsernameAccept.visible = false
$UsernameAcceptIcon.visible = false
$EnterUsername.visible = false
prints(my_info)
$StartServer.visible = true
$EnterIP.visible = true
$ServerEntry.visible = true
$Server.visible = true
$ServerAcceptIcon.visible = true
$Client.visible = true

View File

@ -1,6 +1,11 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://Networking.gd" type="Script" id=1]
[ext_resource path="res://art/multiplayer_menu/start_server.png" type="Texture" id=2]
[ext_resource path="res://art/multiplayer_menu/enter_username.png" type="Texture" id=3]
[ext_resource path="res://art/multiplayer_menu/back.png" type="Texture" id=4]
[ext_resource path="res://art/multiplayer_menu/checkmark.png" type="Texture" id=5]
[ext_resource path="res://art/multiplayer_menu/enter_ip.png" type="Texture" id=6]
[sub_resource type="BitmapFont" id=1]
@ -20,7 +25,61 @@ height = 1.0
ascent = 0.0
distance_field = false
[node name="Networking" type="Node"]
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ ExtResource( 3 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=5]
animations = [ {
"frames": [ ExtResource( 4 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ ExtResource( 5 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=7]
animations = [ {
"frames": [ ExtResource( 6 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ ExtResource( 5 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[node name="Networking" type="Node" index="0"]
pause_mode = 2
script = ExtResource( 1 )
@ -45,16 +104,16 @@ size_flags_vertical = 1
color = Color( 0, 0, 0, 1 )
_sections_unfolded = [ "Visibility" ]
[node name="Server" type="Button" parent="." index="1"]
[node name="Client" type="Button" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 118.0
margin_top = 69.0
margin_right = 382.0
margin_bottom = 282.0
margin_left = 620.0
margin_top = 469.0
margin_right = 696.0
margin_bottom = 543.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
@ -66,37 +125,12 @@ toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Server"
flat = false
flat = true
align = 1
[node name="Client" type="Button" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 548.0
margin_top = 283.0
margin_right = 785.0
margin_bottom = 416.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Client"
flat = false
align = 1
[node name="Name" type="Button" parent="." index="3"]
[node name="Name" type="Button" parent="." index="2"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -120,16 +154,16 @@ text = "Name"
flat = false
align = 1
[node name="UsernameEntry" type="LineEdit" parent="." index="4"]
[node name="UsernameEntry" type="LineEdit" parent="." index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 518.0
margin_top = 464.0
margin_right = 721.0
margin_bottom = 490.0
margin_left = 377.0
margin_top = 390.0
margin_right = 610.0
margin_bottom = 416.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
@ -146,16 +180,17 @@ caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Placeholder" ]
[node name="ServerEntry" type="LineEdit" parent="." index="5"]
[node name="ServerEntry" type="LineEdit" parent="." index="4"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 518.0
margin_top = 502.0
margin_right = 721.0
margin_bottom = 528.0
margin_left = 407.0
margin_top = 496.0
margin_right = 610.0
margin_bottom = 522.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
@ -163,6 +198,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
text = "192.168."
focus_mode = 2
context_menu_enabled = true
placeholder_text = "Enter server IP"
@ -172,36 +208,9 @@ caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Placeholder" ]
[node name="YourIP" type="RichTextLabel" parent="." index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 588.0
margin_top = 161.0
margin_right = 839.0
margin_bottom = 181.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
bbcode_enabled = false
bbcode_text = ""
visible_characters = -1
percent_visible = 1.0
meta_underlined = true
tab_size = 4
text = "Your IP address: XXX.XXX.X.XXX"
scroll_active = true
scroll_following = false
selection_enabled = false
override_selected_font_color = false
[node name="UsernameLabel" type="RichTextLabel" parent="." index="7"]
[node name="UsernameLabel" type="RichTextLabel" parent="." index="5"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -231,16 +240,16 @@ selection_enabled = false
override_selected_font_color = false
_sections_unfolded = [ "BBCode", "custom_fonts" ]
[node name="BackToMain" type="Button" parent="." index="8"]
[node name="BackToMain" type="Button" parent="." index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 22.0
margin_top = 503.0
margin_right = 156.0
margin_bottom = 573.0
margin_left = 16.0
margin_top = 493.0
margin_right = 181.0
margin_bottom = 579.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
@ -252,20 +261,144 @@ toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Back to Main Menu"
flat = false
flat = true
align = 1
[connection signal="pressed" from="Server" to="." method="_on_Server_pressed"]
[node name="StartServer" type="AnimatedSprite" parent="." index="7"]
visible = false
position = Vector2( 510.253, 137.961 )
scale = Vector2( 0.203772, 0.203773 )
frames = SubResource( 3 )
animation = "default"
[node name="EnterUsername" type="AnimatedSprite" parent="." index="8"]
position = Vector2( 506.573, 202.684 )
scale = Vector2( 0.268352, 0.268352 )
frames = SubResource( 4 )
animation = "default"
[node name="ServerIP" type="Label" parent="." index="9"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 764.0
margin_top = 14.0
margin_right = 1012.0
margin_bottom = 79.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "192.168.0.1"
align = 2
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Visibility" ]
[node name="BackIcon" type="AnimatedSprite" parent="." index="10"]
position = Vector2( 114.639, 542.358 )
scale = Vector2( 0.626981, 0.626981 )
frames = SubResource( 5 )
animation = "default"
[node name="UsernameAcceptIcon" type="AnimatedSprite" parent="." index="11"]
position = Vector2( 682.745, 404.707 )
scale = Vector2( 0.4, 0.4 )
frames = SubResource( 6 )
animation = "default"
_sections_unfolded = [ "Transform" ]
[node name="UsernameAccept" type="Button" parent="." index="12"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 643.0
margin_top = 355.0
margin_right = 725.0
margin_bottom = 438.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
flat = true
align = 1
[node name="EnterIP" type="AnimatedSprite" parent="." index="13"]
visible = false
position = Vector2( 507.859, 382.258 )
scale = Vector2( 0.33039, 0.33039 )
frames = SubResource( 7 )
animation = "default"
[node name="Server" type="Button" parent="." index="14"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 314.0
margin_top = 26.0
margin_right = 707.0
margin_bottom = 232.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
flat = true
align = 1
_sections_unfolded = [ "Visibility" ]
[node name="ServerAcceptIcon" type="AnimatedSprite" parent="." index="15"]
visible = false
position = Vector2( 656.015, 512.574 )
scale = Vector2( 0.329, 0.329 )
frames = SubResource( 8 )
animation = "default"
_sections_unfolded = [ "Transform" ]
[connection signal="pressed" from="Client" to="." method="_on_Client_pressed"]
[connection signal="pressed" from="Name" to="." method="_on_Name_pressed"]
[connection signal="text_changed" from="UsernameEntry" to="." method="_on_UsernameEntry_text_changed"]
[connection signal="text_entered" from="UsernameEntry" to="." method="_on_LineEdit_text_entered"]
[connection signal="text_entered" from="ServerEntry" to="." method="_on_Server_Entry_text_entered"]
[connection signal="pressed" from="BackToMain" to="." method="_on_BackToMain_pressed"]
[connection signal="pressed" from="UsernameAccept" to="." method="_on_UsernameAccept_pressed"]
[connection signal="pressed" from="Server" to="." method="_on_Server_pressed"]

View File

@ -101,7 +101,10 @@ var y_up = false
var x_down = false
var y_down = false
var username = \"username\"
func _process(delta):
$Username.text = username
pass
func shoot():
@ -141,7 +144,7 @@ custom_solver_bias = 0.0
radius = 12.8998
height = 40.4125
[node name="OtherPlayer" type="Area2D"]
[node name="OtherPlayer" type="Area2D" index="0"]
input_pickable = true
gravity_point = true
@ -158,14 +161,38 @@ Laser = ExtResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
modulate = Color( 0.276855, 0.445152, 0.84375, 1 )
position = Vector2( 1.01175, 7.07602 )
scale = Vector2( 0.2, 0.2 )
frames = SubResource( 1 )
animation = "default"
_sections_unfolded = [ "Visibility" ]
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
position = Vector2( 45.5518, -3.09424 )
shape = SubResource( 2 )
[node name="Username" type="Label" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -87.0
margin_top = -55.0
margin_right = 87.0
margin_bottom = -41.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "username"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

View File

@ -20,7 +20,7 @@ custom_solver_bias = 0.0
radius = 12.8998
height = 40.4125
[node name="Player" type="Area2D" index="0"]
[node name="Player" type="Area2D"]
input_pickable = true
gravity_point = true

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB