Initial commit

main
Elnu 1 year ago
commit 8d5714c215

2
.gitattributes vendored

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

@ -0,0 +1,101 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="./nzbrawl.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=0
binary_format/embed_pck=true
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"
[preset.1]
name="Linux/X11"
platform="Linux/X11"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/nzbrawl.zip"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=0
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""

@ -0,0 +1,3 @@
extends Node
var players = {}

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b2rvll882ejor"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

@ -0,0 +1,53 @@
[gd_scene load_steps=4 format=3 uid="uid://r5n0cnh707fi"]
[ext_resource type="Script" path="res://scene_manager.gd" id="1_ywv22"]
[ext_resource type="PackedScene" uid="uid://b6olswaoek0bw" path="res://player.tscn" id="2_b15um"]
[ext_resource type="PackedScene" uid="uid://dmbiy6vupfawk" path="res://platform.tscn" id="3_njyoi"]
[node name="Main" type="Node2D"]
script = ExtResource("1_ywv22")
player_scene = ExtResource("2_b15um")
[node name="PlayerSpawns" type="Node2D" parent="."]
[node name="0" type="Node2D" parent="PlayerSpawns" groups=["PlayerSpawnPoint"]]
position = Vector2(526, 361)
[node name="1" type="Node2D" parent="PlayerSpawns" groups=["PlayerSpawnPoint"]]
position = Vector2(848, 361)
[node name="CollisionShape2D" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(114, 593)
scale = Vector2(9.84444, 4.5)
[node name="CollisionShape2D2" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(323, 448)
scale = Vector2(9.40821, 0.413171)
[node name="CollisionShape2D5" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(606, 389)
scale = Vector2(9.40821, 0.413171)
[node name="CollisionShape2D6" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(-50, 393)
scale = Vector2(9.40821, 0.413171)
[node name="CollisionShape2D7" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(31, 273)
scale = Vector2(9.40821, 0.413171)
[node name="CollisionShape2D3" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(289, 634)
scale = Vector2(53.8059, 1.28385)
[node name="CollisionShape2D8" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(289, 634)
scale = Vector2(53.8059, 1.28385)
[node name="CollisionShape2D4" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(-392, 155)
scale = Vector2(26.2654, 622.781)
[node name="CollisionShape2D9" parent="." instance=ExtResource("3_njyoi")]
position = Vector2(1499, 155)
scale = Vector2(26.2654, 622.781)

@ -0,0 +1,89 @@
extends Control
@export var port = 1717
@export var max_players = 4
var COMPRESSION = ENetConnection.COMPRESS_RANGE_CODER
var line_edit: LineEdit
var peer: ENetMultiplayerPeer
# Called when the node enters the scene tree for the first time.
func _ready():
multiplayer.peer_connected.connect(peer_connected)
multiplayer.peer_disconnected.connect(peer_disconnected)
multiplayer.connected_to_server.connect(connected_to_server)
multiplayer.connection_failed.connect(connection_failed)
# We have to enable object encoding to send PlayerData, etc.
multiplayer.allow_object_decoding = true
line_edit = get_node("LineEditName")
# Called on both server and clients
func peer_connected(id):
print("Player connected " + str(id))
# Called on both server and clients
func peer_disconnected(id):
print("Player disconnected " + str(id))
@rpc("any_peer")
func send_player_data(player_data: Dictionary):
if !GameManager.players.has(player_data.id):
GameManager.players[player_data.id] = player_data
if multiplayer.is_server():
for i in GameManager.players:
send_player_data.rpc(GameManager.players[i])
# Called only from clients
func connected_to_server():
print("Connected to server!")
send_player_data.rpc_id(1, {
"id": multiplayer.get_unique_id(),
"name": line_edit.text if line_edit.text else "Player"
})
# Called only from clients
func connection_failed():
print("Couldn't connect!")
func _on_host_pressed():
# Create peer instance for host's player
peer = ENetMultiplayerPeer.new()
var error = peer.create_server(port, max_players)
if error != OK:
print("Cannot host: " + error)
peer.get_host().compress(COMPRESSION)
# Connect host's player
multiplayer.set_multiplayer_peer(peer)
print("Waiting for players!")
send_player_data({
"id": multiplayer.get_unique_id(),
"name": line_edit.text if line_edit.text else "Player"
})
func _on_join_pressed():
peer = ENetMultiplayerPeer.new()
peer.create_client($LineEditIP.text if $LineEditIP.text else "127.0.0.1", port)
peer.get_host().compress(COMPRESSION)
multiplayer.set_multiplayer_peer(peer)
@rpc("any_peer", "call_local")
func start_game():
var scene = load("res://main.tscn").instantiate()
get_tree().root.add_child(scene)
self.hide()
func _on_start_game_pressed():
start_game.rpc()

@ -0,0 +1,56 @@
[gd_scene load_steps=2 format=3 uid="uid://btcrmlpg4lrbt"]
[ext_resource type="Script" path="res://multiplayer_controller.gd" id="1_e6bhu"]
[node name="MultiplayerController" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_e6bhu")
[node name="Host" type="Button" parent="."]
layout_mode = 2
offset_left = 487.0
offset_top = 259.0
offset_right = 583.0
offset_bottom = 290.0
text = "Host"
[node name="Join" type="Button" parent="."]
layout_mode = 2
offset_left = 733.0
offset_top = 167.0
offset_right = 829.0
offset_bottom = 198.0
text = "Join"
[node name="Start Game" type="Button" parent="."]
layout_mode = 2
offset_left = 596.0
offset_top = 257.0
offset_right = 692.0
offset_bottom = 288.0
text = "Start Game"
[node name="LineEditName" type="LineEdit" parent="."]
layout_mode = 2
offset_left = 419.0
offset_top = 167.0
offset_right = 727.0
offset_bottom = 198.0
placeholder_text = "Name..."
[node name="LineEditIP" type="LineEdit" parent="."]
layout_mode = 2
offset_left = 417.0
offset_top = 130.0
offset_right = 731.0
offset_bottom = 161.0
placeholder_text = "IP..."
[connection signal="pressed" from="Host" to="." method="_on_host_pressed"]
[connection signal="pressed" from="Join" to="." method="_on_join_pressed"]
[connection signal="pressed" from="Start Game" to="." method="_on_start_game_pressed"]

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://dmbiy6vupfawk"]
[ext_resource type="Texture2D" uid="uid://dbjqbgu6ru4m1" path="res://white.png" id="1_eu1eh"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6fi6a"]
size = Vector2(32, 32)
[node name="CollisionShape2D" type="StaticBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_6fi6a")
[node name="Sprite2D" type="Sprite2D" parent="."]
modulate = Color(0.105882, 0.105882, 0.105882, 1)
texture = ExtResource("1_eu1eh")

@ -0,0 +1,65 @@
extends CharacterBody2D
@export var speed = 300.0
@export var jump_velocity = -400.0
@export var wall_jump_velocity = 600.0
@export var ungrounded_x_lerp = 10.0
@export var grounded_drag_lerp = 5.0
@export var ungrounded_drag_lerp = 5.0
@export var fox_time = 5
@export var limp_gravity_modifier = 2.0
var x_velocity_offset = 0
var x_movement = 0
var desired_x_movement = 0
var last_grounded = 0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _ready():
$MultiplayerSynchronizer.set_multiplayer_authority(name.to_int())
var username = GameManager.players[name.to_int()].name
$Label.text = username
var username_hash = 0
for i in username.length():
username_hash += username.unicode_at(i)
$Sprite2D.modulate = Color.from_hsv((username_hash % 255) / 255.0, 0.5, 0.8)
func _physics_process(delta):
if $MultiplayerSynchronizer.get_multiplayer_authority() != multiplayer.get_unique_id():
return
# Add the gravity.
if is_on_floor():
last_grounded = Time.get_ticks_msec()
else:
velocity.y += gravity * delta * (limp_gravity_modifier if Input.is_action_pressed("limp") else 1)
var grounded = Time.get_ticks_msec() - last_grounded < fox_time
x_velocity_offset = lerpf(x_velocity_offset, 0, (grounded_drag_lerp if is_on_floor() else ungrounded_drag_lerp) * delta)
# Handle Jump.
if Input.is_action_just_pressed("jump"):
if grounded:
velocity.y = jump_velocity
elif len($WallDetect.get_overlapping_bodies()) > 0:
velocity.y = jump_velocity
if $WallDetect.get_overlapping_bodies()[0].position.x > position.x:
x_velocity_offset = -wall_jump_velocity
else:
x_velocity_offset = wall_jump_velocity
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("move_left", "move_right")
velocity.x = x_velocity_offset
if direction:
desired_x_movement = direction * speed;
x_movement = lerpf(x_movement, desired_x_movement, 1 if grounded else ungrounded_x_lerp * delta)
velocity.x += x_movement
else:
velocity.x = move_toward(velocity.x, 0, speed)
move_and_slide()

@ -0,0 +1,57 @@
[gd_scene load_steps=6 format=3 uid="uid://b6olswaoek0bw"]
[ext_resource type="Script" path="res://player.gd" id="1_0p8o6"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_2xv6m"]
load_path = "res://.godot/imported/white.png-d8533361663a5f8fe5200e5b5262a62d.ctex"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8wbiu"]
size = Vector2(32, 48)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2cyhj"]
size = Vector2(38, 48)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_38o4e"]
properties/0/path = NodePath(".:position")
properties/0/spawn = true
properties/0/sync = true
properties/0/watch = false
[node name="Player" type="CharacterBody2D"]
collision_layer = 2
script = ExtResource("1_0p8o6")
jump_velocity = -700.0
wall_jump_velocity = 700.0
fox_time = 100
limp_gravity_modifier = 3.0
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(1, 1.5)
texture = SubResource("CompressedTexture2D_2xv6m")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_8wbiu")
[node name="WallDetect" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="WallDetect"]
shape = SubResource("RectangleShape2D_2cyhj")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_38o4e")
[node name="Label" type="Label" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -24.5
offset_top = -54.0
offset_right = 24.5
offset_bottom = -28.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
text = "Player"
horizontal_alignment = 1

@ -0,0 +1,62 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="nzbrawl"
run/main_scene="res://multiplayer_controller.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/icon="res://icon.svg"
[autoload]
GameManager="*res://game_manager.gd"
[debug]
gdscript/warnings/shadowed_variable=0
gdscript/warnings/shadowed_variable_base_class=0
[input]
move_left={
"deadzone": 0.5,
"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":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
, 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":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"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":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, 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":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
jump={
"deadzone": 0.5,
"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":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
, 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":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, 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":32,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
limp={
"deadzone": 0.5,
"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":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
, 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":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, 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":70,"key_label":0,"unicode":102,"echo":false,"script":null)
]
}
[physics]
2d/default_gravity=2000.0
[rendering]
renderer/rendering_method.mobile="gl_compatibility"

@ -0,0 +1,17 @@
extends Node2D
@export var player_scene: PackedScene
# Called when the node enters the scene tree for the first time.
func _ready():
var spawn_points = get_tree().get_nodes_in_group("PlayerSpawnPoint")
for i in GameManager.players:
var current_player: Node2D = player_scene.instantiate()
current_player.name = str(GameManager.players[i].id)
current_player.global_position = spawn_points[i % len(spawn_points)].global_position
add_child(current_player)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dbjqbgu6ru4m1"
path="res://.godot/imported/white.png-d8533361663a5f8fe5200e5b5262a62d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://white.png"
dest_files=["res://.godot/imported/white.png-d8533361663a5f8fe5200e5b5262a62d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading…
Cancel
Save