28 lines
810 B
GDScript
28 lines
810 B
GDScript
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)
|