# Duane's Dungeon - a rogue-like game # Copyright (C) 2023 Duane Robertson # state_minimap.gd - test state that shows text # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . extends State class_name StateMinimap var map:Dungeon var minimap var map_rect:Rect2i var title:Label func _ready(): super() name = 'StateMinimap' map = get_parent().map map_rect = Rect2i(get_parent().map_pos, get_parent().MAP_SZ) show_map() func input(event): if (event is InputEventKey and Input.is_action_pressed('ui_minimap')) \ or (event is InputEventMouseButton and event.pressed): minimap.visible = false exit() func show_map(): if minimap: minimap.queue_free() minimap = null else: minimap = map.make_mini_map() minimap.position = map_rect.position as Vector2 var sc = (map_rect.size as Vector2) / (map.bounds.size as Vector2) minimap.scale = Vector2.ONE * sc add_child(minimap)