Initial commit

This commit is contained in:
GeekROS
2024-03-03 22:59:18 +08:00
commit cec0aae8e3
69 changed files with 2687 additions and 0 deletions

1
engine/assets/icon.svg Normal file
View File

@@ -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

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://uxjhy0m5hoin"
path="res://.godot/imported/icon.svg-56083ea2a1f1a4f1e49773bdc6d7826c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon.svg"
dest_files=["res://.godot/imported/icon.svg-56083ea2a1f1a4f1e49773bdc6d7826c.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d05rp7emahb2e"
path="res://.godot/imported/background.jpeg-5639b05a789575f90a2f9972dfc49a59.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/launch/background.jpeg"
dest_files=["res://.godot/imported/background.jpeg-5639b05a789575f90a2f9972dfc49a59.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

40
engine/project.godot Normal file
View File

@@ -0,0 +1,40 @@
; 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="Mir of Godot"
config/version="1.0.0"
run/main_scene="res://scenes/launch/launch.tscn"
config/features=PackedStringArray("4.2", "Mobile")
boot_splash/bg_color=Color(0, 0, 0, 1)
config/icon="res://assets/icon.svg"
[autoload]
Global="*res://scripts/framework/global.gd"
Server="*res://scripts/framework/server/server.gd"
Client="*res://scripts/framework/client/client.gd"
Request="*res://scripts/framework/utils/request.gd"
[display]
window/size/viewport_width=1280
window/size/viewport_height=720
window/stretch/scale_mode="integer"
[filesystem]
import/blender/enabled=false
[rendering]
renderer/rendering_method="mobile"
environment/defaults/default_clear_color=Color(0, 0, 0, 1)

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=3 uid="uid://i6g3y6btijjm"]
[ext_resource type="Texture2D" uid="uid://d05rp7emahb2e" path="res://assets/launch/background.jpeg" id="1_5xji2"]
[node name="Launch" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Background" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_5xji2")
expand_mode = 2
stretch_mode = 6

View File

@@ -0,0 +1,28 @@
#*****************************************************************************
# @file client.gd
# @author MakerYang(https://www.makeryang.com)
# @statement 免费课程配套开源项目,任何形式收费均为盗版
#*****************************************************************************
extends Node
# 初始化自定义数据
var client_peer:ENetMultiplayerPeer
# 初始化数据结构
var data = {
"client_id": 0
}
# 创建客户端并返回客户端状态
func create_client() -> int:
client_peer = ENetMultiplayerPeer.new()
var error = client_peer.create_client(Global.get_server_address(), Global.get_server_port())
if error == OK:
multiplayer.multiplayer_peer = client_peer
# 更新客户端ID
update_client_id(multiplayer.get_unique_id())
return error
# 更新客户端ID
func update_client_id(client_id: int) -> void:
data["client_id"] = client_id

View File

@@ -0,0 +1,53 @@
#*****************************************************************************
# @file global.gd
# @author MakerYang(https://www.makeryang.com)
# @statement 免费课程配套开源项目,任何形式收费均为盗版
#*****************************************************************************
extends Node
# 初始化数据结构
var data = {
"varsion": "1.0.0",
"mode": "",
"server": {
"port": 7020,
"address": "game.makeryang.com"
},
"account": {
"token": ""
}
}
func _ready() -> void:
# 服务器模式检测
if OS.has_feature("dedicated_server"):
print("[服务器模式]")
data["mode"] = "server"
var error = Server.create_server()
if error != OK:
printerr("[服务器创建失败]")
else:
print("[客户端模式]")
data["mode"] = "client"
var error = Client.create_client()
if error != OK:
printerr("[服务器连接失败]")
# 是否为服务器模式
func is_server() -> bool:
var server = false
if data["mode"] == "server":
server = true
return server
# 获取服务器端口
func get_server_port() -> int:
return data["server"]["port"]
# 获取服务器端口
func get_server_address() -> String:
return data["server"]["address"]
# 获取用户Token
func get_account_token() -> String:
return data["account"]["token"]

View File

@@ -0,0 +1,29 @@
#*****************************************************************************
# @file server.gd
# @author MakerYang(https://www.makeryang.com)
# @statement 免费课程配套开源项目,任何形式收费均为盗版
#*****************************************************************************
extends Node
# 初始化自定义数据
var server_peer:ENetMultiplayerPeer
# 创建服务器并返回服务器状态
func create_server() -> int:
print("[创建服务器...]")
server_peer = ENetMultiplayerPeer.new()
var error = server_peer.create_server(Global.get_server_port())
if error == OK:
multiplayer.multiplayer_peer = server_peer
multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
print("[服务器创建成功]")
return error
# 客户端连接服务器时回调函数
func _on_peer_connected(id: int) -> void:
print("[新的客户端连接 " + str(id) + "]")
# 客户端断开服务器时回调函数
func _on_peer_disconnected(id: int) -> void:
print("[客户端连接断开 " + str(id) + "]")

View File

@@ -0,0 +1,30 @@
#*****************************************************************************
# @file request.gd
# @author MakerYang(https://www.makeryang.com)
# @statement 免费课程配套开源项目,任何形式收费均为盗版
#*****************************************************************************
extends Node
# 初始化自定义数据
var http_request:HTTPRequest = HTTPRequest.new()
var http_callback = null
# 初始化数据结构
var data = {
"headers": [
"Content-Type: application/json",
"Account-Token: ",
]
}
# 请求服务器接口
func on_server(path: String, method: int, parameter, callback) -> void:
if !http_request.is_inside_tree():
add_child(http_request)
var parameter_json = JSON.stringify(parameter)
data["headers"][1] = "Account-Token: " + Global.get_account_token()
if http_callback and http_request.is_connected("request_completed", http_callback):
http_request.request_completed.disconnect(http_callback)
http_request.request_completed.connect(callback)
http_callback = callback
http_request.request("https://" + Global.get_server_address() + path, data["headers"], method, parameter_json)