Skip to content

Commit

Permalink
Merge pull request #8 from opensuspect/main
Browse files Browse the repository at this point in the history
Syncing with main
  • Loading branch information
TheSecondReal0 authored Oct 19, 2020
2 parents d385682 + 3994905 commit d8372fa
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 37 deletions.
12 changes: 6 additions & 6 deletions src/assets/autoload/network.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ func ready() -> void:
# give the server access to puppet functions and variables
set_network_master(1)

func client_server(port: int, player_name: String) -> void:
func client_server(port: int, playerName: String) -> void:
print("Starting server on port ", port, " with host player name ", player_name)
connection = Connection.CLIENT_SERVER
self.player_name = player_name
print("Starting server on port ", port)
player_name = playerName
server = WebSocketServer.new()
server.listen(port, PoolStringArray(), true) #3rd input must be true to use Godot's high level networking API
get_tree().set_network_peer(server)
connect_signals()
get_tree().change_scene("res://assets/main/main.tscn")

func client(hostName: String, port: int, player_name: String) -> void:
func client(hostName: String, port: int, playerName: String) -> void:
print("Connecting to server ", hostName, " on port ", port, " with host player name ", player_name)
connection = Connection.CLIENT
self.player_name = player_name
print("Connecting to ", hostName, " on port ", port)
player_name = playerName
client = WebSocketClient.new()
#use "ws://" at the beginning of address for websocket connections
var url: String = "ws://" + hostName + ":" + str(port)
Expand Down
4 changes: 3 additions & 1 deletion src/assets/main/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var player_scene = load(player_s)
var players = {}
#!!!THIS IS IMPORTANT!!!
#INCREASE THIS VARIABLE BY ONE EVERY COMMIT TO PREVENT OLD CLIENTS FROM TRYING TO CONNECT TO SERVERS!!!
var version = 3
var version = 4
var intruders = 0
var errdc = false
onready var config = ConfigFile.new()
Expand Down Expand Up @@ -134,8 +134,10 @@ func _on_startgamebutton_gamestartpressed():
intruders = intruders + 1
rpc_id(other_id,"startgame",isintruder)
isintruder = false
$maps.switchMap("test")
emit_signal("clientstartgame")
get_tree().set_refuse_new_network_connections(true)

remote func startgame(areweanintruder):
if areweanintruder:
print("we are the intruder!")
Expand Down
9 changes: 5 additions & 4 deletions src/assets/main/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ margin_right = -247.972
margin_bottom = -13.1382

[node name="startgamebutton" type="Button" parent="players/Player/Camera2D/CanvasLayer"]
margin_left = 1.77539
margin_top = 571.249
margin_right = 95.7754
margin_bottom = 599.249
anchor_top = 1.0
anchor_bottom = 1.0
margin_top = -28.0
margin_right = 94.0
text = "Start Game"
script = ExtResource( 7 )
__meta__ = {
Expand All @@ -74,6 +74,7 @@ __meta__ = {
script = ExtResource( 2 )

[node name="test" parent="maps" instance=ExtResource( 6 )]
light_mask = 2
[connection signal="clientstartgame" from="." to="players/Player/Camera2D/CanvasLayer/Button" method="_on_Node2D_clientstartgame"]
[connection signal="pressed" from="players/Player/Camera2D/CanvasLayer/Button" to="players/Player/Camera2D/CanvasLayer/chatbox" method="popup"]
[connection signal="gamestartpressed" from="players/Player/Camera2D/CanvasLayer/startgamebutton" to="." method="_on_startgamebutton_gamestartpressed"]
Expand Down
14 changes: 10 additions & 4 deletions src/assets/main/maps.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
extends Node2D

var maps: Dictionary = {"test": preload("res://assets/maps/test/test.tscn")}
var maps: Dictionary = {"lobby": preload("res://assets/maps/lobby/lobby.tscn"), "test": preload("res://assets/maps/test/test.tscn")}

var currentMap: String = "test"
var currentMap: String = "lobby"

func _ready():
switchMap("test")
set_network_master(1)
switchMap(currentMap)

func switchMap(newMap: String):
puppet func switchMap(newMap: String):
#if the func is not remotely called rpc sender id will be 0, if server sent it will be 1, negative should be impossible
if not get_tree().get_rpc_sender_id() < 2:
return
if GameManager.ingame:
return
if not maps.keys().has(newMap):
return
if get_tree().is_network_server():
rpc("switchMap", newMap)
for i in get_children():
i.queue_free()
currentMap = newMap
Expand Down
11 changes: 11 additions & 0 deletions src/assets/maps/lobby/lobby.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_scene format=2]

[node name="lobby" type="Node2D"]

[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 22.0
text = "LOBBY"
__meta__ = {
"_edit_use_anchors_": false
}
14 changes: 11 additions & 3 deletions src/assets/maps/test/test.tscn
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]

[ext_resource path="res://assets/common/textures/icons/icon.png" type="Texture" id=1]

[sub_resource type="RectangleShape2D" id=1]
[sub_resource type="OccluderPolygon2D" id=1]
polygon = PoolVector2Array( 338.558, 76.2244, 431.056, -205.476, 401.625, -428.313, 271.286, -579.675, 52.6532, -663.764, 115.72, -705.809, -6.20956, -764.672, 77.8801, -794.103, 23.2217, -873.989, 14.8128, -937.056, -44.05, -970.692, -94.5037, -882.398, -44.05, -844.557, -6.20956, -844.557, -111.322, -756.263, -2.00516, -722.627, -90.2992, -676.378, -363.591, -512.403, -451.884, -276.952, -414.044, 8.95264, -346.772, 114.065, -519.156, 420.992, -535.974, 589.171, -414.044, 639.625, -313.137, 601.785, -334.159, 854.054, -229.047, 929.734, -77.6858, 711.101, 6.40381, 639.625, 69.471, 854.054, 124.129, 950.757, 250.264, 938.143, 321.74, 807.804, 338.558, 593.376, 380.603, 631.216, 544.577, 593.376, 527.76, 450.423 )

[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 420.733, 180.052 )

[node name="test" type="Node2D"]

[node name="StaticBody2D" type="StaticBody2D" parent="."]
z_index = -1

[node name="LightOccluder2D" type="LightOccluder2D" parent="StaticBody2D"]
scale = Vector2( 0.05, 0.05 )
occluder = SubResource( 1 )

[node name="Sprite2" type="Sprite" parent="StaticBody2D"]
light_mask = 2
scale = Vector2( 0.05, 0.05 )
texture = ExtResource( 1 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2( 0, 40 )
scale = Vector2( 0.05, 0.05 )
shape = SubResource( 1 )
shape = SubResource( 2 )
4 changes: 3 additions & 1 deletion src/assets/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func _ready():
if "--server" in OS.get_cmdline_args():
main_player = false
if main_player:
$VisibleArea.enabled = true
$Dark.enabled = true
ourname = Network.get_player_name()
print(ourname)
print("ourname: ", ourname)
$Label.text = ourname
# Only called when main_player is true
func get_input():
Expand Down
30 changes: 23 additions & 7 deletions src/assets/player/player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=19 format=2]

[ext_resource path="res://assets/player/player.gd" type="Script" id=1]
[ext_resource path="res://assets/player/textures/characters/black/walk-h/black-r-walk-4-4.png" type="Texture" id=2]
Expand All @@ -14,6 +14,8 @@
[ext_resource path="res://assets/player/textures/characters/black/walk-v/black-up2-1-4.png" type="Texture" id=12]
[ext_resource path="res://assets/player/textures/characters/black/walk-v/black-up2-4-4.png" type="Texture" id=13]
[ext_resource path="res://assets/player/textures/characters/black/walk-v/black-up2-3-4.png" type="Texture" id=14]
[ext_resource path="res://assets/player/textures/light.png" type="Texture" id=15]
[ext_resource path="res://assets/player/textures/dark.png" type="Texture" id=16]

[sub_resource type="CapsuleShape2D" id=1]
radius = 15.0
Expand All @@ -25,11 +27,6 @@ animations = [ {
"name": "idle",
"speed": 5.0
}, {
"frames": [ ExtResource( 12 ), ExtResource( 11 ), ExtResource( 14 ), ExtResource( 13 ) ],
"loop": true,
"name": "walk-up",
"speed": 8.0
}, {
"frames": [ ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 10 ) ],
"loop": true,
"name": "walk-down",
Expand All @@ -39,6 +36,11 @@ animations = [ {
"loop": true,
"name": "walk-h",
"speed": 5.0
}, {
"frames": [ ExtResource( 12 ), ExtResource( 11 ), ExtResource( 14 ), ExtResource( 13 ) ],
"loop": true,
"name": "walk-up",
"speed": 8.0
} ]

[node name="Player" type="KinematicBody2D"]
Expand All @@ -53,7 +55,7 @@ shape = SubResource( 1 )
[node name="Sprite" type="AnimatedSprite" parent="."]
frames = SubResource( 2 )
animation = "walk-h"
frame = 2
frame = 3
playing = true

[node name="Label" type="Label" parent="."]
Expand All @@ -66,3 +68,17 @@ align = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Dark" type="Light2D" parent="."]
scale = Vector2( 2065.42, -2756.44 )
enabled = false
texture = ExtResource( 16 )
color = Color( 1, 1, 1, 0 )
mode = 3
shadow_item_cull_mask = -2147483647

[node name="VisibleArea" type="Light2D" parent="."]
enabled = false
texture = ExtResource( 15 )
mode = 2
shadow_item_cull_mask = -2147483647
3 changes: 3 additions & 0 deletions src/assets/player/textures/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/assets/player/textures/dark.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/dark.png-0d8a4d94fb4aa551e475ab5ca4b5cd6f.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/player/textures/dark.png"
dest_files=[ "res://.import/dark.png-0d8a4d94fb4aa551e475ab5ca4b5cd6f.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
3 changes: 3 additions & 0 deletions src/assets/player/textures/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/assets/player/textures/light.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/light.png-e3f6775575ebd4572b84d7be136234d9.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/player/textures/light.png"
dest_files=[ "res://.import/light.png-e3f6775575ebd4572b84d7be136234d9.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
22 changes: 12 additions & 10 deletions src/assets/ui/mainmenu/playgame/playgame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ __meta__ = {

[node name="CreateGameMenu" type="VBoxContainer" parent="."]
visible = false
margin_right = 640.0
margin_bottom = 64.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1

[node name="PortLine" type="HBoxContainer" parent="CreateGameMenu"]
margin_right = 640.0
Expand All @@ -42,9 +42,11 @@ caret_blink = true
caret_blink_speed = 0.5

[node name="Name" type="HBoxContainer" parent="CreateGameMenu"]
anchor_right = 1.0
margin_top = 38.0
margin_right = 640.0
margin_bottom = 68.0
alignment = 1

[node name="Name" type="Label" parent="CreateGameMenu/Name"]
margin_top = 4.0
Expand Down Expand Up @@ -72,11 +74,11 @@ text = "BACK"

[node name="JoinGameMenu" type="VBoxContainer" parent="."]
visible = false
margin_right = 640.0
margin_bottom = 100.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down Expand Up @@ -150,36 +152,36 @@ margin_bottom = 190.0
text = "BACK"

[node name="PlayGameMenu" type="VBoxContainer" parent="."]
margin_right = 640.0
margin_bottom = 124.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1

[node name="Tutorial" type="Button" parent="PlayGameMenu"]
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 34.0
disabled = true
text = "TUTORIAL"
flat = true

[node name="JoinGame" type="Button" parent="PlayGameMenu"]
margin_top = 42.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 76.0
text = "JOIN GAME"
flat = true

[node name="CreateGame" type="Button" parent="PlayGameMenu"]
margin_top = 84.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 118.0
text = "CREATE GAME"
flat = true

[node name="Back" type="Button" parent="PlayGameMenu"]
margin_top = 126.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 160.0
text = "BACK"
flat = true
Expand Down
1 change: 1 addition & 0 deletions src/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ binary_format/embed_pck=true
custom_template/release=""
custom_template/debug=""
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
Expand Down
2 changes: 1 addition & 1 deletion src/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PlayerManager="*res://assets/autoload/playermanager.gd"
[display]

window/stretch/mode="2d"
window/stretch/aspect="keep"
window/stretch/aspect="expand"

[gui]

Expand Down

0 comments on commit d8372fa

Please sign in to comment.