From 9b47e374c777e6b851ecb7dc1a994f265c065199 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 14 Jan 2024 12:22:14 +0100 Subject: [PATCH] Initial commit --- .gitattributes | 2 + .gitignore | 15 +++++ README.md | 0 client/Client.gd | 10 +++ player/Player.gd | 7 ++ player/Player.tscn | 12 ++++ project.godot | 94 ++++++++++++++++++++++++++ server/core/Client.go | 17 +++++ server/core/Server.go | 115 ++++++++++++++++++++++++++++++++ server/go.mod | 3 + server/main.go | 17 +++++ ui/FPS.gd | 8 +++ ui/Ping.gd | 38 +++++++++++ ui/UI.tscn | 41 ++++++++++++ ui/icon.svg | 1 + ui/icon.svg.import | 37 ++++++++++ ui/theme.tres | 10 +++ ui/ubuntu_nf_regular.ttf.import | 38 +++++++++++ world/CameraAttributes.tres | 3 + world/Environment.tres | 8 +++ world/ProceduralSky.tres | 4 ++ world/Sky.tres | 6 ++ world/World.gd | 21 ++++++ world/World.tscn | 22 ++++++ 24 files changed, 529 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 client/Client.gd create mode 100644 player/Player.gd create mode 100644 player/Player.tscn create mode 100644 project.godot create mode 100644 server/core/Client.go create mode 100644 server/core/Server.go create mode 100644 server/go.mod create mode 100644 server/main.go create mode 100644 ui/FPS.gd create mode 100644 ui/Ping.gd create mode 100644 ui/UI.tscn create mode 100644 ui/icon.svg create mode 100644 ui/icon.svg.import create mode 100644 ui/theme.tres create mode 100644 ui/ubuntu_nf_regular.ttf.import create mode 100644 world/CameraAttributes.tres create mode 100644 world/Environment.tres create mode 100644 world/ProceduralSky.tres create mode 100644 world/Sky.tres create mode 100644 world/World.gd create mode 100644 world/World.tscn diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..40b3c2d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto eol=lf +*.ttf filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..620245f --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +* +!*/ +!*.go +!*.mod +!*.sum +!*.md +!*.gd +!*.import +!*.svg +!*.tres +!*.tscn +!.gitignore +!.gitattributes +!project.godot +.godot/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/client/Client.gd b/client/Client.gd new file mode 100644 index 0000000..76344b8 --- /dev/null +++ b/client/Client.gd @@ -0,0 +1,10 @@ +extends Node + +const PLAYER = preload("res://player/Player.tscn") +var udp := PacketPeerUDP.new() + +func _ready(): + udp.connect_to_host("127.0.0.1", 4242) + var player = PLAYER.instantiate() + add_child(player) + print("Ready.") diff --git a/player/Player.gd b/player/Player.gd new file mode 100644 index 0000000..407028f --- /dev/null +++ b/player/Player.gd @@ -0,0 +1,7 @@ +extends Node3D + +func _ready(): + pass + +func _process(delta): + rotate_y(delta) diff --git a/player/Player.tscn b/player/Player.tscn new file mode 100644 index 0000000..5ef2426 --- /dev/null +++ b/player/Player.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://2lcnu3dy54lx"] + +[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"] + +[sub_resource type="BoxMesh" id="BoxMesh_8125v"] + +[node name="Player" type="Node3D" groups=["Player"]] +script = ExtResource("1_8gebs") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) +mesh = SubResource("BoxMesh_8125v") diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..ce69b08 --- /dev/null +++ b/project.godot @@ -0,0 +1,94 @@ +; 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="Battle of Mages" +run/main_scene="res://world/World.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://ui/icon.svg" + +[autoload] + +Client="*res://client/Client.gd" + +[display] + +window/vsync/vsync_mode=0 + +[gui] + +theme/custom="res://ui/theme.tres" + +[input] + +move_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"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) +, 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(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"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":4194321,"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":68,"key_label":0,"unicode":100,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) +] +} +move_forward={ +"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":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":87,"key_label":0,"unicode":119,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) +] +} +move_backward={ +"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":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":83,"key_label":0,"unicode":115,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"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":32,"key_label":0,"unicode":32,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) +] +} +toggle_fullscreen={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"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":4194342,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +shoot={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":false,"script":null) +] +} +aim={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":false,"script":null) +] +} +crouch={ +"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":4194326,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +menu={ +"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":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null) +] +} diff --git a/server/core/Client.go b/server/core/Client.go new file mode 100644 index 0000000..7dbc6b6 --- /dev/null +++ b/server/core/Client.go @@ -0,0 +1,17 @@ +package core + +import ( + "net" + "time" +) + +// Client represents a UDP client. +type Client struct { + address *net.UDPAddr + lastPacket time.Time +} + +// String shows the client address. +func (c *Client) String() string { + return c.address.String() +} diff --git a/server/core/Server.go b/server/core/Server.go new file mode 100644 index 0000000..d1e79f3 --- /dev/null +++ b/server/core/Server.go @@ -0,0 +1,115 @@ +package core + +import ( + "fmt" + "net" + "time" +) + +// Handler is a byte code specific packet handler. +type Handler func([]byte, *Client) + +// Server represents a UDP server. +type Server struct { + socket *net.UDPConn + clients map[string]*Client + handlers [256]Handler +} + +// New creates a new server. +func New() *Server { + return &Server{ + clients: make(map[string]*Client), + } +} + +// AddHandler adds the handler for the given byte code. +func (s *Server) AddHandler(code byte, handler Handler) { + s.handlers[code] = handler +} + +// SendTo sends the data to a client. +func (s *Server) SendTo(data []byte, client *Client) { + _, err := s.socket.WriteToUDP(data, client.address) + + if err != nil { + fmt.Println("Error sending response:", err) + } +} + +// Run starts the server on the given port. +func (s *Server) Run(port int) { + s.socket = listen(port) + defer s.socket.Close() + + s.read() +} + +// listen creates a socket for the server and starts listening for incoming packets. +func listen(port int) *net.UDPConn { + addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", port)) + + if err != nil { + panic(err) + } + + connection, err := net.ListenUDP("udp", addr) + + if err != nil { + panic(err) + } + + return connection +} + +// read is a blocking call which will read incoming packets and handle them. +func (s *Server) read() { + buffer := make([]byte, 4096) + + for { + n, addr, err := s.socket.ReadFromUDP(buffer) + + if err != nil { + fmt.Println("Error reading from UDP connection:", err) + continue + } + + if n == 0 { + continue + } + + go s.handle(buffer[:n], addr) + } +} + +// handle deals with an incoming packet. +func (s *Server) handle(data []byte, addr *net.UDPAddr) { + c := s.getClient(addr) + c.lastPacket = time.Now() + // fmt.Printf("Received %d bytes from %s: %s\n", len(data), c, string(data)) + + handler := s.handlers[data[0]] + + if handler == nil { + fmt.Println("Unknown packet type.") + return + } + + handler(data, c) +} + +// getClient either returns a new or existing client for the requested address. +func (s *Server) getClient(addr *net.UDPAddr) *Client { + c, exists := s.clients[addr.String()] + + if exists { + return c + } + + c = &Client{ + address: addr, + } + + s.clients[addr.String()] = c + return c +} diff --git a/server/go.mod b/server/go.mod new file mode 100644 index 0000000..fba5bef --- /dev/null +++ b/server/go.mod @@ -0,0 +1,3 @@ +module server + +go 1.21.6 diff --git a/server/main.go b/server/main.go new file mode 100644 index 0000000..435dd35 --- /dev/null +++ b/server/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "server/core" +) + +func main() { + server := core.New() + + server.AddHandler(0, func(data []byte, client *core.Client) { + // count := data[1] + // fmt.Println(count) + server.SendTo(data, client) + }) + + server.Run(4242) +} diff --git a/ui/FPS.gd b/ui/FPS.gd new file mode 100644 index 0000000..cc501b2 --- /dev/null +++ b/ui/FPS.gd @@ -0,0 +1,8 @@ +extends Label + +func _ready(): + DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED) + +func _process(_delta): + var fps = Engine.get_frames_per_second() + text = str(fps) diff --git a/ui/Ping.gd b/ui/Ping.gd new file mode 100644 index 0000000..07edfee --- /dev/null +++ b/ui/Ping.gd @@ -0,0 +1,38 @@ +extends Label + +const HISTORY_SIZE = 8 + +var pingCount := 0 +var pingSent: Array[float] = [] + +func _ready(): + var timer := Timer.new() + add_child(timer) + timer.autostart = true + timer.wait_time = 1 + timer.connect("timeout", self._ping) + timer.start() + + pingSent.resize(HISTORY_SIZE) + +func _process(_delta): + if Client.udp.get_available_packet_count() > 0: + #print("Received: %s" % udp.get_packet().get_string_from_utf8()) + var bytes := Client.udp.get_packet() + var count := bytes.decode_u8(1) + var timeSent := pingSent[count] + var duration := Time.get_unix_time_from_system() - timeSent + var ping := duration * 1000 + text = str(snapped(ping, 0.01)) + +func _ping(): + var buffer := StreamPeerBuffer.new() + buffer.put_8(0) + buffer.put_8(pingCount) + Client.udp.put_packet(buffer.data_array) + + pingSent[pingCount] = Time.get_unix_time_from_system() + pingCount += 1 + + if pingCount >= HISTORY_SIZE: + pingCount = 0 diff --git a/ui/UI.tscn b/ui/UI.tscn new file mode 100644 index 0000000..b6d4220 --- /dev/null +++ b/ui/UI.tscn @@ -0,0 +1,41 @@ +[gd_scene load_steps=3 format=3 uid="uid://bxotvk73tbgw0"] + +[ext_resource type="Script" path="res://ui/FPS.gd" id="1_128dk"] +[ext_resource type="Script" path="res://ui/Ping.gd" id="2_m7fhx"] + +[node name="UI" type="Control"] +layout_mode = 3 +anchors_preset = 0 + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer"] +offset_right = 40.0 +offset_bottom = 50.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/MarginContainer"] +layout_mode = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="FPSLabel" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "FPS:" + +[node name="FPS" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "0" +script = ExtResource("1_128dk") + +[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="PingLabel" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +text = "Ping:" + +[node name="Ping" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +text = "0" +script = ExtResource("2_m7fhx") diff --git a/ui/icon.svg b/ui/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/ui/icon.svg @@ -0,0 +1 @@ + diff --git a/ui/icon.svg.import b/ui/icon.svg.import new file mode 100644 index 0000000..608150e --- /dev/null +++ b/ui/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://biplb56hj51h7" +path="res://.godot/imported/icon.svg-57a480398ce0db3d1582eb3ec78dffaa.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icon.svg" +dest_files=["res://.godot/imported/icon.svg-57a480398ce0db3d1582eb3ec78dffaa.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 diff --git a/ui/theme.tres b/ui/theme.tres new file mode 100644 index 0000000..cc08b44 --- /dev/null +++ b/ui/theme.tres @@ -0,0 +1,10 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://caqphxkvcu3tb"] + +[ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://ui/ubuntu_nf_regular.ttf" id="1_1unma"] + +[resource] +default_font = ExtResource("1_1unma") +MarginContainer/constants/margin_bottom = 5 +MarginContainer/constants/margin_left = 5 +MarginContainer/constants/margin_right = 5 +MarginContainer/constants/margin_top = 5 diff --git a/ui/ubuntu_nf_regular.ttf.import b/ui/ubuntu_nf_regular.ttf.import new file mode 100644 index 0000000..05ef6cf --- /dev/null +++ b/ui/ubuntu_nf_regular.ttf.import @@ -0,0 +1,38 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://b7mov13kwi8u8" +path="res://.godot/imported/ubuntu_nf_regular.ttf-feed7a5a59b6d10a4a32843efe52a9da.fontdata" + +[deps] + +source_file="res://ui/ubuntu_nf_regular.ttf" +dest_files=["res://.godot/imported/ubuntu_nf_regular.ttf-feed7a5a59b6d10a4a32843efe52a9da.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[{ +"chars": [], +"glyphs": [], +"name": "New Configuration", +"size": Vector2i(16, 0) +}] +language_support={} +script_support={} +opentype_features={} diff --git a/world/CameraAttributes.tres b/world/CameraAttributes.tres new file mode 100644 index 0000000..f3539e6 --- /dev/null +++ b/world/CameraAttributes.tres @@ -0,0 +1,3 @@ +[gd_resource type="CameraAttributesPractical" format=3 uid="uid://b835orxyqq6w5"] + +[resource] diff --git a/world/Environment.tres b/world/Environment.tres new file mode 100644 index 0000000..883f82f --- /dev/null +++ b/world/Environment.tres @@ -0,0 +1,8 @@ +[gd_resource type="Environment" load_steps=2 format=3 uid="uid://dixa0yso2s1u3"] + +[ext_resource type="Sky" uid="uid://b0q75qnaj0r5h" path="res://world/Sky.tres" id="1_utnj1"] + +[resource] +sky = ExtResource("1_utnj1") +ambient_light_source = 3 +reflected_light_source = 2 diff --git a/world/ProceduralSky.tres b/world/ProceduralSky.tres new file mode 100644 index 0000000..3844b50 --- /dev/null +++ b/world/ProceduralSky.tres @@ -0,0 +1,4 @@ +[gd_resource type="ProceduralSkyMaterial" format=3 uid="uid://b7q6crweeh3jv"] + +[resource] +ground_bottom_color = Color(0.0313726, 0.0470588, 0.160784, 1) diff --git a/world/Sky.tres b/world/Sky.tres new file mode 100644 index 0000000..7c5edf7 --- /dev/null +++ b/world/Sky.tres @@ -0,0 +1,6 @@ +[gd_resource type="Sky" load_steps=2 format=3 uid="uid://b0q75qnaj0r5h"] + +[ext_resource type="Material" uid="uid://b7q6crweeh3jv" path="res://world/ProceduralSky.tres" id="1_7mt7h"] + +[resource] +sky_material = ExtResource("1_7mt7h") diff --git a/world/World.gd b/world/World.gd new file mode 100644 index 0000000..32d0447 --- /dev/null +++ b/world/World.gd @@ -0,0 +1,21 @@ +extends Node + +func _ready(): + # Capture mouse + #Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + + # Mute audio + var master_sound = AudioServer.get_bus_index("Master") + AudioServer.set_bus_mute(master_sound, true) + +func _input(event): + if event.is_action_pressed("toggle_fullscreen"): + var mode = DisplayServer.window_get_mode() + + match mode: + DisplayServer.WINDOW_MODE_FULLSCREEN: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) + _: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) + + return diff --git a/world/World.tscn b/world/World.tscn new file mode 100644 index 0000000..a11e9bf --- /dev/null +++ b/world/World.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=5 format=3 uid="uid://b40y7iuskv1ar"] + +[ext_resource type="Script" path="res://world/World.gd" id="1_2lci4"] +[ext_resource type="Environment" uid="uid://dixa0yso2s1u3" path="res://world/Environment.tres" id="1_qb8w4"] +[ext_resource type="CameraAttributesPractical" uid="uid://b835orxyqq6w5" path="res://world/CameraAttributes.tres" id="2_1nt3m"] +[ext_resource type="PackedScene" uid="uid://bxotvk73tbgw0" path="res://ui/UI.tscn" id="4_c6x8y"] + +[node name="World" type="Node"] +script = ExtResource("1_2lci4") + +[node name="UI" parent="." instance=ExtResource("4_c6x8y")] + +[node name="Camera" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5) +fov = 90.0 + +[node name="Sun" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.904299, 0.26004, -0.33856, 0, 0.793066, 0.609135, 0.4269, -0.55084, 0.717169, 0, 0, 0) + +[node name="Environment" type="WorldEnvironment" parent="."] +environment = ExtResource("1_qb8w4") +camera_attributes = ExtResource("2_1nt3m")