Initial commit

This commit is contained in:
istamarahsan 2025-01-11 10:07:37 +07:00
commit 1cf3019178
8 changed files with 351 additions and 0 deletions

2
.gitattributes vendored Normal file
View file

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

3
.gitignore vendored Normal file
View file

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

132
export_presets.cfg Normal file
View file

@ -0,0 +1,132 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=false
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="C:/Users/ahsan/OneDrive/Desktop/build.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=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=""
application/export_angle=0
application/export_d3d12=0
application/d3d12_agility_sdk_multiarch=true
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="Windows Server"
platform="Windows Desktop"
runnable=false
advanced_options=false
dedicated_server=true
custom_features=""
export_filter="customized"
customized_files={
"res://": "strip"
}
include_filter=""
exclude_filter=""
export_path="C:/Users/ahsan/OneDrive/Desktop/server.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=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=""
application/export_angle=0
application/export_d3d12=0
application/d3d12_agility_sdk_multiarch=true
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}'"

1
icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><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 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dbla0xaub2d6"
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

76
main.gd Normal file
View file

@ -0,0 +1,76 @@
extends Node
const PORT = 25565
const MAX_CONNECTIONS = 20
var counter = 0
@onready var before_connect_container = get_node("BeforeConnect") as Container
@onready var host_text_edit = get_node("%HostTextEdit") as TextEdit
@onready var connect_button = get_node("%ConnectButton") as Button
@onready var after_connect_container = get_node("%AfterConnect") as Container
@onready var counter_label = get_node("%CounterLabel") as Label
@onready var decrement_button = get_node("%DecrementButton") as Button
@onready var increment_button = get_node("%IncrementButton") as Button
func _ready() -> void:
if OS.has_feature("dedicated_server"):
print("Starting dedicated server")
var peer = ENetMultiplayerPeer.new()
var err = peer.create_server(PORT, MAX_CONNECTIONS)
if err:
print(err)
multiplayer.multiplayer_peer = peer
multiplayer.peer_connected.connect(_on_player_connected)
else:
print("Game starting")
#multiplayer.peer_disconnected.connect(_on_player_disconnected)
multiplayer.connected_to_server.connect(_on_connected_ok)
#multiplayer.connection_failed.connect(_on_connected_fail)
#multiplayer.server_disconnected.connect(_on_server_disconnected)
increment_button.button_up.connect(func(): _increment.rpc())
decrement_button.button_up.connect(func(): _decrement.rpc())
connect_button.button_up.connect(_on_connect_pressed)
@rpc("any_peer", "call_local")
func _increment():
counter += 1
counter_label.text = str(counter)
@rpc("any_peer", "call_local")
func _decrement():
counter -= 1
counter_label.text = str(counter)
@rpc("authority", "call_remote")
func _set_counter(value: int):
counter = value
counter_label.text = str(counter)
func _on_connect_pressed():
var peer = ENetMultiplayerPeer.new()
var parsed: PackedStringArray = host_text_edit.text.split(":")
print("Connecting to ", parsed[0])
peer.create_client(parsed[0] if not parsed[0].is_empty() else "localhost", int(parsed[1]) if parsed.size() > 1 else PORT)
multiplayer.multiplayer_peer = peer
func _on_player_connected(id: int):
if multiplayer.get_unique_id() == 1:
_set_counter.rpc_id(id, counter)
func _on_player_disconnected():
pass
func _on_connected_ok():
$AfterConnect.visible = true
$BeforeConnect.visible = false
counter_label.text = str(counter)
func _on_connected_fail():
pass
func _on_server_disconnected():
pass

80
main.tscn Normal file
View file

@ -0,0 +1,80 @@
[gd_scene load_steps=2 format=3 uid="uid://c7gn46af6whf8"]
[ext_resource type="Script" path="res://main.gd" id="1_e0ud3"]
[node name="Main" 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_e0ud3")
[node name="BeforeConnect" type="VBoxContainer" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -187.5
offset_top = -88.0
offset_right = 187.5
offset_bottom = 88.0
grow_horizontal = 2
grow_vertical = 2
alignment = 1
[node name="HostTextEdit" type="TextEdit" parent="BeforeConnect"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
placeholder_text = "192.168.*.*"
[node name="ConnectButton" type="Button" parent="BeforeConnect"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
text = "Connect"
[node name="AfterConnect" type="VBoxContainer" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -187.5
offset_top = -88.5
offset_right = 187.5
offset_bottom = 88.5
grow_horizontal = 2
grow_vertical = 2
[node name="CounterLabel" type="Label" parent="AfterConnect"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_font_sizes/font_size = 64
text = "1"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Actions" type="HBoxContainer" parent="AfterConnect"]
layout_mode = 2
[node name="DecrementButton" type="Button" parent="AfterConnect/Actions"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "-"
[node name="IncrementButton" type="Button" parent="AfterConnect/Actions"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "+"

20
project.godot Normal file
View file

@ -0,0 +1,20 @@
; 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="tcg"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.3", "Mobile")
config/icon="res://icon.svg"
[rendering]
renderer/rendering_method="mobile"