diff options
author | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-04-07 18:10:49 +0200 |
---|---|---|
committer | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-04-07 18:10:49 +0200 |
commit | 4617947cc0a1b769beacb750b4ec47667655dc8f (patch) | |
tree | a51994faf460c4da3d71123342d03892b4d888b0 /game | |
parent | 2364fbc03f0a44bcef0881b38a5cf74fa819fb7f (diff) |
minimap-first-try
Diffstat (limited to 'game')
-rw-r--r-- | game/common/map/MapFrame.png | bin | 0 -> 1043 bytes | |||
-rw-r--r-- | game/common/map/MapFrame.png.import | 34 | ||||
-rw-r--r-- | game/common/map/minimap.png | bin | 0 -> 69018 bytes | |||
-rw-r--r-- | game/common/map/minimap.png.import | 34 | ||||
-rw-r--r-- | game/src/GameSession/MapView.tscn | 2 | ||||
-rw-r--r-- | game/src/GameSession/Minimap.gd | 15 | ||||
-rw-r--r-- | game/src/GameSession/RectangularCamera.gd | 24 |
7 files changed, 108 insertions, 1 deletions
diff --git a/game/common/map/MapFrame.png b/game/common/map/MapFrame.png Binary files differnew file mode 100644 index 0000000..21aa2ce --- /dev/null +++ b/game/common/map/MapFrame.png 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 Binary files differnew file mode 100644 index 0000000..9e5bdb6 --- /dev/null +++ b/game/common/map/minimap.png 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() |