From 4617947cc0a1b769beacb750b4ec47667655dc8f Mon Sep 17 00:00:00 2001 From: Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:10:49 +0200 Subject: minimap-first-try --- extension/src/MapMesh.cpp | 2 +- game/common/map/MapFrame.png | Bin 0 -> 1043 bytes game/common/map/MapFrame.png.import | 34 ++++++++++++++++++++++++++++++ game/common/map/minimap.png | Bin 0 -> 69018 bytes game/common/map/minimap.png.import | 34 ++++++++++++++++++++++++++++++ game/src/GameSession/MapView.tscn | 2 +- game/src/GameSession/Minimap.gd | 15 +++++++++++++ game/src/GameSession/RectangularCamera.gd | 24 +++++++++++++++++++++ 8 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 game/common/map/MapFrame.png create mode 100644 game/common/map/MapFrame.png.import create mode 100644 game/common/map/minimap.png create mode 100644 game/common/map/minimap.png.import create mode 100644 game/src/GameSession/Minimap.gd create mode 100644 game/src/GameSession/RectangularCamera.gd diff --git a/extension/src/MapMesh.cpp b/extension/src/MapMesh.cpp index f0fc819..ff69390 100644 --- a/extension/src/MapMesh.cpp +++ b/extension/src/MapMesh.cpp @@ -8,7 +8,7 @@ using namespace OpenVic2; void MapMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("set_aspect_ratio", "ratio"), &MapMesh::set_aspect_ratio); ClassDB::bind_method(D_METHOD("get_aspect_ratio"), &MapMesh::get_aspect_ratio); - + ClassDB::bind_method(D_METHOD("set_repeat_proportion", "proportion"), &MapMesh::set_repeat_proportion); ClassDB::bind_method(D_METHOD("get_repeat_proportion"), &MapMesh::get_repeat_proportion); diff --git a/game/common/map/MapFrame.png b/game/common/map/MapFrame.png new file mode 100644 index 0000000..21aa2ce Binary files /dev/null and b/game/common/map/MapFrame.png differ diff --git a/game/common/map/MapFrame.png.import b/game/common/map/MapFrame.png.import new file mode 100644 index 0000000..04756cc --- /dev/null +++ b/game/common/map/MapFrame.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://vr1hq2stk8ny" +path="res://.godot/imported/MapFrame.png-a4cf5a3479e19f337ce338f6f6ee4eb8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://common/map/MapFrame.png" +dest_files=["res://.godot/imported/MapFrame.png-a4cf5a3479e19f337ce338f6f6ee4eb8.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 diff --git a/game/common/map/minimap.png b/game/common/map/minimap.png new file mode 100644 index 0000000..9e5bdb6 Binary files /dev/null and b/game/common/map/minimap.png differ diff --git a/game/common/map/minimap.png.import b/game/common/map/minimap.png.import new file mode 100644 index 0000000..c69c844 --- /dev/null +++ b/game/common/map/minimap.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0sm1jfu4kyv3" +path="res://.godot/imported/minimap.png-6dff941a6fa3e94c55113971bbb32fcf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://common/map/minimap.png" +dest_files=["res://.godot/imported/minimap.png-6dff941a6fa3e94c55113971bbb32fcf.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 diff --git a/game/src/GameSession/MapView.tscn b/game/src/GameSession/MapView.tscn index 4650acb..63d16ef 100644 --- a/game/src/GameSession/MapView.tscn +++ b/game/src/GameSession/MapView.tscn @@ -19,7 +19,7 @@ _camera = NodePath("MapCamera") _map_mesh_instance = NodePath("MapMeshInstance") [node name="MapCamera" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 1, 1) +transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 1, 0) [node name="MapMeshInstance" type="MeshInstance3D" parent="."] transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0) diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/Minimap.gd new file mode 100644 index 0000000..4bf028b --- /dev/null +++ b/game/src/GameSession/Minimap.gd @@ -0,0 +1,15 @@ +extends Control + + +var MouseInside: bool = false + +func _process(delta): + if MouseInside: + print(get_local_mouse_position()) + +func _on_mouse_entered(): + MouseInside = true + + +func _on_mouse_exited(): + MouseInside = false diff --git a/game/src/GameSession/RectangularCamera.gd b/game/src/GameSession/RectangularCamera.gd new file mode 100644 index 0000000..55deb1d --- /dev/null +++ b/game/src/GameSession/RectangularCamera.gd @@ -0,0 +1,24 @@ +extends Control + + +@export var pos_x = 100.0 +@export var pos_y = 100.0 +@export var zoom_x = 10 +@export var zoom_y = 10 +@onready var _frame: TextureRect = $"../TextureRect" + +var RectangularCamera = Rect2(pos_x,pos_y,zoom_x,zoom_y) + +func _draw() -> void: + draw_rect(RectangularCamera,Color.BLACK,false,-1) + +func _on_map_view_map_view_camera_change(camera_position): + + zoom_x = camera_position.y*(_frame.size.x/20)*1.77 + zoom_y = camera_position.y*(_frame.size.y/20)*1.77 + + pos_x = camera_position.x*(_frame.size.x/20) + _frame.size.x/2 - zoom_x/2 # + _frame.size.x/2 - zoom_x/2 - Translation from camera_position.x to pos_x (i.e. 0px for center on camera_pos -> 175px for center on rect_camera) + pos_y = camera_position.z*(_frame.size.y/10) + _frame.size.y/2 - zoom_y/2 # + _frame.size.y/2 - zoom_y/2 - Translation from camera_position.y to pos_y (i.e. 0px for center on camera_pos -> 87.5px for center on rect_camera) + + RectangularCamera = Rect2(pos_x,pos_y,zoom_x,zoom_y) + queue_redraw() -- cgit v1.2.3-56-ga3b1