implement camera display marker to minimap
This commit is contained in:
parent
d0f0d8c009
commit
e2fb7638c8
6 changed files with 96 additions and 47 deletions
28
scenes/CameraMarker.gd
Normal file
28
scenes/CameraMarker.gd
Normal file
|
@ -0,0 +1,28 @@
|
|||
extends Sprite2D
|
||||
|
||||
var size_multiplier
|
||||
var w_s
|
||||
var previous_camera_zoom
|
||||
|
||||
# draws a box represnting the camera view in minimap
|
||||
func _draw():
|
||||
draw_rect(Rect2(-w_s.x/2, -w_s.y/2, w_s.x, w_s.y), Color.GREEN, false, -3.0)
|
||||
|
||||
|
||||
# rotates the box if camera is rotated
|
||||
func _on_camera_zoom_2d_camera_rotation_changed(new_rotation):
|
||||
self.rotation = new_rotation
|
||||
|
||||
|
||||
# redraws the box to a different size if amera is zoomed
|
||||
func _on_camera_zoom_2d_camera_zoom_changed(new_zoom_factor):
|
||||
w_s = (DisplayServer.window_get_size(0) / size_multiplier)
|
||||
w_s.x /= new_zoom_factor
|
||||
w_s.y /= new_zoom_factor
|
||||
queue_redraw()
|
||||
|
||||
|
||||
# Sets the initial size of the camera box, after game is loaded
|
||||
func _on_main_worldgen_ready() -> void:
|
||||
size_multiplier = Globals.map_size / 32
|
||||
w_s = (DisplayServer.window_get_size(0) / size_multiplier)
|
Loading…
Add table
Add a link
Reference in a new issue